Skip to content

Commit 665ed2a

Browse files
committed
Switch existing rigs to using the new utility function for layer selection.
1 parent d72edd7 commit 665ed2a

File tree

5 files changed

+14
-199
lines changed

5 files changed

+14
-199
lines changed

rigs/limbs/arm.py

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from ...utils import MetarigError, make_mechanism_name, org
1010
from ...utils import create_limb_widget, connected_children_names
1111
from ...utils import align_bone_y_axis, align_bone_x_axis, align_bone_z_axis
12+
from ...utils import layout_layer_selection_ui
1213
from rna_prop_ui import rna_idprop_ui_prop_get
1314
from ..widgets import create_ikarrow_widget
1415
from math import trunc, pi
@@ -1151,46 +1152,8 @@ def parameters_ui(layout, params):
11511152
r = layout.row()
11521153
r.prop(params, "bbones")
11531154

1154-
bone_layers = bpy.context.active_pose_bone.bone.layers[:]
1155-
1156-
for layer in ['fk', 'tweak']:
1157-
r = layout.row()
1158-
r.prop(params, layer + "_extra_layers")
1159-
r.active = params.tweak_extra_layers
1160-
1161-
col = r.column(align=True)
1162-
row = col.row(align=True)
1163-
1164-
for i in range(8):
1165-
icon = "NONE"
1166-
if bone_layers[i]:
1167-
icon = "LAYER_ACTIVE"
1168-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1169-
1170-
row = col.row(align=True)
1171-
1172-
for i in range(16, 24):
1173-
icon = "NONE"
1174-
if bone_layers[i]:
1175-
icon = "LAYER_ACTIVE"
1176-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1177-
1178-
col = r.column(align=True)
1179-
row = col.row(align=True)
1180-
1181-
for i in range(8, 16):
1182-
icon = "NONE"
1183-
if bone_layers[i]:
1184-
icon = "LAYER_ACTIVE"
1185-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1186-
1187-
row = col.row(align=True)
1188-
1189-
for i in range(24, 32):
1190-
icon = "NONE"
1191-
if bone_layers[i]:
1192-
icon = "LAYER_ACTIVE"
1193-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1155+
layout_layer_selection_ui(layout, params, "fk_extra_layers", "fk_layers")
1156+
layout_layer_selection_ui(layout, params, "tweak_extra_layers", "tweak_layers")
11941157

11951158

11961159
def create_sample(obj):

rigs/limbs/leg.py

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from ...utils import MetarigError, make_mechanism_name, org
1111
from ...utils import create_limb_widget, connected_children_names
1212
from ...utils import align_bone_y_axis, align_bone_x_axis, align_bone_z_axis
13+
from ...utils import layout_layer_selection_ui
1314
from rna_prop_ui import rna_idprop_ui_prop_get
1415
from ..widgets import create_ikarrow_widget
1516
from math import trunc, pi
@@ -1474,46 +1475,8 @@ def parameters_ui(layout, params):
14741475
r = layout.row()
14751476
r.prop(params, "bbones")
14761477

1477-
bone_layers = bpy.context.active_pose_bone.bone.layers[:]
1478-
1479-
for layer in ['fk', 'tweak']:
1480-
r = layout.row()
1481-
r.prop(params, layer + "_extra_layers")
1482-
r.active = params.tweak_extra_layers
1483-
1484-
col = r.column(align=True)
1485-
row = col.row(align=True)
1486-
1487-
for i in range(8):
1488-
icon = "NONE"
1489-
if bone_layers[i]:
1490-
icon = "LAYER_ACTIVE"
1491-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1492-
1493-
row = col.row(align=True)
1494-
1495-
for i in range(16, 24):
1496-
icon = "NONE"
1497-
if bone_layers[i]:
1498-
icon = "LAYER_ACTIVE"
1499-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1500-
1501-
col = r.column(align=True)
1502-
row = col.row(align=True)
1503-
1504-
for i in range(8, 16):
1505-
icon = "NONE"
1506-
if bone_layers[i]:
1507-
icon = "LAYER_ACTIVE"
1508-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1509-
1510-
row = col.row(align=True)
1511-
1512-
for i in range(24, 32):
1513-
icon = "NONE"
1514-
if bone_layers[i]:
1515-
icon = "LAYER_ACTIVE"
1516-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1478+
layout_layer_selection_ui(layout, params, "fk_extra_layers", "fk_layers")
1479+
layout_layer_selection_ui(layout, params, "tweak_extra_layers", "tweak_layers")
15171480

15181481

15191482
def create_sample(obj):

rigs/limbs/paw.py

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from ...utils import MetarigError, make_mechanism_name, org
99
from ...utils import create_limb_widget, connected_children_names
1010
from ...utils import align_bone_y_axis, align_bone_x_axis, align_bone_z_axis
11+
from ...utils import layout_layer_selection_ui
1112
from rna_prop_ui import rna_idprop_ui_prop_get
1213
from ..widgets import create_ikarrow_widget, create_gear_widget
1314
from ..widgets import create_foot_widget, create_ballsocket_widget
@@ -1302,46 +1303,8 @@ def parameters_ui(layout, params):
13021303
r = layout.row()
13031304
r.prop(params, "bbones")
13041305

