mirror of
https://github.com/Cian-H/simple_blender_server.git
synced 2026-05-08 08:41:43 +01:00
Fixed python template for 5.0
This commit is contained in:
+8
-6
@@ -26,21 +26,23 @@ def export_to_glb(obj: bpy.types.Object):
|
||||
Parameters:
|
||||
obj (bpy.types.Object): The object to export
|
||||
"""
|
||||
# Ensure the object is the only object, is selected, and is active
|
||||
bpy.ops.object.select_all(action="SELECT")
|
||||
obj.select_set(False)
|
||||
bpy.ops.object.delete()
|
||||
# Ensure the scene is in Object Mode before altering selection
|
||||
if bpy.context.mode != 'OBJECT':
|
||||
bpy.ops.object.mode_set(mode='OBJECT')
|
||||
|
||||
# Deselect all objects, select only the target object, and make it active
|
||||
bpy.ops.object.select_all(action="DESELECT")
|
||||
obj.select_set(True)
|
||||
bpy.context.view_layer.objects.active = obj
|
||||
|
||||
# Export using use_selection=True to avoid deleting the rest of the scene
|
||||
bpy.ops.export_scene.gltf(
|
||||
filepath="{{.Filename}}",
|
||||
export_format="GLB",
|
||||
# export_draco_mesh_compression_enable=True,
|
||||
use_selection=True,
|
||||
export_apply=True,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
export_to_glb(guarded_model())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user