Skip to content

Instantly share code, notes, and snippets.

@mrmurphy
Created June 22, 2012 20:20
Show Gist options
  • Save mrmurphy/2974955 to your computer and use it in GitHub Desktop.
Save mrmurphy/2974955 to your computer and use it in GitHub Desktop.
Import all references from Maya
import pymel.core as pm
def importAllReferences():
print("Importing all references...")
done = False
while (done == False and (len(pm.listReferences()) != 0)):
refs = pm.listReferences()
print("Importing " + str(len(refs)) + " references.")
for ref in refs:
if ref.isLoaded():
done = False
ref.importContents()
else:
done = True
print("Done importing references...")
return True
@JanPhKoch
Copy link

JanPhKoch commented Nov 16, 2018

Thanks! You saved some time for me today :)

for others that find this:

the while statement could be cleaner with:
while not done and (len(pm.listReferences()) != 0):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment