Skip to content

Instantly share code, notes, and snippets.

@LiamHz
Created February 23, 2025 07:07
Show Gist options
  • Save LiamHz/87a5413794a73eefab9ac4e2ff244161 to your computer and use it in GitHub Desktop.
Save LiamHz/87a5413794a73eefab9ac4e2ff244161 to your computer and use it in GitHub Desktop.
import bpy
def create_assets_from_empty_children():
# Get all empties in the scene
empties = [obj for obj in bpy.data.objects if obj.type == 'EMPTY']
for empty in empties:
# Get direct mesh children
children = [obj for obj in empty.children if obj.type == 'MESH']
if len(children) < 1:
continue
# Prepare selection
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.select_all(action='DESELECT')
# Select all children and set active object
for child in children:
child.select_set(True)
bpy.context.view_layer.objects.active = children[0]
# Join objects
bpy.ops.object.join()
# Get resulting object
joined_obj = bpy.context.active_object
joined_obj.name = f"{empty.name.rstrip('_grp')}"
# Mark as asset
joined_obj.asset_mark()
# Generate asset preview
joined_obj.asset_generate_preview()
if __name__ == "__main__":
create_assets_from_empty_children()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment