I'm making an add-on to boost my workflow. I want to add custom shapes to the bones of the armature selected in the PointerProperty from the panel. But according to my knowledge, I can only add custom shapes in the posebones of the armature which can be accessed by bpy.context.object.pose.bones but taking an armature like this I've already accessed bpy.context.object.data. Any help would be greatly appreciated.
Here is the code:
import bpy
class CUSTOM_PT_PANEL(bpy.types.Panel):
bl_label = "Custom"
bl_idname = "CUSTOM_PT_PANEL"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "Custom"
def draw (self, context):
layout = self.layout
layout.prop(context.scene, 'select_rig')
layout.operator('add.custom_shape')
class CUSTOM_OT_OPERATOR(bpy.types.Operator):
bl_label = "Add custom shae"
bl_idname = "add.custom_shape"
def execute(self,context):
armature = bpy.context.scene.select_rig
#Custom Shape
bpy.ops.mesh.primitive_cube_add()
shape = bpy.context.active_object
bpy.ops.object.mode_set(mode='EDIT')
shape.scale.y = 0.4
shape.scale.z = 0.4
bpy.ops.mesh.delete(type='ONLY_FACE')
bpy.ops.object.mode_set(mode='OBJECT')
return {'FINISHED'}
classes = [CUSTOM_PT_PANEL, CUSTOM_OT_OPERATOR]
def register():
for cls in classes:
bpy.utils.register_class(cls)
bpy.types.Scene.select_rig = bpy.props.PointerProperty(name='Select Rig',type=bpy.types.Armature)
def unregister():
for cls in classes:
bpy.utils.unregister_class(cls)
if name == "main":
register()
```


