Skip to content

Commit

Permalink
#475 Regenerate Name should only work when it is a collider object
Browse files Browse the repository at this point in the history
  • Loading branch information
Weisl committed Jan 31, 2024
1 parent 1ceb312 commit ac97068
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions collider_conversion/regenerate_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,22 @@ def poll(cls, context):

def execute(self, context):
prefs = context.preferences.addons[__package__.split('.')[0]].preferences

count = 0
for obj in context.selected_objects.copy():

# skip if invalid object
if obj is None or obj.type != "MESH":
if obj is None:
continue

if obj.type != "MESH":
continue

if not obj.get('isCollider'):
continue

# count how many objects are renamed
count = count + 1

if prefs.replace_name:
basename = prefs.obj_basename
elif obj.parent:
Expand All @@ -50,4 +59,8 @@ def execute(self, context):
obj.name = new_name
OBJECT_OT_add_bounding_object.set_data_name(obj, new_name, "_data")

# Show warning if no object is found to rename
if count == 0:
self.report({'WARNING'}, 'No collider to rename')

return {'FINISHED'}

0 comments on commit ac97068

Please sign in to comment.