get references namespaces

Become a member of the CGSociety

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

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 03 March 2013   #1
get references namespaces

Hi!

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:
    try:
        if mc.referenceQuery(myNamespace, inr=True):
            myList.append(myNamespace.split(':')[0])
    except:
        pass
        
myDictionary = list(set(myList))


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

Thanks
 
Old 03 March 2013   #2
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 pm.ls(r=True, type='reference'):
	myList.append(r.referenceFile().fullNamespace)


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

David
__________________
http://www.djx.com.au
 
Old 03 March 2013   #3
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 = mc.ls(r=True, rf=True)
for myReference in allReferences:
    myList.append(mc.referenceQuery(myReference, ns=True, shn=True))
    
print myList


Thanks for the help!
 
Old 03 March 2013   #4
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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 07:40 PM.


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