Fix: wrong active object after creation/before deletion
This commit is contained in:
parent
db03c570ad
commit
430821326d
8
addon.py
8
addon.py
@ -293,7 +293,8 @@ class BlenderMCPServer:
|
|||||||
raise ValueError(f"Unsupported object type: {type}")
|
raise ValueError(f"Unsupported object type: {type}")
|
||||||
|
|
||||||
# Get the created object
|
# Get the created object
|
||||||
obj = bpy.context.active_object
|
bpy.context.view_layer.update()
|
||||||
|
obj = bpy.context.view_layer.objects.active
|
||||||
|
|
||||||
# Rename the object if a name is provided
|
# Rename the object if a name is provided
|
||||||
if name:
|
if name:
|
||||||
@ -359,9 +360,8 @@ class BlenderMCPServer:
|
|||||||
obj_name = obj.name
|
obj_name = obj.name
|
||||||
|
|
||||||
# Select and delete the object
|
# Select and delete the object
|
||||||
bpy.ops.object.select_all(action='DESELECT')
|
if obj:
|
||||||
obj.select_set(True)
|
bpy.data.objects.remove(obj, do_unlink=True)
|
||||||
bpy.ops.object.delete()
|
|
||||||
|
|
||||||
return {"deleted": obj_name}
|
return {"deleted": obj_name}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user