From 36876a3f96c43e5f9e4476f5675cca608cb6d179 Mon Sep 17 00:00:00 2001 From: Matthias Patscheider Date: Sun, 19 Sep 2021 14:11:19 +0300 Subject: [PATCH 01/11] #85 Fix Fixed bug that numerating does not work properly for renaming selected bones in edit bone mode --- renaming_operators.py | 19 +++++++++++++------ renaming_utilities.py | 6 ++++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/renaming_operators.py b/renaming_operators.py index 676f8bf..23c2221 100644 --- a/renaming_operators.py +++ b/renaming_operators.py @@ -360,6 +360,13 @@ def execute(self, context): # for key in bpy.data.shape_keys[0].key_blocks: # shapeKeyNamesList.append(key.name) + boneList = [] + + if wm.renaming_object_types == 'BONE': + for arm in bpy.data.armatures: + for bone in arm.bones: + boneList.append(bone.name) + VariableReplacer.reset() if len(str(replaceName)) > 0: if len(renamingList) > 0: @@ -378,12 +385,6 @@ def execute(self, context): newName = replaceName dataList = [] - boneList = [] - - if wm.renaming_object_types == 'BONE': - for arm in bpy.data.armatures: - for bone in arm.bones: - boneList.append(bone.name) if wm.renaming_object_types == 'DATA': for obj in bpy.data.objects: @@ -419,10 +420,16 @@ def execute(self, context): break elif wm.renaming_object_types == 'BONE': + print("Bone List: " + str(boneList) + '\n') if newName in boneList and newName != entity.name: + print(newName + '\n') i = i + 1 else: + print('lollololol \n') + boneList.append(newName) break + + elif wm.renaming_object_types == 'COLLECTION': if newName in bpy.data.collections and newName != entity.name: i = i + 1 diff --git a/renaming_utilities.py b/renaming_utilities.py index 4e4022d..773f4a1 100644 --- a/renaming_utilities.py +++ b/renaming_utilities.py @@ -56,6 +56,7 @@ def getRenamingList(self, context, overrideSelection=False): selectedBones = [] selection = context.selected_objects + if modeOld == 'OBJECT': errorMsg = "Renaming only selected Bones is only supported for EDIT and POSE mode by now." return None, None, errorMsg @@ -79,6 +80,7 @@ def getRenamingList(self, context, overrideSelection=False): # else: # if modeOld == 'EDIT_ARMATURE' # + #TODO: Save armature for bones for selected_bone in selectedBones: name = selected_bone.name for arm in armatures: @@ -86,12 +88,12 @@ def getRenamingList(self, context, overrideSelection=False): for bone in arm.bones: if name == bone.name: newBone = PoseBone(arm.bones[name]) - renamingList.append(newBone) + renamingList.append(newBone) else: # modeOld == 'EDIT': for bone in arm.edit_bones: if name == bone.name: newBone = arm.edit_bones[name] - renamingList.append(newBone) + renamingList.append(newBone) else: for arm in bpy.data.armatures: From c3d37378b78ef10da73f4184748ccbbaabfcb363 Mon Sep 17 00:00:00 2001 From: Matthias Patscheider Date: Mon, 20 Sep 2021 20:28:36 +0300 Subject: [PATCH 02/11] #84 [fix] Can't rename font and metaball --- renaming_operators.py | 41 +++++++++++++++++++---------------------- renaming_utilities.py | 36 ++++++++++++++---------------------- 2 files changed, 33 insertions(+), 44 deletions(-) diff --git a/renaming_operators.py b/renaming_operators.py index 23c2221..785d34d 100644 --- a/renaming_operators.py +++ b/renaming_operators.py @@ -23,6 +23,11 @@ def randomString(stringLength=10): def switchToEditMode(context): bpy.ops.object.mode_set(mode='EDIT') +# def numerate_new_name(replaceName,separator, fill, width, step, startNum ,digits): +# newName = replaceName + separator + ( +# '{num:{fill}{width}}'.format(num=(i * step) + startNum, fill='0', width=digits)) +# return newName + class VariableReplacer(): addon_prefs = None @@ -194,7 +199,6 @@ def getCollection(cls, context, entity): return collectionNames - # TODO Parent class that contains common functionality like setting up variables, getRenamingList and Error Handling class VIEW3D_OT_search_and_select(bpy.types.Operator): @@ -248,7 +252,7 @@ def execute(self, context): obj.select_set(True) elif str(wm.renaming_object_types) == 'BONE': - print("SELECTION LIST: " + str(selectionList)) + # print("SELECTION LIST: " + str(selectionList)) if bpy.context.mode == 'POSE': bpy.ops.pose.select_all(action='DESELECT') for bone in selectionList: @@ -257,7 +261,7 @@ def execute(self, context): elif bpy.context.mode == 'EDIT_ARMATURE': bpy.ops.armature.select_all(action='DESELECT') for bone in selectionList: - print("EDIT Bone: " + str(bone)) + # print("EDIT Bone: " + str(bone)) bone.select = True bone.select_head = True bone.select_tail = True @@ -357,8 +361,6 @@ def execute(self, context): for key_grp in bpy.data.shape_keys: for key in key_grp.key_blocks: shapeKeyNamesList.append(key.name) - # for key in bpy.data.shape_keys[0].key_blocks: - # shapeKeyNamesList.append(key.name) boneList = [] @@ -368,6 +370,7 @@ def execute(self, context): boneList.append(bone.name) VariableReplacer.reset() + if len(str(replaceName)) > 0: if len(renamingList) > 0: for entity in renamingList: @@ -378,9 +381,6 @@ def execute(self, context): i = 0 - if wm.renaming_object_types == 'COLLECTION' or wm.renaming_object_types == 'IMAGE': - i = 0 - oldName = entity.name newName = replaceName @@ -399,9 +399,10 @@ def execute(self, context): if wm.renaming_object_types == 'OBJECT': if newName in bpy.data.objects and newName != entity.name: - i = i + 1 + i += i + 1 else: break + elif wm.renaming_object_types == 'MATERIAL': if newName in bpy.data.materials and newName != entity.name: i = i + 1 @@ -413,6 +414,7 @@ def execute(self, context): i = i + 1 else: break + elif wm.renaming_object_types == 'DATA': if newName in dataList and newName != entity.name: i = i + 1 @@ -420,12 +422,10 @@ def execute(self, context): break elif wm.renaming_object_types == 'BONE': - print("Bone List: " + str(boneList) + '\n') - if newName in boneList and newName != entity.name: - print(newName + '\n') + if newName in boneList: + print(newName) i = i + 1 else: - print('lollololol \n') boneList.append(newName) break @@ -443,9 +443,7 @@ def execute(self, context): break elif wm.renaming_object_types == 'SHAPEKEYS': - # print (str(i) + " " + str(shapeKeyNamesList)) if newName in shapeKeyNamesList: - # print('1') shapeKeyNamesList.append(newName) i = i + 1 else: @@ -454,8 +452,7 @@ def execute(self, context): else: break - newName = replaceName + separator + ( - '{num:{fill}{width}}'.format(num=(i * step) + startNum, fill='0', width=digits)) + entity.name = newName msg.addMessage(oldName, entity.name) i = i + 1 @@ -463,7 +460,7 @@ def execute(self, context): else: # len(str(replaceName)) <= 0 msg.addMessage(None, None, "Insert a valid string to replace names") - i = 0 + callRenamingPopup(context) if switchEditMode: @@ -690,9 +687,9 @@ def execute(self, context): ('LATTICE', "", "Rename lattice objects", 'OUTLINER_OB_LATTICE', 32), ('CURVE', "", "Rename curve objects", 'OUTLINER_OB_CURVE', 64), ('SURFACE', "", "Rename surface objects", 'OUTLINER_OB_SURFACE', 128), - ('TEXT', "", "Rename text objects", 'OUTLINER_OB_FONT', 256), + ('FONT', "", "Rename font objects", 'OUTLINER_OB_FONT', 256), ('GPENCIL', "", "Rename greace pencil objects", 'OUTLINER_OB_GREASEPENCIL', 512), - ('METABALL', "", "Rename metaball objects", 'OUTLINER_OB_META', 1024), + ('META', "", "Rename metaball objects", 'OUTLINER_OB_META', 1024), ('SPEAKER', "", "Rename empty speakers", 'OUTLINER_OB_SPEAKER', 2048), ('LIGHT_PROBE', "", "Rename mesh lightpropes", 'OUTLINER_OB_LIGHTPROBE', 4096), ('VOLUME', "", "Rename mesh volumes", 'OUTLINER_OB_VOLUME', 8192) @@ -754,9 +751,9 @@ def register(): items=enumObjectTypes, description="Which kind of object to rename", options={'ENUM_FLAG'}, - default={'CURVE', 'LATTICE', 'SURFACE', 'METABALL', 'MESH', + default={'CURVE', 'LATTICE', 'SURFACE','MESH', 'ARMATURE', 'LIGHT', 'CAMERA', 'EMPTY', 'GPENCIL', - 'TEXT', 'SPEAKER', 'LIGHT_PROBE', 'VOLUME'} + 'FONT', 'SPEAKER', 'LIGHT_PROBE', 'VOLUME'} ) IDStore.renaming_newName = StringProperty(name="New Name", default='') diff --git a/renaming_utilities.py b/renaming_utilities.py index 773f4a1..8447385 100644 --- a/renaming_utilities.py +++ b/renaming_utilities.py @@ -1,5 +1,5 @@ import bpy -from bpy.types import PoseBone +from bpy.types import PoseBone, EditBone def trimString(string, size): @@ -53,9 +53,12 @@ def getRenamingList(self, context, overrideSelection=False): modeOld = context.mode if onlySelection == True: - selectedBones = [] - selection = context.selected_objects + selection_and_active = context.selected_objects.copy() + if context.object not in selection_and_active: + selection_and_active.append(context.object) + + selectedBones = [] if modeOld == 'OBJECT': errorMsg = "Renaming only selected Bones is only supported for EDIT and POSE mode by now." @@ -69,41 +72,30 @@ def getRenamingList(self, context, overrideSelection=False): switchEditMode = True armatures = [] - for obj in selection: + for obj in selection_and_active: if obj.type == 'ARMATURE': armatures.append(obj.data) - # bpy.ops.object.mode_set(mode='POSE') - # bpy.ops.object.mode_set(mode='EDIT') - # if modeOld == 'POSE': - # bpy.ops.object.mode_set(mode='POSE') - # else: # if modeOld == 'EDIT_ARMATURE' - # - #TODO: Save armature for bones for selected_bone in selectedBones: - name = selected_bone.name for arm in armatures: if modeOld == 'POSE': + name = selected_bone.name for bone in arm.bones: if name == bone.name: newBone = PoseBone(arm.bones[name]) renamingList.append(newBone) else: # modeOld == 'EDIT': for bone in arm.edit_bones: - if name == bone.name: - newBone = arm.edit_bones[name] + if selected_bone == bone: + newBone = EditBone(selected_bone) renamingList.append(newBone) - else: + else: # if onlySelection == False for arm in bpy.data.armatures: - if modeOld == 'POSE' or modeOld == 'OBJECT': - for bone in arm.bones: - # print(bone) - renamingList.append(bone) - else: - for bone in arm.edit_bones: - renamingList.append(bone) + for bone in arm.bones: + renamingList.append(bone) + elif wm.renaming_object_types == 'COLLECTION': From 27ee36db422d9ddfe58e2edd4829c477e1700c7b Mon Sep 17 00:00:00 2001 From: Matthias Patscheider Date: Mon, 20 Sep 2021 20:40:06 +0300 Subject: [PATCH 03/11] #85 Use edit_bones instead of bones for EDIT mode renaming --- renaming_operators.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/renaming_operators.py b/renaming_operators.py index 785d34d..5729328 100644 --- a/renaming_operators.py +++ b/renaming_operators.py @@ -363,11 +363,16 @@ def execute(self, context): shapeKeyNamesList.append(key.name) boneList = [] + modeOld = context.mode if wm.renaming_object_types == 'BONE': for arm in bpy.data.armatures: - for bone in arm.bones: - boneList.append(bone.name) + if modeOld == 'POSE': + for bone in arm.bones: + boneList.append(bone.name) + else: # modeOld == 'EDIT': + for bone in arm.edit_bones: + boneList.append(bone.name) VariableReplacer.reset() @@ -423,7 +428,6 @@ def execute(self, context): elif wm.renaming_object_types == 'BONE': if newName in boneList: - print(newName) i = i + 1 else: boneList.append(newName) From 8ee028336fb2bf69e458aec17182afb41d5fea5f Mon Sep 17 00:00:00 2001 From: Matthias Patscheider Date: Mon, 20 Sep 2021 22:33:49 +0300 Subject: [PATCH 04/11] Replace ugly for loop --- renaming_operators.py | 160 ++++++++++++++++++++---------------------- 1 file changed, 77 insertions(+), 83 deletions(-) diff --git a/renaming_operators.py b/renaming_operators.py index 5729328..3a74ed0 100644 --- a/renaming_operators.py +++ b/renaming_operators.py @@ -23,11 +23,51 @@ def randomString(stringLength=10): def switchToEditMode(context): bpy.ops.object.mode_set(mode='EDIT') -# def numerate_new_name(replaceName,separator, fill, width, step, startNum ,digits): -# newName = replaceName + separator + ( -# '{num:{fill}{width}}'.format(num=(i * step) + startNum, fill='0', width=digits)) -# return newName +def numerate_object_name(context, new_name, typelist, active_entity_name): + + wm = context.scene + digits = len(wm.renaming_numerate) + + prefs = context.preferences.addons[__package__].preferences + separator = prefs.renaming_separator + startNum = prefs.numerate_start_number + step = prefs.numerate_step + + i = startNum + + newName = new_name + separator + ( + '{num:{fill}{width}}'.format(num=(i * step) + startNum, fill='0', width=digits)) + + while newName in typelist and newName != active_entity_name: + i += 1 + newName = new_name + separator + ( + '{num:{fill}{width}}'.format(num=(i * step) + startNum, fill='0', width=digits)) + + return newName + +def getAllBones(mode): + '''Get list of all bones depending of Edit or Pose Mode''' + + boneList = [] + + for arm in bpy.data.armatures: + if mode == 'POSE': + for bone in arm.bones: + boneList.append(bone.name) + else: # mode == 'EDIT': + for bone in arm.edit_bones: + boneList.append(bone.name) + + return boneList + +def getAllShapeKeys(): + '''get list of all shape keys''' + shapeKeyNamesList = [] + + for key_grp in bpy.data.shape_keys: + for key in key_grp.key_blocks: + shapeKeyNamesList.append(key.name) class VariableReplacer(): addon_prefs = None @@ -347,42 +387,32 @@ def execute(self, context): callErrorPopup(context) return {'CANCELLED'} - digits = len(wm.renaming_numerate) + modeOld = context.mode + + # settings for numerating the new name + prefs = context.preferences.addons[__package__].preferences separator = prefs.renaming_separator - startNum = prefs.numerate_start_number step = prefs.numerate_step msg = wm.renaming_messages - shapeKeyNamesList = [] + # get list of all objects of certain type if wm.renaming_object_types == 'SHAPEKEYS': - for key_grp in bpy.data.shape_keys: - for key in key_grp.key_blocks: - shapeKeyNamesList.append(key.name) - - boneList = [] - modeOld = context.mode + shapeKeyNamesList = getAllShapeKeys() if wm.renaming_object_types == 'BONE': - for arm in bpy.data.armatures: - if modeOld == 'POSE': - for bone in arm.bones: - boneList.append(bone.name) - else: # modeOld == 'EDIT': - for bone in arm.edit_bones: - boneList.append(bone.name) + boneList = getAllBones(modeOld) VariableReplacer.reset() - if len(str(replaceName)) > 0: - if len(renamingList) > 0: + if len(str(replaceName)) > 0: # New name is not empty + if len(renamingList) > 0: # List of objects to rename is not empty for entity in renamingList: if entity is not None: replaceName = VariableReplacer.replaceInputString(context, wm.renaming_newName, entity) - # print ("Entity: " + entity.name + " " + "replaced: " + replaceName) i = 0 @@ -398,68 +428,32 @@ def execute(self, context): if wm.renaming_usenumerate == True: - while True: - newName = replaceName + separator + ( - '{num:{fill}{width}}'.format(num=(i * step) + startNum, fill='0', width=digits)) - - if wm.renaming_object_types == 'OBJECT': - if newName in bpy.data.objects and newName != entity.name: - i += i + 1 - else: - break - - elif wm.renaming_object_types == 'MATERIAL': - if newName in bpy.data.materials and newName != entity.name: - i = i + 1 - else: - break - - elif wm.renaming_object_types == 'IMAGE': - if newName in bpy.data.images and newName != entity.name: - i = i + 1 - else: - break - - elif wm.renaming_object_types == 'DATA': - if newName in dataList and newName != entity.name: - i = i + 1 - else: - break - - elif wm.renaming_object_types == 'BONE': - if newName in boneList: - i = i + 1 - else: - boneList.append(newName) - break - - - elif wm.renaming_object_types == 'COLLECTION': - if newName in bpy.data.collections and newName != entity.name: - i = i + 1 - else: - break - - elif wm.renaming_object_types == 'ACTIONS': - if newName in bpy.data.actions and newName != entity.name: - i = i + 1 - else: - break - - elif wm.renaming_object_types == 'SHAPEKEYS': - if newName in shapeKeyNamesList: - shapeKeyNamesList.append(newName) - i = i + 1 - else: - shapeKeyNamesList.append(newName) - break - else: - break + if wm.renaming_object_types == 'OBJECT': + new_name = numerate_object_name(context, replaceName, bpy.data.objects, entity.name) + elif wm.renaming_object_types == 'MATERIAL': + new_name = numerate_object_name(context, replaceName, bpy.data.materials, entity.name) - entity.name = newName - msg.addMessage(oldName, entity.name) - i = i + 1 + elif wm.renaming_object_types == 'IMAGE': + new_name = numerate_object_name(context, replaceName, bpy.data.images, entity.name) + + elif wm.renaming_object_types == 'DATA': + new_name = numerate_object_name(context, replaceName, dataList, entity.name) + + elif wm.renaming_object_types == 'BONE': + new_name = numerate_object_name(context, replaceName, boneList, entity.name) + + elif wm.renaming_object_types == 'COLLECTION': + new_name = numerate_object_name(context, replaceName, bpy.data.collections, entity.name) + + elif wm.renaming_object_types == 'ACTIONS': + new_name = numerate_object_name(context, replaceName, bpy.data.actions, entity.name) + + elif wm.renaming_object_types == 'SHAPEKEYS': + new_name = numerate_object_name(context, replaceName, shapeKeyNamesList, entity.name) + + entity.name = new_name + msg.addMessage(oldName, entity.name) else: # len(str(replaceName)) <= 0 msg.addMessage(None, None, "Insert a valid string to replace names") From 1a35d88d97a827ba9c58e291489b44df81396a47 Mon Sep 17 00:00:00 2001 From: Matthias Patscheider Date: Mon, 20 Sep 2021 22:36:34 +0300 Subject: [PATCH 05/11] Remove unnecessary append --- renaming_operators.py | 1 - 1 file changed, 1 deletion(-) diff --git a/renaming_operators.py b/renaming_operators.py index 5729328..c6d867f 100644 --- a/renaming_operators.py +++ b/renaming_operators.py @@ -448,7 +448,6 @@ def execute(self, context): elif wm.renaming_object_types == 'SHAPEKEYS': if newName in shapeKeyNamesList: - shapeKeyNamesList.append(newName) i = i + 1 else: shapeKeyNamesList.append(newName) From a742eb9e29b50c0c18dbc1475c85463e1b4367e6 Mon Sep 17 00:00:00 2001 From: Matthias Patscheider Date: Mon, 20 Sep 2021 22:51:56 +0300 Subject: [PATCH 06/11] Update bone and shapekey lists --- renaming_operators.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/renaming_operators.py b/renaming_operators.py index 3a74ed0..8bbf86d 100644 --- a/renaming_operators.py +++ b/renaming_operators.py @@ -24,7 +24,7 @@ def switchToEditMode(context): bpy.ops.object.mode_set(mode='EDIT') -def numerate_object_name(context, new_name, typelist, active_entity_name): +def numerate_object_name(context, new_name, typelist, active_entity_name, return_type_list = False): wm = context.scene digits = len(wm.renaming_numerate) @@ -44,6 +44,10 @@ def numerate_object_name(context, new_name, typelist, active_entity_name): newName = new_name + separator + ( '{num:{fill}{width}}'.format(num=(i * step) + startNum, fill='0', width=digits)) + if return_type_list: # Manually add new name to custom generated list like all bones and all shape keys + typelist.append(new_name) + return newName, typelist + return newName def getAllBones(mode): @@ -441,7 +445,7 @@ def execute(self, context): new_name = numerate_object_name(context, replaceName, dataList, entity.name) elif wm.renaming_object_types == 'BONE': - new_name = numerate_object_name(context, replaceName, boneList, entity.name) + new_name, boneList = numerate_object_name(context, replaceName, boneList, entity.name, return_type_list = True) elif wm.renaming_object_types == 'COLLECTION': new_name = numerate_object_name(context, replaceName, bpy.data.collections, entity.name) @@ -450,7 +454,7 @@ def execute(self, context): new_name = numerate_object_name(context, replaceName, bpy.data.actions, entity.name) elif wm.renaming_object_types == 'SHAPEKEYS': - new_name = numerate_object_name(context, replaceName, shapeKeyNamesList, entity.name) + new_name, shapeKeyNamesList = numerate_object_name(context, replaceName, shapeKeyNamesList, entity.name, return_type_list = True) entity.name = new_name msg.addMessage(oldName, entity.name) From 601b1f306207e35174baabfe4294bfcca528055b Mon Sep 17 00:00:00 2001 From: Matthias Patscheider Date: Mon, 20 Sep 2021 23:00:50 +0300 Subject: [PATCH 07/11] Clean Data --- renaming_operators.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/renaming_operators.py b/renaming_operators.py index 8bbf86d..542434a 100644 --- a/renaming_operators.py +++ b/renaming_operators.py @@ -73,6 +73,17 @@ def getAllShapeKeys(): for key in key_grp.key_blocks: shapeKeyNamesList.append(key.name) + return shapeKeyNamesList + +def getAllDataNames(): + dataList = [] + + for obj in bpy.data.objects: + if obj.data is not None: + dataList.append(obj.data.name) + + return dataList + class VariableReplacer(): addon_prefs = None entity = None @@ -409,6 +420,10 @@ def execute(self, context): if wm.renaming_object_types == 'BONE': boneList = getAllBones(modeOld) + if wm.renaming_object_types == 'DATA': + dataList = getAllDataNames() + + VariableReplacer.reset() if len(str(replaceName)) > 0: # New name is not empty @@ -425,12 +440,10 @@ def execute(self, context): dataList = [] - if wm.renaming_object_types == 'DATA': - for obj in bpy.data.objects: - if obj.data is not None: - dataList.append(obj.data.name) + if wm.renaming_usenumerate == False: + new_name - if wm.renaming_usenumerate == True: + else # if wm.renaming_usenumerate == True if wm.renaming_object_types == 'OBJECT': new_name = numerate_object_name(context, replaceName, bpy.data.objects, entity.name) @@ -442,7 +455,7 @@ def execute(self, context): new_name = numerate_object_name(context, replaceName, bpy.data.images, entity.name) elif wm.renaming_object_types == 'DATA': - new_name = numerate_object_name(context, replaceName, dataList, entity.name) + new_name, dataList = numerate_object_name(context, replaceName, dataList, entity.name, return_type_list = True) elif wm.renaming_object_types == 'BONE': new_name, boneList = numerate_object_name(context, replaceName, boneList, entity.name, return_type_list = True) From e89ec007f730703696d2528caf0bf950601902e9 Mon Sep 17 00:00:00 2001 From: Matthias Patscheider Date: Mon, 20 Sep 2021 23:11:38 +0300 Subject: [PATCH 08/11] Fix numerating issue for code optimization --- renaming_operators.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/renaming_operators.py b/renaming_operators.py index 542434a..caf004c 100644 --- a/renaming_operators.py +++ b/renaming_operators.py @@ -24,7 +24,7 @@ def switchToEditMode(context): bpy.ops.object.mode_set(mode='EDIT') -def numerate_object_name(context, new_name, typelist, active_entity_name, return_type_list = False): +def numerate_object_name(context, name, typelist, active_entity_name, return_type_list = False): wm = context.scene digits = len(wm.renaming_numerate) @@ -36,16 +36,16 @@ def numerate_object_name(context, new_name, typelist, active_entity_name, return i = startNum - newName = new_name + separator + ( + newName = name + separator + ( '{num:{fill}{width}}'.format(num=(i * step) + startNum, fill='0', width=digits)) while newName in typelist and newName != active_entity_name: i += 1 - newName = new_name + separator + ( + newName = name + separator + ( '{num:{fill}{width}}'.format(num=(i * step) + startNum, fill='0', width=digits)) if return_type_list: # Manually add new name to custom generated list like all bones and all shape keys - typelist.append(new_name) + typelist.append(newName) return newName, typelist return newName @@ -443,7 +443,7 @@ def execute(self, context): if wm.renaming_usenumerate == False: new_name - else # if wm.renaming_usenumerate == True + else: # if wm.renaming_usenumerate == True if wm.renaming_object_types == 'OBJECT': new_name = numerate_object_name(context, replaceName, bpy.data.objects, entity.name) @@ -458,6 +458,7 @@ def execute(self, context): new_name, dataList = numerate_object_name(context, replaceName, dataList, entity.name, return_type_list = True) elif wm.renaming_object_types == 'BONE': + print(str(boneList)) new_name, boneList = numerate_object_name(context, replaceName, boneList, entity.name, return_type_list = True) elif wm.renaming_object_types == 'COLLECTION': From de00d1f420c255bb03d317c93a30987195700d72 Mon Sep 17 00:00:00 2001 From: Matthias Patscheider Date: Mon, 20 Sep 2021 23:26:42 +0300 Subject: [PATCH 09/11] Fix non selected numerate --- renaming_operators.py | 3 ++- renaming_utilities.py | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/renaming_operators.py b/renaming_operators.py index caf004c..1e93937 100644 --- a/renaming_operators.py +++ b/renaming_operators.py @@ -441,7 +441,8 @@ def execute(self, context): dataList = [] if wm.renaming_usenumerate == False: - new_name + entity.name = replaceName + msg.addMessage(oldName, entity.name) else: # if wm.renaming_usenumerate == True diff --git a/renaming_utilities.py b/renaming_utilities.py index 8447385..e62ac12 100644 --- a/renaming_utilities.py +++ b/renaming_utilities.py @@ -93,9 +93,14 @@ def getRenamingList(self, context, overrideSelection=False): else: # if onlySelection == False for arm in bpy.data.armatures: - for bone in arm.bones: - renamingList.append(bone) - + if modeOld == 'EDIT': + for bone in arm.edit_bones: + newBone = EditBone(bone) + renamingList.append(newBone) + else: # modeOld == 'POSE' or modeOld == 'OBJECT' + for bone in arm.bones: + newBone = PoseBone(bone) + renamingList.append(newBone) elif wm.renaming_object_types == 'COLLECTION': From 702bd81959f214f118e5c23071e0b2d7133a6080 Mon Sep 17 00:00:00 2001 From: matthias Date: Fri, 24 Sep 2021 21:49:21 +0300 Subject: [PATCH 10/11] #93 -Fix edit mode renaming all --- renaming_operators.py | 1 - renaming_utilities.py | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/renaming_operators.py b/renaming_operators.py index 28a8eb1..0f82895 100644 --- a/renaming_operators.py +++ b/renaming_operators.py @@ -459,7 +459,6 @@ def execute(self, context): new_name, dataList = numerate_object_name(context, replaceName, dataList, entity.name, return_type_list = True) elif wm.renaming_object_types == 'BONE': - print(str(boneList)) new_name, boneList = numerate_object_name(context, replaceName, boneList, entity.name, return_type_list = True) elif wm.renaming_object_types == 'COLLECTION': diff --git a/renaming_utilities.py b/renaming_utilities.py index e62ac12..02fcb28 100644 --- a/renaming_utilities.py +++ b/renaming_utilities.py @@ -85,7 +85,7 @@ def getRenamingList(self, context, overrideSelection=False): if name == bone.name: newBone = PoseBone(arm.bones[name]) renamingList.append(newBone) - else: # modeOld == 'EDIT': + else: # modeOld == 'EDIT_ARMATURE': for bone in arm.edit_bones: if selected_bone == bone: newBone = EditBone(selected_bone) @@ -93,7 +93,7 @@ def getRenamingList(self, context, overrideSelection=False): else: # if onlySelection == False for arm in bpy.data.armatures: - if modeOld == 'EDIT': + if modeOld == 'EDIT_ARMATURE': for bone in arm.edit_bones: newBone = EditBone(bone) renamingList.append(newBone) @@ -102,7 +102,6 @@ def getRenamingList(self, context, overrideSelection=False): newBone = PoseBone(bone) renamingList.append(newBone) - elif wm.renaming_object_types == 'COLLECTION': renamingList = list(bpy.data.collections) From d3f850f5bdb917b067c8dc390bba0e4caee5aae3 Mon Sep 17 00:00:00 2001 From: Matthias Patscheider Date: Fri, 24 Sep 2021 21:58:55 +0300 Subject: [PATCH 11/11] Update Blender Version and Addon version --- __init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/__init__.py b/__init__.py index c7ca41e..def3554 100644 --- a/__init__.py +++ b/__init__.py @@ -22,8 +22,8 @@ "name": "Simple Renaming Panel", "description": "This Addon offers the basic functionality of renaming a set of objects", "author": "Matthias Patscheider", - "version": (1, 5, 1), - "blender": (2, 83, 0), + "version": (1, 5, 2), + "blender": (2, 93, 0), "location": "View3D > Tools ", "warning": "", "wiki_url": "https://weisl.github.io/renaming/",