I've got this script. not a python master, but it sort of works. There are issue with the output. I'm converting these STLs to FBX for use in Unreal. The problem is this conversion seems to cause the STLs to be flipped 180 degree vertically and it does something to the normals. The come into unreal looking like some kind of 80s heavy metal album cover. if I go into the modeling mode in Unreal and choose normals, before even making any changes they're instantly fixed. if I manually impor the STLs into blender and then export them into FBX through blender they're fine. But obviously I'm trying to automate this. Anyone know how I can fix that?
import os
import aspose.threed
from aspose.threed import Scene, FileFormat
Function to convert an STL mesh to FBX format with scaling and orientation
def convert_to_fbx(input_stl_path, output_fbx_path):
# Load the STL mesh
scene = Scene(input_stl_path)
# Save the mesh as FBX format
scene.save(output_fbx_path, FileFormat.FBX7400ASCII) # Save the scene as FBX format
Input directory for STL files and output directory for FBX files
input_stl_directory = r'I:\3DModels\Revelations\Terrain\Roads'
output_fbx_directory = r'I:\3DModels\Revelations\Terrain\Roads'
Convert each STL file to FBX format with scaling and orientation
for file in os.listdir(input_stl_directory):
if file.endswith(".stl"):
input_stl_path = os.path.join(input_stl_directory, file)
output_fbx_path = os.path.join(output_fbx_directory, os.path.splitext(file)[0] + ".fbx")
convert_to_fbx(input_stl_path, output_fbx_path)