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 On 20 June 2015 at 00:57, Nicolas Combecave <[email protected]> wrote: > 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=True, f=True) > locScene = cmds.file(rename="%s/loc.ma" %tmpDir) > cmds.spaceLocator() > cmds.file(save=True, f=True, type="mayaAscii") > # Create master scene to reference loc > cmds.file(new=True, f=True) > cmds.file(locScene, r=True, namespace="REF") > cmds.setKeyframe('REF:locator1') > masterScene = cmds.file(rename="%s/master.ma" %tmpDir) > cmds.file(save=True, f=True, type="mayaAscii") > # Reopen loc scene, lock an attr and save > cmds.file(locScene, f=True, o=True) > cmds.setAttr("locator1.tx", l=True) > cmds.file(save=True, f=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(masterScene, f=True, o=True) > #To kill the callBack > #om.MMessage.removeCallback(cb_id) > > [image: Mixmax] > <https://mixmax.com/r/ab7cH4iCSZ2E8jEhb> Not using Mixmax yet? > <https://mixmax.com/r/ab7cH4iCSZ2E8jEhb> > > 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 > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/1434754669547-9ef55ec0-33bcdda0-ea8e1c12%40mixmax.com > <https://groups.google.com/d/msgid/python_inside_maya/1434754669547-9ef55ec0-33bcdda0-ea8e1c12%40mixmax.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAGTPGOCEQ56%3DFF9WH49j8wB%2BcjoG3sSs10wQwvYfwVGy%2BeiZaQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
