0

How can I check if a reference with a particular unresolved name is loaded using an if statement. Thanks

Pseudo code example

If (referenceLoaded "C:/bridge.ma"){ do stuff}

Milesklc
  • 3
  • 4

3 Answers3

0

You could try something like

referenceQuery -isLoaded "C:/bridge.ma";

Which will return a 1 or 0 if the file is loaded or not.

Heres a rough example of the above in an if statement:

if (!`referenceQuery -isLoaded "C:/bridge.ma"`)
    print("reference not loaded");

else if (`referenceQuery -isLoaded "C:/bridge.ma"`)
    print("reference is loaded");
Mr K
  • 33
  • 5
  • Thanks. It wored beautifully – Milesklc Aug 19 '16 at 00:25
  • Sorry but I realize that it doesn't work as well as i want it to. It only works if the file as been referenced that is, it appears in the reference editor. However, I would like to beable to detect if the file is actually referenced. Right now the current code throws an error "please specify a reference node, referenced file, or node from a referenced file." I think it's because the file was never referenced before. But if the file was referenced but just not loaded, the code would work. – Milesklc Aug 19 '16 at 00:46
0

Sorry but I realize that it doesn't work as well as i want it to. It only works if the file as been referenced that is, it appears in the reference editor. However, I would like to beable to detect if the file is actually referenced. Right now the current code throws an error "please specify a reference node, referenced file, or node from a referenced file." I think it's because the file was never referenced before. But if the file was referenced but just not loaded, the code would work.

Milesklc
  • 3
  • 4
0

I resolved the erroring out issue by using catch

if (catch(!referenceQuery -isLoaded "C:/bridge.ma")) { continue; } else if (referenceQuery -isLoaded "C:/bridge.ma") { print("reference is loaded"); }

Milesklc
  • 3
  • 4