Skip to content

Instantly share code, notes, and snippets.

@aobond2
Last active January 24, 2023 17:03
Show Gist options
  • Save aobond2/9919e43685f0548e2688cb1a0147b1e7 to your computer and use it in GitHub Desktop.
Save aobond2/9919e43685f0548e2688cb1a0147b1e7 to your computer and use it in GitHub Desktop.
def renameCollection_2():
categoryColl = bpy.context.collection
categoryName = categoryColl.name
pivotObject = None
shadowCatcherObject = None
prefix = "Prefix_"
if (checkCollectionNaming(categoryColl.name) == True):
# Set naming for collection
for childColl in categoryColl.children:
objectName = None
for object in childColl.all_objects:
if ("Item" in object.name):
objectName = object.name
if objectName != None:
childColl.name = prefix + objectName
# Get pivot and shadow catcher and update their naming
for c in categoryColl.all_objects:
if ("Pivot" in c.name):
pivotObject = c
if ("ShadowCatcher" in c.name):
shadowCatcherObject = c
# Set pivot object naming
if (pivotObject != None):
pivotObject.name = "Pivot_" + categoryName
# Set shadow catcher object naming
if (shadowCatcherObject != None):
shadowCatcherObject.name = "ShadowCatcher_" + categoryName
def checkCollectionNaming(collectionName):
if (collectionName == "Props"):
return False
if (collectionName == "Environment"):
return False
if (collectionName == "Placeholder"):
return False
if (collectionName == "Setup"):
return False
else:
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment