3
$\begingroup$

so imagine you have two objects but they are linked so it is one mesh data block

The following command should make the cubes single users so that the mesh data blocks are not shared but it doesnt do it.

row.operator("object.make_single_user")

So I am curious how one has to add the value for the object + data:

bpy.ops.object.make_single_user(type='SELECTED_OBJECTS', 
                                object=True, 
                                obdata=True, 
                                material=False, 
                                texture=False, 
                                animation=False)

or how one could call this menu:

enter image description here

$\endgroup$
6
$\begingroup$

The default options for bpy.ops.object.make_single_user() are all false so you need to specify at least one True option when you call the operator. When calling an operator directly you can just include the optional values in the call -

bpy.ops.object.make_single_user(type='SELECTED_OBJECTS', object=True, obdata=True)

When using layout.operator() in a panel or menu, you can't pass options this way but there are two methods you can use. When you only have one option to set you can add the property to the operator line -

layout.operator("object.make_single_user", text="Object").object = True

When you need to define multiple options you need to keep the operator item that is created and then adjust it's properties. As shown from the make single user menu -

props = layout.operator("object.make_single_user", text="Object")
props.object = True
props.obdata = props.material = props.texture = props.animation = False

props = layout.operator("object.make_single_user", text="Object & Data")
props.object = props.obdata = True
props.material = props.texture = props.animation = False
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.