Skip to content

Instantly share code, notes, and snippets.

@JustinPedersen
Created June 22, 2021 08:54
Show Gist options
  • Save JustinPedersen/4781760294d89a62e80cd52d24a56f63 to your computer and use it in GitHub Desktop.
Save JustinPedersen/4781760294d89a62e80cd52d24a56f63 to your computer and use it in GitHub Desktop.
Quick script to copy or instance one source object onto multiple other object's locations.
import pymel.core as pm
# Useage: Select the source object, then all of the target objects to copy to.
# Change this to True if you want to use Instances
make_instance = False
user_selection = pm.ls(selection=True)
if not len(user_selection) >= 2:
pm.error('Please select at least 2 objects')
source_obj = user_selection[0]
target_objs = user_selection[1:]
for target_obj in target_objs:
if make_instance:
new_obj = pm.instance(source_obj)
else:
new_obj = pm.duplicate(source_obj)
pm.matchTransform(new_obj, target_obj)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment