I have a bone with various custom properties and I want to change the value of all of them, from 0 to 1 at the same time (pressing a button).
Asked
Active
Viewed 334 times
1 Answers
1
Have a look at the operator simple template in the text editor. Replace main(context) with this
def main(context):
#active pose bone
pb = context.active_pose_bone
# all custom properties on bone
for key in pb.keys():
#ignore _RNA_UI
if key == '_RNA_UI':
continue
pb[key] = 1
# insert a keyframe
pb.keyframe_insert('["%s"]' % key)
and the poll method to
def poll(cls, context):
return context.active_pose_bone is not None
to make sure that there is an active pose bone selected.
and change the idname from object.simple_operator to something meaningful like posebone.set
Then have a look at the panel simple template and
row.operator("posebone.set")
will give you a UI button.
batFINGER
- 84,216
- 10
- 108
- 233
pb.keyframe_insert('["%s"]' % key)to code. Will add a keyframe for each custom property at the frame of button press. – batFINGER Jun 08 '16 at 05:17