MSceneMessage addConnectionFailedCallback odd behaviour ?

47 views
Skip to first unread message

Nicolas Combecave

unread,
Jun 19, 2015, 6:57:55 PM6/19/15
to python_in...@googlegroups.com
Hi,

I’m confused by the MSceneMessage.addConnectionFailedCallback behaviour...

Basically I try to create a callback for monitoring failed connections during reopening of a file containing references...

Here is the code snippet for repro:

MSceneMessage addConnectionFailedCallback
                  
import maya.OpenMaya as om
import maya.cmds as cmds
import os
tmpDir = os.environ["TMPDIR"]
# Create basic scene to be referenced
cmds.file(new=Truef=True)
locScene = cmds.file(rename="%s/loc.ma" %tmpDir)
cmds.spaceLocator()
cmds.file(save=Truef=Truetype="mayaAscii")
# Create master scene to reference loc
cmds.file(new=Truef=True)
cmds.file(locScener=Truenamespace="REF")
cmds.setKeyframe('REF:locator1')
masterScene = cmds.file(rename="%s/master.ma" %tmpDir)
cmds.file(save=Truef=Truetype="mayaAscii")
# Reopen loc scene, lock an attr and save
cmds.file(locScenef=Trueo=True)
cmds.setAttr("locator1.tx"l=True)
cmds.file(save=Truef=True)
# Create callBack
def cb(srcPlug,destPlug,srcPlugName,dstPlugName,clientData):
    print "callback triggered"
    print srcPlug
    print destPlug
    print srcPlugName
    print dstPlugName
    print clientData
cb_id = om.MSceneMessage.addConnectionFailedCallback(cb"noData")
# Reopening master scene, shouldn't callback trigger??
cmds.file(masterScenef=Trueo=True)
#To kill the callBack
#om.MMessage.removeCallback(cb_id)
Mixmax Not using Mixmax yet?

Maybe I don’t get it right, because the callback is not triggered in this scenario.

To investigate, I tried to insert directly some code into the masterScene ma:
connectAttr “aFake.plug” “REF:locator1.tx”;

saving and reopening, and then the callback is executed:
callback triggered
<maya.OpenMaya.MPlug; proxy of <Swig Object of type 'MPlug *' at 0x7d51c90> >
<maya.OpenMaya.MPlug; proxy of <Swig Object of type 'MPlug *' at 0x7d51ba0> >
this.plug
REF.tx
noData

So it must be that failing connections on a reference node placeHolder is not caught by the callback.
But as we can see in the details printed by the callback, dstPlugName seems incorrect.

Has anyone used this callback in this scenario?
Didn’t find much infos on google…

Any hint/suggestions would be very welcome.

Nicolas

owen burgess

unread,
Jun 22, 2015, 8:54:38 AM6/22/15
to python_in...@googlegroups.com
Hi Nico,

the callback is only triggered during file read, and for the following conditions (this is from the docs page):
  • inability to find the specified node or attribute names, or
  • a conflicting existing connection
So if during file load Maya cannot resolve a connectAttr command because one of the attribute names is invalid, eg : "aFake.plug", then Maya will print an error message in the Script Editor, and your function will be called.

But In the scenario you present here, there is nothing preventing Maya from connecting the animation curve nodes to the placeHolderList array attribute. Defer loading the referenced file "loc.ma" and you'll see 10 connections to REFRN.placeHolderList, which is expected

After the reference has been loaded, Maya will attempt to transfer connections to & from REFRN.placeHolderList to attributes on refernced nodes, according to the entries in the reference edits list. It appears that the callback does not monitor this task and therefore any edit of type "connectAttr" that cannot be resolved will not trigger the callback.

That doesn't answer the original question of how best to monitor failed reference edits, but I hope it helps clear up why the callback is not triggered.

Did you notice that an unresolved "connectAttr" edit will leave the node connected to the reference node's placeHolderList ? Perhaps you could scan the connections to & from the placeHolderList to get an idea of which connections have failed ?

Owen

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/1434754669547-9ef55ec0-33bcdda0-ea8e1c12%40mixmax.com.
For more options, visit https://groups.google.com/d/optout.

Nicolas Combecave

unread,
Jun 22, 2015, 4:35:45 PM6/22/15
to python_in...@googlegroups.com
Hi Owen,

My first reaction was that as the reference edits are *read* from the file, they would be catched by the callback...
But it seems that referenceEdits are considered to be outside the scope of fileIO, so it kind of makes sense now.

The purpose of trying to catch failed connectAttr referenceEdits via te callback was to bypass the inspection of placeHolder remaining connections after reference load, or to query them via the reference related commands...

Anyway, your input is appreciated Owen...
Thanks.

Nicolas


Reply all
Reply to author
Forward
0 new messages