get references namespaces

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  03 March 2013
get references namespaces


I was looking for a way of getting the namespaces of the references (the ones that appear in the reference editor) and I ended up with this:

allNamespaces = mc.namespaceInfo(ls=1, r=1)
myList = []
for myNamespace in allNamespaces:
        if mc.referenceQuery(myNamespace, inr=True):
myDictionary = list(set(myList))

I was wondering if there was a cleaner way of doing it cause it feels a little messy

  03 March 2013
I'm not sure how much better this really is, but here's how I'm doing it.

import pymel.core as pm
myList = []
for r in, type='reference'):

r.referenceFile() gives you an instance of the FileReference class which has several other useful methods (which is why I use it)

  03 March 2013
Hey David,

Seems that pymel has some nice methods! Unfortunately I have never used it
Nevertheless I think that your logic makes way more sense and it is cleaner, so here is the same with maya commands for future reference.

import maya.cmds as mc

myList = []
allReferences =, rf=True)
for myReference in allReferences:
    myList.append(mc.referenceQuery(myReference, ns=True, shn=True))
print myList

Thanks for the help!
  03 March 2013
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 11:12 PM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.