37
37
importlib .reload (utils )
38
38
importlib .reload (metarig_menu )
39
39
importlib .reload (rig_lists )
40
+ importlib .reload (template_list )
41
+ importlib .reload (feature_sets )
40
42
else :
41
- from . import utils , rig_lists , generate , ui , metarig_menu
43
+ from . import (utils , rig_lists , template_list ,
44
+ generate , ui , metarig_menu , feature_sets )
42
45
43
46
import bpy
44
47
import sys
45
48
import os
46
49
from bpy .types import AddonPreferences
47
50
from bpy .props import BoolProperty
48
- from bpy .props import StringProperty
49
51
50
52
51
53
class RigifyPreferences (AddonPreferences ):
@@ -119,29 +121,28 @@ def update_legacy(self, context):
119
121
120
122
register ()
121
123
122
- def update_external_rigs (self , context ):
123
-
124
+ def update_external_rigs (self ):
125
+ """Get external feature sets"""
124
126
if self .legacy_mode :
125
127
return
126
128
127
- custom_rigs_folder = bpy . context . user_preferences . addons [ 'rigify' ]. preferences . custom_rigs_folder
129
+ feature_sets_path = os . path . join ( bpy . utils . script_path_user (), 'rigify' )
128
130
129
- if custom_rigs_folder == "" and 'external' in rig_lists .rigs_dict :
130
- rig_lists .rigs_dict .pop ('external' )
131
- return
131
+ invalid_path = not os .path .exists (feature_sets_path )
132
+ if not invalid_path :
133
+ if feature_sets_path not in sys .path :
134
+ sys .path .append (feature_sets_path )
135
+ # Reload rigs
136
+ print ('Reloading external rigs...' )
137
+ rig_lists .get_external_rigs (feature_sets_path )
132
138
133
- if custom_rigs_folder not in sys .path :
134
- sys .path .append (bpy .context .user_preferences .addons ['rigify' ].preferences .custom_rigs_folder )
139
+ # Reload metarigs
140
+ print ('Reloading external metarigs...' )
141
+ metarig_menu .get_external_metarigs (feature_sets_path )
135
142
136
- rig_lists .get_external_rigs ()
137
- if 'external' in rig_lists .rigs_dict and rig_lists .rigs_dict ['external' ]:
138
- # Add external rig parameters
139
- for rig in rig_lists .rigs_dict ['external' ]['rig_list' ]:
140
- r = utils .get_rig_type (rig , custom_rigs_folder )
141
- try :
142
- r .add_parameters (RigifyParameterValidator (RigifyParameters , rig , RIGIFY_PARAMETER_TABLE ))
143
- except AttributeError :
144
- pass
143
+ # Reload templates
144
+ print ('Reloading external templates...' )
145
+ template_list .get_external_templates (feature_sets_path )
145
146
146
147
legacy_mode = BoolProperty (
147
148
name = 'Rigify Legacy Mode' ,
@@ -150,14 +151,6 @@ def update_external_rigs(self, context):
150
151
update = update_legacy
151
152
)
152
153
153
- custom_rigs_folder = StringProperty (
154
- name = 'Rigify Custom Rigs' ,
155
- description = 'Folder Containing User Defined Rig Types' ,
156
- default = '' ,
157
- subtype = 'DIR_PATH' ,
158
- update = update_external_rigs
159
- )
160
-
161
154
show_expanded = BoolProperty ()
162
155
163
156
show_rigs_folder_expanded = BoolProperty ()
@@ -186,7 +179,7 @@ def draw(self, context):
186
179
if expand :
187
180
split = col .row ().split (percentage = 0.15 )
188
181
split .label ('Description:' )
189
- split .label (text = 'This is the folder containing user defined Rig Types ' )
182
+ split .label (text = 'When enabled the add-on will run in legacy mode using the old 2.76b feature set. ' )
190
183
191
184
box = column .box ()
192
185
rigs_expand = getattr (self , 'show_rigs_folder_expanded' )
@@ -199,12 +192,21 @@ def draw(self, context):
199
192
op = sub .operator ('wm.context_toggle' , text = '' , icon = icon ,
200
193
emboss = False )
201
194
op .data_path = 'addon_prefs.show_rigs_folder_expanded'
202
- row .prop (self , 'custom_rigs_folder' )
203
-
195
+ sub .label ('{}: {}' .format ('Rigify' , 'External feature sets' ))
204
196
if rigs_expand :
197
+ if os .path .exists (os .path .join (bpy .utils .script_path_user (), 'rigify' )):
198
+ feature_sets_path = os .path .join (bpy .utils .script_path_user (), 'rigify' )
199
+ for fs in os .listdir (feature_sets_path ):
200
+ row = col .row ()
201
+ row .label (fs )
202
+ op = row .operator ("wm.rigify_remove_feature_set" , text = "Remove" , icon = 'CANCEL' )
203
+ op .featureset = fs
204
+ row = col .row (align = True )
205
+ row .operator ("wm.rigify_add_feature_set" , text = "Install Feature Set from File..." , icon = 'FILESEL' )
206
+
205
207
split = col .row ().split (percentage = 0.15 )
206
208
split .label ('Description:' )
207
- split .label (text = 'When enabled the add-on will run in legacy mode using the old 2.76b feature set. ' )
209
+ split .label (text = 'External feature sets (rigs, metarigs, ui layouts) ' )
208
210
209
211
row = layout .row ()
210
212
row .label ("End of Rigify Preferences" )
@@ -259,6 +261,10 @@ class RigifySelectionColors(bpy.types.PropertyGroup):
259
261
)
260
262
261
263
264
+ class RigifyTemplate (bpy .types .PropertyGroup ):
265
+ name = bpy .props .StringProperty ()
266
+
267
+
262
268
class RigifyParameters (bpy .types .PropertyGroup ):
263
269
name = bpy .props .StringProperty ()
264
270
@@ -340,9 +346,11 @@ def set_group(self, value):
340
346
341
347
def register ():
342
348
ui .register ()
349
+ feature_sets .register ()
343
350
metarig_menu .register ()
344
351
345
352
bpy .utils .register_class (RigifyName )
353
+ bpy .utils .register_class (RigifyTemplate )
346
354
bpy .utils .register_class (RigifyParameters )
347
355
348
356
bpy .utils .register_class (RigifyColorSet )
@@ -351,6 +359,12 @@ def register():
351
359
bpy .utils .register_class (RigifyPreferences )
352
360
bpy .types .Armature .rigify_layers = bpy .props .CollectionProperty (type = RigifyArmatureLayer )
353
361
362
+ bpy .types .Armature .active_feature_set = bpy .props .EnumProperty (
363
+ items = feature_sets .feature_set_items ,
364
+ name = "Feature Set" ,
365
+ description = "Feature set to select from for this bone"
366
+ )
367
+
354
368
bpy .types .PoseBone .rigify_type = bpy .props .StringProperty (name = "Rigify Type" , description = "Rig type for this bone" )
355
369
bpy .types .PoseBone .rigify_parameters = bpy .props .PointerProperty (type = RigifyParameters )
356
370
@@ -383,7 +397,8 @@ def register():
383
397
), name = 'Theme' )
384
398
385
399
IDStore = bpy .types .WindowManager
386
- IDStore .rigify_collection = bpy .props .EnumProperty (items = rig_lists .col_enum_list , default = "All" ,
400
+ IDStore .rigify_collection = bpy .props .EnumProperty (items = (("All" , "All" , "All" ),),
401
+ default = "All" ,
387
402
name = "Rigify Active Collection" ,
388
403
description = "The selected rig collection" )
389
404
@@ -429,19 +444,27 @@ def update_mode(self, context):
429
444
if (ui and 'legacy' in str (ui )) or bpy .context .user_preferences .addons ['rigify' ].preferences .legacy_mode :
430
445
# update legacy on restart or reload
431
446
bpy .context .user_preferences .addons ['rigify' ].preferences .legacy_mode = True
447
+ IDStore = bpy .types .Armature
448
+ IDStore .rigify_templates = bpy .props .CollectionProperty (type = RigifyTemplate )
449
+ IDStore .rigify_active_template = bpy .props .IntProperty (name = "Rigify Active Template" , description = "The selected ui template" , default = 0 )
432
450
433
- # Add rig parameters
434
- for rig in rig_lists .rig_list :
435
- r = utils .get_rig_type (rig )
436
- try :
437
- r .add_parameters (RigifyParameterValidator (RigifyParameters , rig , RIGIFY_PARAMETER_TABLE ))
438
- except AttributeError :
439
- pass
451
+ bpy .context .user_preferences .addons ['rigify' ].preferences .update_external_rigs ()
440
452
441
- external_rigs_folder = bpy .context .user_preferences .addons ['rigify' ].preferences .custom_rigs_folder
442
- if external_rigs_folder and not 'external' in rig_lists .rigs_dict :
443
- #force update on reload
444
- bpy .context .user_preferences .addons ['rigify' ].preferences .custom_rigs_folder = external_rigs_folder
453
+ # Add rig parameters
454
+ if bpy .context .user_preferences .addons ['rigify' ].preferences .legacy_mode :
455
+ for rig in rig_lists .rig_list :
456
+ r = utils .get_rig_type (rig )
457
+ try :
458
+ r .add_parameters (RigifyParameters )
459
+ except AttributeError :
460
+ pass
461
+ else :
462
+ for rig in rig_lists .rigs :
463
+ r = rig_lists .rigs [rig ]['module' ]
464
+ try :
465
+ r .add_parameters (RigifyParameters )
466
+ except AttributeError :
467
+ pass
445
468
446
469
447
470
def unregister ():
@@ -464,17 +487,21 @@ def unregister():
464
487
del IDStore .rigify_transfer_start_frame
465
488
del IDStore .rigify_transfer_end_frame
466
489
490
+ IDStore = bpy .types .Armature
491
+ del IDStore .rigify_templates
492
+ del IDStore .rigify_active_template
493
+
467
494
bpy .utils .unregister_class (RigifyName )
495
+ bpy .utils .unregister_class (RigifyTemplate )
468
496
bpy .utils .unregister_class (RigifyParameters )
469
497
470
498
bpy .utils .unregister_class (RigifyColorSet )
471
499
bpy .utils .unregister_class (RigifySelectionColors )
472
500
473
501
bpy .utils .unregister_class (RigifyArmatureLayer )
474
-
475
- if bpy .context .user_preferences .addons ['rigify' ].preferences .custom_rigs_folder in sys .path :
476
- sys .path .remove (bpy .context .user_preferences .addons ['rigify' ].preferences .custom_rigs_folder )
477
- bpy .utils .unregister_class (RigifyPreferences )
502
+ if "bl_rna" in RigifyPreferences .__dict__ :
503
+ bpy .utils .unregister_class (RigifyPreferences )
478
504
479
505
metarig_menu .unregister ()
480
506
ui .unregister ()
507
+ feature_sets .unregister ()
0 commit comments