In my python addon, I'm able to get the user's selected posebone and for reasons I need the armature it belongs to. How would I achieve this?
1 Answer
Python console.
Bit of "educated guesswork" going on very little from question. I'll try and cover all bases here
Using python console, C = bpy.context
The armature object has context, in pose mode
>>> C.object
bpy.data.objects['Armature']
>>> C.mode
'POSE'
The active pose bone
>>> pb = C.active_pose_bone
>>> pb
bpy.data.objects['Armature'].pose.bones["Bone"]
The pose bone belongs to the armature object which has context. Alternatively the id_data
pointer tells us which ID object to which an object belongs.
>>> pb.id_data
bpy.data.objects['Armature']
The armature associated with this object.
>>> pb.id_data.data
bpy.data.armatures['Armature']
It would be really handy if in future you posted some pertinent code.
-
1$\begingroup$ so ? how do you get the bone armature ? do you have parse all armatures ? $\endgroup$– PhilCommented May 10, 2022 at 11:08