1
$\begingroup$

Using the blender API, I am trying to "Make Proxy" on a linked rig.

My first approach was to identify the linked objects through bpy.data.groups.objects and then use the bpy.ops.object.proxy_make() operator to make proxies.

However, this would make proxies for all linked objects (rigs, meshes etc.), when my objective is to do it only to the rigs.

Is there a way to identify the right objects to proxy? Alternatively, is there a better method to do the whole exercise?

$\endgroup$

1 Answer 1

2
$\begingroup$

The make proxy operator works only on the active object (it has to be visible). You set the active object like this:

import bpy
objects = bpy.context.scene.objects
objects.active = objects["Name"]

If you don't know the name you can list all objects in the scene with dupli group:

ob_list = [ob for ob in objects if ob.dupli_group]

You can specify what object inside the group to make the proxy of like this:

bpy.ops.object.proxy_make(object="Name_Of_Object_Inside_Linked_Group")

If you don't know the name, you can list all the armatures inside the active object's dupli group:

armatures = [ob for ob in objects.active.dupli_group.objects if ob.type == 'ARMATURE']

The proxy object then becomes the active object. You can rename the proxy easily (otherwise it will carry the name of the linked group object):

objects.active.name = "Name_Of_Object_Inside_Linked_Group_PROXY"

To complete this you also get the linked group object from a proxy object like this (if you need to know what the proxy is influencing and if the object is a proxy at all):

group_ob = proxy_ob.proxy_group
$\endgroup$
3
  • $\begingroup$ Thanks for the comprehensive answer. Learned some new things. Very helpful $\endgroup$
    – RSS
    Commented Feb 8, 2017 at 18:33
  • $\begingroup$ when executing bpy.ops.object.proxy_make(object="Name_Of_Object_Inside_Linked_Group") from script I got the famous bpy.ops.object.proxy_make.poll() failed, context is incorrect. I tried some context override but I failed. is there a way to make the override working or can we make proxy without ops at all ? $\endgroup$
    – Pullup
    Commented Jul 19, 2017 at 10:10
  • $\begingroup$ @Pullup search the operator in source code like this: blender.stackexchange.com/questions/6880/… and find it's poll() method. See what members of bpy.context it checks. Override all the context members like so: docs.blender.org/api/blender_python_api_current/…. If there is still problem you will have to ask that as a question and show the code for debugging as it won't be probably trivial. $\endgroup$ Commented Jul 19, 2017 at 15:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .