1

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)

dparnas
  • 113
  • 4
  • 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 – Shantanu Aryan Sep 29 '21 at 21:16
  • 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 ? – dparnas Oct 03 '21 at 08:48

1 Answers1

1

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

Shantanu Aryan
  • 1,014
  • 7
  • 14