1
$\begingroup$

In a blender add-on, I import a mesh and join it with an armature using automatic weight. I use bpy.ops.object.parent_set(type='ARMATURE_AUTO', keep_transform=True) for this.

However, I then need to add an additional mesh to the the main object and recalculate the weights for only a single bone (this to avoid weight painting for other bones influencing the additional mesh on poses)

In the post How to recalculate automatic weights for single bones?, it is described how to do this manually.

However, I'm unable to identify method to trigger this from python code.

Is there a suitable method for this in the blender API ? Or is there some way of triggering a select of a UI menu element from python code (for example some general function within the https://docs.blender.org/api/current/bpy.ops.html namespace)

$\endgroup$
2
  • $\begingroup$ You can use the info panel in blender to quickly find the python commands. If you cannot find the info panel, it is on the bottom left on scripting tab. It logs out every action you perform. Do it manually and find whats logged there. I got bpy.ops.paint.weight_from_bones(type='AUTOMATIC'). hope this helps $\endgroup$ Sep 29, 2021 at 21:16
  • $\begingroup$ Awesome, just what I needed. Thank you ! Would you mind adding this as an answer so that I can mark it as the correct one ? $\endgroup$
    – dparnas
    Oct 3, 2021 at 8:48

1 Answer 1

1
$\begingroup$

You can use the info panel in blender to quickly find the python commands. If you cannot find the info panel, it is on the bottom left on scripting tab. It logs out every action you perform.

Do it manually and find whats logged there. I got bpy.ops.paint.weight_from_bones(type='AUTOMATIC').

automatic weight for single bone

Hope this helps

$\endgroup$

You must log in to answer this question.

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