#๐Ÿ”’ STL To FBX conversion script works, but has issues

5 messages ยท Page 1 of 1 (latest)

mild garnet
#

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)

dusty cloakBOT
#

@mild garnet

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

mild garnet
#

This will give you an idea of what I'm talking about with the normals.

dusty cloakBOT
#

@mild garnet

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.