0
$\begingroup$

I am using blender 2.81.

If I change into "Default" view and then manipulate objects then the Info pane shows the Python commands associated with those manipulations. This is very helpful.

But when I select objects it does not show the equivalent operations. Specifically I am trying to associate the bones with the mesh and parent them with automatic weights.

It is quite frustrating as I am trying to write a script to automate the export of a rig.

$\endgroup$
  • 1
    $\begingroup$ Please rephrase this as a question. It is not clear what you're asking here. $\endgroup$ – Moog Dec 9 '19 at 11:43
  • 1
    $\begingroup$ Hi! Do you look for mouse select log output? It seems this is missing in blender. $\endgroup$ – RUben Dec 9 '19 at 12:05
  • $\begingroup$ @RUben yes this is what i am looking for. normally my procedure is to select bones in pose mode, then switch to object mode and multiselect mesh and bones at same time. there is no output to show what has happened so i have no idea how to write script $\endgroup$ – MitchBroadhead Dec 9 '19 at 12:20
0
$\begingroup$

To set active object as parent armature deform with Automatic Weights for selected objects, you need to:

  1. select objects include active:

    object.select_set(True)
    
  2. set active object:

    view_layer.objects.active = object
    
  3. call operator:

    bpy.ops.object.parent_set(type='ARMATURE_AUTO')
    

Code example from scene:

import bpy

objects = [
    'Armature',
    'Cylinder',
    'Cylinder.001',
    'Cylinder.002'
    ]

context = bpy.context
view_layer = context.view_layer
scene = context.scene

# select objects include active
for ob in objects:
    scene.objects[ob].select_set(True)

# set active object
view_layer.objects.active = scene.objects[objects[0]]

# call operator
bpy.ops.object.parent_set(type='ARMATURE_AUTO')
$\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.