22 lines
566 B
Python
22 lines
566 B
Python
import bpy
|
|
import sys
|
|
|
|
# Get-ChildItem -Path .\assets\*.stl | ForEach-Object { blender --background --python .\blender_stl_to_obj.py $_.FullName }
|
|
|
|
stl_in = sys.argv[-1]
|
|
|
|
if not stl_in.endswith('.stl'):
|
|
print('Input file is not an STL file')
|
|
sys.exit(1)
|
|
|
|
try:
|
|
with open(stl_in) as f:
|
|
pass
|
|
except FileNotFoundError:
|
|
print('Input file does not exist')
|
|
sys.exit(1)
|
|
|
|
obj_out = stl_in.replace('.stl', '.obj')
|
|
|
|
bpy.ops.wm.stl_import(filepath=stl_in)
|
|
bpy.ops.wm.obj_export(filepath=obj_out, export_materials=False, forward_axis='Y', up_axis='Z') |