how to find all unloaded (unchecked) referenced files in maya ?

940 views
Skip to first unread message

gnn

unread,
Jul 17, 2017, 8:46:32 AM7/17/17
to Python Programming for Autodesk Maya
Hi!
Did someone know why this little script isn't print all the unloaded referenced files in my .ma file?
i've got somes nested ones who are unchecked in the referenced editor,
and even if it print them in : 'print eachnode',
it doesn't tell me that they're unloaded...??


references=[]
for ref_node in cmds.ls(type='reference'):
    references
.append(ref_node)
for eachnode in references:
   
print eachnode
    unLoaded_ref_files
= cmds.referenceQuery(eachnode, filename=True, isLoaded=False)
print unLoaded_ref_files      

thanks a lot for any help

Neil Roche

unread,
Jul 18, 2017, 7:25:41 AM7/18/17
to Python Programming for Autodesk Maya
Off the top of my head I think the referenceQuery command will only return a boolean for the isLoaded flag.

Andres Weber

unread,
Jul 18, 2017, 5:05:17 PM7/18/17
to Python Programming for Autodesk Maya
This one liner seems to work
unloaded_reference_files = [file for file in cmds.file(reference=True, q=True) if not cmds.referenceQuery(file, isLoaded=True)]

gnn

unread,
Jul 23, 2017, 11:43:35 AM7/23/17
to Python Programming for Autodesk Maya
Thanks a lot Andes for your answer,
I'd done like that, it's working now :)

unLoaded_ref_files=[]
refList
= pm.ls(type='reference')
for ref in refList:
   
try:
       
if ref.isLoaded():
           
print ref
       
else:
            refUnloaded
="{}".format(ref)
           
print "{} IS NOT LOADED".format(ref)
            unLoaded_ref_files
.append(refUnloaded)
   
except:
       
print "FAILED with {}".format(ref)


Andres Weber

unread,
Jul 23, 2017, 6:08:22 PM7/23/17
to Python Programming for Autodesk Maya
Love how many ways Maya/Pymel includes to solve a problem!  It's a bit more verbose and seems to have some paths it might not go down (did you find it was actually going to the error catching section?) but if it works for you, that's great.

Just a tip, there's a few I could mention but this was the most glaring:
As a general rule you should always specify what errors you're expecting in the except section so you don't confuse yourself down the line depending on what input you pass.  It tends to be a bad design paradigm!

Gmanue

unread,
Jul 24, 2017, 1:40:53 PM7/24/17
to python_in...@googlegroups.com
Thanks for your advice, as i'm newbee with python it's nice to help me with that!

--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/iNYVImCqRM4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/e3b8b156-6a61-43f1-980e-4920fb5c9dab%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages