1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
script_arm = """
controls = [%s]
tweaks = [%s]
ik_ctrl = [%s]
fk_ctrl = '%s'
parent = '%s'
# IK/FK Switch on all Control Bones
if is_selected( controls ):
layout.prop( pose_bones[ parent ], '["%s"]', slider = True )
props = layout.operator("pose.rigify_arm_fk2ik_" + rig_id, text="Snap FK->IK (" + fk_ctrl + ")")
props.uarm_fk = controls[1]
props.farm_fk = controls[2]
props.hand_fk = controls[3]
props.uarm_ik = controls[0]
props.farm_ik = ik_ctrl[1]
props.hand_ik = controls[4]
props = layout.operator("pose.rigify_arm_ik2fk_" + rig_id, text="Snap IK->FK (" + fk_ctrl + ")")
props.uarm_fk = controls[1]
props.farm_fk = controls[2]
props.hand_fk = controls[3]
props.uarm_ik = controls[0]
props.farm_ik = ik_ctrl[1]
props.hand_ik = controls[4]
#props.pole = ik_arm[3]
# BBone rubber hose on each Respective Tweak
for t in tweaks:
if is_selected( t ):
layout.prop( pose_bones[ t ], '["%s"]', slider = True )
# IK Stretch on IK Control bone
if is_selected( ik_ctrl ):
layout.prop( pose_bones[ parent ], '["%s"]', slider = True )
# FK limb follow
if is_selected( fk_ctrl ):
layout.prop( pose_bones[ parent ], '["%s"]', slider = True )
"""
script_leg = """
controls = [%s]
tweaks = [%s]
ik_ctrl = [%s]
fk_ctrl = '%s'
parent = '%s'
# IK/FK Switch on all Control Bones
if is_selected( controls ):
layout.prop( pose_bones[ parent ], '["%s"]', slider = True )
props = layout.operator("pose.rigify_leg_fk2ik_" + rig_id, text="Snap FK->IK (" + fk_ctrl + ")")
props.thigh_fk = controls[1]
props.shin_fk = controls[2]
props.foot_fk = controls[3]
props.mfoot_fk = controls[7]
props.thigh_ik = controls[0]
props.shin_ik = ik_ctrl[1]
props.foot_ik = ik_ctrl[2]
props.mfoot_ik = ik_ctrl[2]
props = layout.operator("pose.rigify_leg_ik2fk_" + rig_id, text="Snap IK->FK (" + fk_ctrl + ")")
props.thigh_fk = controls[1]
props.shin_fk = controls[2]
props.foot_fk = controls[3]
props.mfoot_fk = controls[7]
props.thigh_ik = controls[0]
props.shin_ik = ik_ctrl[1]
props.foot_ik = controls[6]
#props.pole = ik_leg[3]
props.footroll = controls[5]
props.mfoot_ik = ik_ctrl[2]
# BBone rubber hose on each Respective Tweak
for t in tweaks:
if is_selected( t ):
layout.prop( pose_bones[ t ], '["%s"]', slider = True )
# IK Stretch on IK Control bone
if is_selected( ik_ctrl ):
layout.prop( pose_bones[ parent ], '["%s"]', slider = True )
# FK limb follow
if is_selected( fk_ctrl ):
layout.prop( pose_bones[ parent ], '["%s"]', slider = True )
"""
def create_script( bones, limb_type=None):
# All ctrls have IK/FK switch
controls = [ bones['ik']['ctrl']['limb'] ] + bones['fk']['ctrl']
controls += bones['ik']['ctrl']['terminal']
controls += [ bones['fk']['mch'] ]
controls_string = ", ".join(["'" + x + "'" for x in controls])
# All tweaks have their own bbone prop
tweaks = bones['tweak']['ctrl'][1:-1]
tweaks_string = ", ".join(["'" + x + "'" for x in tweaks])
# IK ctrl has IK stretch
ik_ctrl = [ bones['ik']['ctrl']['terminal'][-1] ]
ik_ctrl += [ bones['ik']['mch_ik'] ]
ik_ctrl += [ bones['ik']['mch_target'] ]
ik_ctrl_string = ", ".join(["'" + x + "'" for x in ik_ctrl])
if limb_type == 'arm':
return script_arm % (
controls_string,
tweaks_string,
ik_ctrl_string,
bones['fk']['ctrl'][0],
bones['parent'],
'IK/FK',
'rubber_tweak',
'IK_Strertch',
'FK_limb_follow'
)
elif limb_type == 'leg':
return script_leg % (
controls_string,
tweaks_string,
ik_ctrl_string,
bones['fk']['ctrl'][0],
bones['parent'],
'IK/FK',
'rubber_tweak',
'IK_Strertch',
'FK_limb_follow'
)
elif limb_type == 'paw':
return script_leg % (
controls_string,
tweaks_string,
ik_ctrl_string,
bones['fk']['ctrl'][0],
bones['parent'],
'IK/FK',
'rubber_tweak',
'IK_Strertch',
'FK_limb_follow'
)
|