1305-
bone_layers = bpy.context.active_pose_bone.bone.layers[:]
1306-
1307-
for layer in ['fk', 'tweak']:
1308-
r = layout.row()
1309-
r.prop(params, layer + "_extra_layers")
1310-
r.active = params.tweak_extra_layers
1311-
1312-
col = r.column(align=True)
1313-
row = col.row(align=True)
1314-
1315-
for i in range(8):
1316-
icon = "NONE"
1317-
if bone_layers[i]:
1318-
icon = "LAYER_ACTIVE"
1319-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1320-
1321-
row = col.row(align=True)
1322-
1323-
for i in range(16, 24):
1324-
icon = "NONE"
1325-
if bone_layers[i]:
1326-
icon = "LAYER_ACTIVE"
1327-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1328-
1329-
col = r.column(align=True)
1330-
row = col.row(align=True)
1331-
1332-
for i in range(8, 16):
1333-
icon = "NONE"
1334-
if bone_layers[i]:
1335-
icon = "LAYER_ACTIVE"
1336-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1337-
1338-
row = col.row(align=True)
1339-
1340-
for i in range(24, 32):
1341-
icon = "NONE"
1342-
if bone_layers[i]:
1343-
icon = "LAYER_ACTIVE"
1344-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1306+
layout_layer_selection_ui(layout, params, "fk_extra_layers", "fk_layers")
1307+
layout_layer_selection_ui(layout, params, "tweak_extra_layers", "tweak_layers")
13451308

13461309

13471310
def create_sample(obj):

rigs/limbs/simple_tentacle.py

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from ...utils import put_bone, create_sphere_widget
55
from ...utils import create_circle_widget, align_bone_x_axis
66
from ...utils import MetarigError
7+
from ...utils import layout_layer_selection_ui
78

89

910
class Rig:
@@ -277,45 +278,7 @@ def parameters_ui(layout, params):
277278
for i, axis in enumerate(['x', 'y', 'z']):
278279
row.prop(params, "copy_rotation_axes", index=i, toggle=True, text=axis)
279280

280-
r = layout.row()
281-
r.prop(params, "tweak_extra_layers")
282-
r.active = params.tweak_extra_layers
283-
284-
col = r.column(align=True)
285-
row = col.row(align=True)
286-
287-
bone_layers = bpy.context.active_pose_bone.bone.layers[:]
288-
289-
for i in range(8): # Layers 0-7
290-
icon = "NONE"
291-
if bone_layers[i]:
292-
icon = "LAYER_ACTIVE"
293-
row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon)
294-
295-
row = col.row(align=True)
296-
297-
for i in range(16, 24): # Layers 16-23
298-
icon = "NONE"
299-
if bone_layers[i]:
300-
icon = "LAYER_ACTIVE"
301-
row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon)
302-
303-
col = r.column(align=True)
304-
row = col.row(align=True)
305-
306-
for i in range(8, 16): # Layers 8-15
307-
icon = "NONE"
308-
if bone_layers[i]:
309-
icon = "LAYER_ACTIVE"
310-
row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon)
311-
312-
row = col.row(align=True)
313-
314-
for i in range(24, 32): # Layers 24-31
315-
icon = "NONE"
316-
if bone_layers[i]:
317-
icon = "LAYER_ACTIVE"
318-
row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon)
281+
layout_layer_selection_ui(layout, params, "tweak_extra_layers", "tweak_layers")
319282

320283

321284
def create_sample(obj):

rigs/limbs/super_limb.py

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from .leg import Rig as legRig
55
from .paw import Rig as pawRig
66

7+
from ...utils import layout_layer_selection_ui
78

89
class Rig:
910

@@ -130,46 +131,8 @@ def parameters_ui(layout, params):
130131
r = layout.row()
131132
r.prop(params, "bbones")
132133

133-
bone_layers = bpy.context.active_pose_bone.bone.layers[:]
134-
135-
for layer in ['fk', 'tweak']:
136-
r = layout.row()
137-
r.prop(params, layer + "_extra_layers")
138-
r.active = params.tweak_extra_layers
139-
140-
col = r.column(align=True)
141-
row = col.row(align=True)
142-
143-
for i in range(8):
144-
icon = "NONE"
145-
if bone_layers[i]:
146-
icon = "LAYER_ACTIVE"
147-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
148-
149-
row = col.row(align=True)
150-
151-
for i in range(16,24):
152-
icon = "NONE"
153-
if bone_layers[i]:
154-
icon = "LAYER_ACTIVE"
155-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
156-
157-
col = r.column(align=True)
158-
row = col.row(align=True)
159-
160-
for i in range(8,16):
161-
icon = "NONE"
162-
if bone_layers[i]:
163-
icon = "LAYER_ACTIVE"
164-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
165-
166-
row = col.row(align=True)
167-
168-
for i in range(24,32):
169-
icon = "NONE"
170-
if bone_layers[i]:
171-
icon = "LAYER_ACTIVE"
172-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
134+
layout_layer_selection_ui(layout, params, "fk_extra_layers", "fk_layers")
135+
layout_layer_selection_ui(layout, params, "tweak_extra_layers", "tweak_layers")
173136

174137

175138
def create_sample(obj):

0 commit comments

Comments
 (0)