I don't know if that first argument "self" is needed...Other than
that, what is "connectType?"
The argument right before clientData should be a boolean. If
connectType isn't that there could be
problems there. Or if you're trying to have connectType detect whether
a connection has been made or
broken, then there could be an issue with that part of the code, not
with the callback itself. It might
be easier to make two callbacks, one for made connections, the other
for broken ones. That could save
a lot of time and headaches trying to figure out how to tell when a
connection/disconnection happened
before it actually has outside of the callback...
Hope that helps,
Mike
On Aug 3, 10:31 pm, Chris Gardner <[email protected]> wrote:
> hey mike,
>
> thanks for the thoughts: i have to admit to (almost) complete
> ignorance when it comes to maya API stuff, so i'm flying a little
> blind here. and i know next to nothing about c++...
>
> here's some code from my crash-setup:
>
> def prePlugDetected(self, src, dest, connectType, clientData ):
>
>     sourcePlug = src.name()
>     destPlug = dest.name()
>
>     print '-------'
>     print src.name()
>     print ['disconnected from', 'connected to'][connectType]
>     print destPlug
>     print '-------'
>
>     return True
>
> OpenMaya.MDGMessage.addPreConnectionCallback( prePlugDetected, None )
>
> curiously, i have no problem with the "addConnectionCallback" - i can
> pass an identical function to it and all is happy. but the "pre"
> version crashes hard. this makes me suspect it may be buggy.
>
> i've been passing None into *clientData, but i've tried a few
> different things there, all to no avail.
>
> thanks for your help,
> chrisg
>
> On 3 August 2011 04:09, notanymike <[email protected]> wrote:
>
>
>
>
>
>
>
> > What are you overloading the *clientData part of the function with?
> > I'm not sure how it works in python, but I had a similar problem with
> > creating
> > a MNodeMessage::addNodeDirtyCallback in c++. I had my function wanting
> > to access a pointer
> > to my node but had not overloaded the callback with that pointer. Most
> > examples put NULL into
> > the *clientData, however you might need to input "this" or "self," I
> > guess. You might also or otherwise need to
> > overload the MPlugFunction function itself like this maybe:
> > def myfunction(OpenMaya.MMessage.MPlugFunction(srcPlg,destPlg,True(or
> > False),self))
> > That is just my guess. Overall it might be preferable to use c++ for
> > callback functions
> > since it's easier to see where everything needs to go....

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to