Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInes Almeida <britalmeida@gmail.com>2016-03-18 01:32:50 +0300
committerInes Almeida <britalmeida@gmail.com>2016-03-18 01:36:28 +0300
commit02036843584870eb29e3792d96fe8a2c1fca12c7 (patch)
treeabe1da71e137c657bf27929e6da7437f237bbc58 /bone_selection_sets.py
parent39e7885ac7ebc9d051f645d108ca2834dc056ff3 (diff)
[Selection Sets] Standard naming convention for new sets
Diffstat (limited to 'bone_selection_sets.py')
-rw-r--r--bone_selection_sets.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/bone_selection_sets.py b/bone_selection_sets.py
index b513973d..fc25404e 100644
--- a/bone_selection_sets.py
+++ b/bone_selection_sets.py
@@ -164,7 +164,6 @@ class POSE_OT_selection_set_add(PluginOperator):
bl_description = "Creates a new empty Selection Set"
bl_options = {'UNDO', 'REGISTER'}
- created_counter = 0
def execute(self, context):
arm = context.object
@@ -172,10 +171,23 @@ class POSE_OT_selection_set_add(PluginOperator):
new_sel_set = arm.selection_sets.add()
# naming
- new_sel_set.name = "SelectionSet"
- if POSE_OT_selection_set_add.created_counter > 0:
- new_sel_set.name += ".{:03d}".format(POSE_OT_selection_set_add.created_counter)
- POSE_OT_selection_set_add.created_counter += 1
+ if "SelectionSet" not in arm.selection_sets:
+ new_sel_set.name = "SelectionSet"
+ else:
+ sorted_sets = []
+ for selset in arm.selection_sets:
+ if selset.name.startswith("SelectionSet."):
+ index = selset.name[13:]
+ if index.isdigit():
+ sorted_sets.append(index)
+ sorted_sets = sorted(sorted_sets)
+ min_index = 1
+ for num in sorted_sets:
+ num = int(num)
+ if min_index < num:
+ break
+ min_index = num + 1
+ new_sel_set.name = "SelectionSet.{:03d}".format(min_index)
# select newly created set
arm.active_selection_set = len(arm.selection_sets) - 1
@@ -215,12 +227,10 @@ class POSE_OT_selection_set_assign(PluginOperator):
bpy.ops.wm.call_menu("INVOKE_DEFAULT",
name="pose.selection_set_create_new_popup")
- print("finished invoke")
return {'FINISHED'}
def execute(self, context):
- print ("execute")
arm = context.object
act_sel_set = arm.selection_sets[arm.active_selection_set]
@@ -295,7 +305,6 @@ class POSE_OT_selection_set_add_and_assign(PluginOperator):
def execute(self, context):
bpy.ops.pose.selection_set_add('EXEC_DEFAULT')
bpy.ops.pose.selection_set_assign('EXEC_DEFAULT')
- print("finished special")
return {'FINISHED'}
# Registry ####################################################################