[Maya] Node Added Callback and File Open

I made a callback that fires whenever a new “file” node is created in the maya scene. This callback will attach an “Attribute Changed” callback that will fire whenever the “fileTextureName” attribute is changed.

Everything works fine, until I open another file, which during load, is creating and setting the callbacks, which in turn, are all triggered since technically, Maya is creating nodes and setting value during a Load operation.

My question is, is it possible to separate the act of Loading a File from the act of the user creating a new Node?

In other words, is it possible to create a callback for “Node Added” that will NOT be triggered by a Load operation?

Note: I am using API callbacks.

shot from the hip:

callback on pre file load that sets an opt var
callback on post file load that unsets it

in your node added callback, check the opt var

?

yeah, I do something similar to detect “Save” versus “Save As”… but I think I might forego the NodeAdded callback for a more targeted application of the callback.

what is really annoying about this, is that I thought setting up the callback using “kAfterOpen” would avoid the issues of triggering the callback while the file is being opened.

the documentation on MMessage offers some advice on Callback during File Read, but no links to how to actually implement what they advise:

http://help.autodesk.com/view/MAYAUL/2015/ENU/?guid=__cpp_ref_class_m_message_html

"For these reasons, callbacks should avoid querying or modifying the DG in any way during file read. They should not add or remove nodes, make or break connections, change parenting, set or retrieve plug values, etc. Even something as innocuous as a call to MFnDagNode::isIntermediateObject may cause problems since it queries the value of the node’s intermediateObject plug. All such actions should be postponed until the file read has completed. "

How do I check if maya is reading a file when a callback triggers?!

Edit:

MFileIO isReadingFile

http://help.autodesk.com/view/MAYAUL/2015/ENU/?guid=__cpp_ref_class_m_file_i_o_html > isReadingFile()