Created
January 24, 2023 10:48
-
-
Save aobond2/4f949a772cf0a3eebed7bb528b81da38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def repositionChildrenToPivot(): | |
coll = bpy.context.collection | |
# Iterate on all object, separate into list of objects, pivot, shadow catcher | |
objectList = [] | |
pivot = None | |
shadowCatcher = None | |
for c in coll.all_objects: | |
if ("Pivot" in c.name): | |
pivot = c | |
continue | |
if ("ShadowCatcher" in c.name): | |
shadowCatcher = c | |
continue | |
else: | |
objectList.append(c) | |
pLoc = pivot.location | |
# Set location of children object to pivot location | |
for o in objectList: | |
o.location = pLoc | |
# Select child then parent object | |
bpy.ops.object.select_all(action='DESELECT') | |
o.select_set(True) | |
pivot.select_set(True) | |
bpy.context.view_layer.objects.active = pivot | |
bpy.ops.object.parent_set(type='OBJECT') | |
#print(pivot.location) | |
#print(shadowCatcher) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment