CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 03-09-2013, 01:01 AM   #1
nookie
Know-it-All
 
nookie's Avatar
portfolio
Luca Fiorentini
Lighting Artist
Lucasfilm Animation
Singapore, Singapore
 
Join Date: Jan 2004
Posts: 367
Send a message via MSN to nookie
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:

Code:
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-09-2013, 04:46 AM   #2
djx
Where's my pony?
 
djx's Avatar
David Johnson
vfx & creature td
Melbourne, Australia
 
Join Date: Jun 2003
Posts: 3,414
I'm not sure how much better this really is, but here's how I'm doing it.

Code:
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-09-2013, 10:27 AM   #3
nookie
Know-it-All
 
nookie's Avatar
portfolio
Luca Fiorentini
Lighting Artist
Lucasfilm Animation
Singapore, Singapore
 
Join Date: Jan 2004
Posts: 367
Send a message via MSN to nookie
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.

Code:
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-09-2013, 10:27 AM   #4
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 05:25 AM.


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