0

When I try to use bpy.ops.wm.append, the object appears "selected" with the red outline, but how do I switch it to "Active" with yellow outline?

bpy.ops.wm.append(
    filepath="Prefab_Objects.blend",
    directory="/Users/Yuri/Desktop/Blender_Python_Test/Prefab_Objects.blend\\Object\\",
    filename="tower")

(I need to apply bpy.context.active_object.name afterward, but can’t because the object is not "active")

Yuri_Re
  • 3
  • 1

1 Answers1

0

You can set the active object with this command:

If len(bpy.context.selected_objects):
    bpy.context.view_layer.objects.active = bpy.context.selected_objects[0]

The active object is now reachable by:

active_obj = bpy.context.active_object
Werwack
  • 161
  • 5