I've several Python scripts (around 6000 scripts). Each of them generates 3D objects.
I want to find a way to export these generated objects to either fbx or obj files.
Is there a way to do it using Blender in command line?
Py file example:
import bpy
bpy.ops.mesh.primitive_plane_add(enter_editmode=False, location=(0, 0, 0))
bpy.ops.object.mode_set(mode = 'OBJECT')
obj = bpy.context.active_object
bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.select_mode(type="VERT")
bpy.ops.mesh.select_all(action = 'DESELECT')
bpy.ops.object.mode_set(mode = 'OBJECT')
obj.data.vertices[0].select = True
obj.data.vertices[1].select = True
obj.data.vertices[2].select = True
obj.data.vertices[3].select = True
bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.extrude_region_move(MESH_OT_extrude_region={"use_normal_flip":False, "mirror":False}, TRANSFORM_OT_translate={"value":(-0.220266, 0.10617, 0.490731), "orient_type":'GLOBAL', "orient_matrix":((5, 2, 3), (4, 1, 9), (6, 8, 7)), "orient_matrix_type":'GLOBAL', "constraint_axis":(False, False, False), "mirror":False, "use_proportional_edit":False, "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "use_proportional_connected":False, "use_proportional_projected":False, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, "cursor_transform":False, "texture_space":False, "remove_on_cancel":False, "release_confirm":False, "use_accurate":False})
bpy.ops.transform.rotate(value= 10, orient_axis='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), mirror=True, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False, release_confirm=True)
bpy.ops.object.modifier_add(type='SUBSURF')
bpy.context.object.modifiers["Subdivision"].levels = 8
When I launch the script (("<your path to blender>\blender.exe" --background --python exportFbx.py -- "<your py file name>" "<your output directory>" ))
I get this error on the command line:
C:\WINDOWS\system32>"C:\Program Files\Blender Foundation\Blender 2.81\blender.exe" --background --python exportFbx.py -- "<Essai.py>" "C:\Users\user\Desktop\Bank2Son Zone Originale II\Command line"
Blender 2.81 (sub 16) (hash 26bd5ebd42e3 built 2019-11-20 16:33:00)
Read prefs: C:\Users\user\AppData\Roaming\Blender Foundation\Blender\2.81\config\userpref.blend
AL lib: (EE) UpdateDeviceParams: Failed to set 48000hz, got 44100hz instead
found bundled python: C:\Program Files\Blender Foundation\Blender 2.81\2.81\python
Warning: 'BatEx_PT_Panel' doesn't have upper case alpha-numeric prefix
register_class(...):
Warning: 'BatEx_PT_Panel' doesn't have upper case alpha-numeric prefix
OSError: Python file "C:\WINDOWS\system32\exportFbx.py" could not be opened: No such file or directory Blender quit