bone space in context menu

This commit is contained in:
ChristopheSeux
2024-02-28 09:59:11 +01:00
parent 150bae5920
commit 75bc414e26
6 changed files with 27 additions and 13 deletions
+21 -9
View File
@@ -392,24 +392,19 @@ class RP_OT_reload_picker(Operator):
# return
def execute(self, context):
#PICKERS.clear()
if context.object.type == 'ARMATURE':
rig = context.object
else:
collection = get_picker_collection(context.object)
rig = collection.rig_picker.rig
#print('Reload', rig)
load_picker_data(rig)
'''
for area in context.screen.areas:
#print(area.type, is_picker_space(area.spaces.active))
if is_picker_space(area.spaces.active):
print('Tag Redraw Region', area.type)
area.regions[0].tag_redraw()
area.tag_redraw()
'''
return {"FINISHED"}
@@ -551,7 +546,8 @@ class RP_MT_context_menu(Menu):
def draw(self, context):
layout = self.layout
col = layout.column()
col.use_property_split = True
col.operator_context = 'INVOKE_DEFAULT'
#col.use_property_split = True
ob = context.object
picker = PICKERS.get(ob)
@@ -561,9 +557,25 @@ class RP_MT_context_menu(Menu):
else:
bone = context.active_pose_bone
# Draw Space Switch Operator
if getattr(ob.data, 'space_switch'):
space_switch = ob.data.space_switch
data_paths = [f'pose.bones["{bone.name}"]["{k}"]' for k in bone.keys()]
space_bone = next((s for s in space_switch.bones if s.data_path in data_paths), None)
if space_bone:
index = list(space_switch.bones).index(space_bone)
value = ob.path_resolve(space_bone.data_path)
space = next((s.name for s in space_bone.spaces if s.value == value), None)
op = col.operator("spaceswitch.change_space", text=f'({space})', icon='PINNED')
op.index=index
col.separator()
if bone:
for key in bone.keys():
layout.prop(bone,f'["{key}"]', slider=True)
col.prop(bone,f'["{key}"]', slider=True)
#layout.operator("rigpicker.show_bone_layer", text="Show Bone Layer", ).type = 'ACTIVE'
#layout.operator("rigidbody.objects_add", text="B Add Passive").type = 'PASSIVE'
-1
View File
@@ -222,7 +222,6 @@ class RP_OT_save_picker(Operator):
bpy.ops.rigpicker.reload_picker()
return {'FINISHED'}
classes = (