@@ -19,9 +19,14 @@ def __init__(self, rig):
19
19
else :
20
20
self .rig .secondary_layers = None
21
21
22
+ if self .rig .params .tweak_layers_extra :
23
+ self .rig .tweak_layers = list (self .rig .params .tweak_layers )
24
+ else :
25
+ self .rig .tweak_layers = None
26
+
22
27
def assign_layer (self , primary_ctrls , all_ctrls ):
23
28
"""
24
- Assign bones to layer
29
+ Assign ctrl bones to layer
25
30
:param primary_ctrls:
26
31
:type primary_ctrls: list(str)
27
32
:param all_ctrls:
@@ -39,17 +44,33 @@ def assign_layer(self, primary_ctrls, all_ctrls):
39
44
if self .rig .secondary_layers and bone not in primary_ctrls :
40
45
edit_bones [bone ].layers = self .rig .params .secondary_layers
41
46
47
+ def assign_tweak_layers (self , tweaks ):
48
+ """
49
+ Assign tweak bones to layer
50
+ :param tweaks:
51
+ :type tweaks: list(str)
52
+ :return:
53
+ """
54
+
55
+ bpy .ops .object .mode_set (mode = 'EDIT' )
56
+ edit_bones = self .obj .data .edit_bones
57
+
58
+ for bone in tweaks :
59
+ if self .rig .tweak_layers :
60
+ edit_bones [bone ].layers = self .rig .params .tweak_layers
61
+
62
+
42
63
@staticmethod
43
64
def add_layer_parameters (params ):
44
- # Setting up extra layers for the tweak bones
65
+ # Setting up extra layers for the primary & secondary controls
45
66
params .primary_layers_extra = bpy .props .BoolProperty (
46
67
name = "primary_layers_extra" ,
47
68
default = True ,
48
69
description = ""
49
70
)
50
71
params .primary_layers = bpy .props .BoolVectorProperty (
51
72
size = 32 ,
52
- description = "Layers for the 1st tweak controls to be on" ,
73
+ description = "Layers for the primary controls to be on" ,
53
74
default = tuple ([i == 1 for i in range (0 , 32 )])
54
75
)
55
76
params .secondary_layers_extra = bpy .props .BoolProperty (
@@ -59,7 +80,20 @@ def add_layer_parameters(params):
59
80
)
60
81
params .secondary_layers = bpy .props .BoolVectorProperty (
61
82
size = 32 ,
62
- description = "Layers for the 2nd tweak controls to be on" ,
83
+ description = "Layers for the secondary controls to be on" ,
84
+ default = tuple ([i == 1 for i in range (0 , 32 )])
85
+ )
86
+
87
+ @staticmethod
88
+ def add_tweak_layer_parameters (params ):
89
+ params .tweak_layers_extra = bpy .props .BoolProperty (
90
+ name = "tweak_layers_extra" ,
91
+ default = True ,
92
+ description = ""
93
+ )
94
+ params .tweak_layers = bpy .props .BoolVectorProperty (
95
+ size = 32 ,
96
+ description = "Layers for the tweak controls to be on" ,
63
97
default = tuple ([i == 1 for i in range (0 , 32 )])
64
98
)
65
99
@@ -104,3 +138,44 @@ def add_layers_ui(layout, params):
104
138
if bone_layers [i ]:
105
139
icon = "LAYER_ACTIVE"
106
140
row .prop (params , layer , index = i , toggle = True , text = "" , icon = icon )
141
+
142
+ @staticmethod
143
+ def add_tweak_layers_ui (layout , params ):
144
+
145
+ layer = "tweak_layers"
146
+ bone_layers = bpy .context .active_pose_bone .bone .layers [:]
147
+
148
+ r = layout .row ()
149
+ r .prop (params , layer + "_extra" )
150
+ r .active = getattr (params , layer + "_extra" )
151
+
152
+ col = r .column (align = True )
153
+ row = col .row (align = True )
154
+ for i in range (8 ):
155
+ icon = "NONE"
156
+ if bone_layers [i ]:
157
+ icon = "LAYER_ACTIVE"
158
+ row .prop (params , layer , index = i , toggle = True , text = "" , icon = icon )
159
+
160
+ row = col .row (align = True )
161
+ for i in range (16 , 24 ):
162
+ icon = "NONE"
163
+ if bone_layers [i ]:
164
+ icon = "LAYER_ACTIVE"
165
+ row .prop (params , layer , index = i , toggle = True , text = "" , icon = icon )
166
+
167
+ col = r .column (align = True )
168
+ row = col .row (align = True )
169
+
170
+ for i in range (8 , 16 ):
171
+ icon = "NONE"
172
+ if bone_layers [i ]:
173
+ icon = "LAYER_ACTIVE"
174
+ row .prop (params , layer , index = i , toggle = True , text = "" , icon = icon )
175
+
176
+ row = col .row (align = True )
177
+ for i in range (24 , 32 ):
178
+ icon = "NONE"
179
+ if bone_layers [i ]:
180
+ icon = "LAYER_ACTIVE"
181
+ row .prop (params , layer , index = i , toggle = True , text = "" , icon = icon )
0 commit comments