On Thu, Sep 25, 2008 at 12:51 AM, MaxtorAG <[EMAIL PROTECTED]> wrote:
>
> Problem:
> 1. I did not know how to construct the MPlug with function (MObject,
> Attribute) (there is no thisObject() function in python API?)

Use MPxNode::thisMObject().

> 2. When I create the node, everything works. I get the correct integer
> number for my debugging (0 for both). As soon as I connect anything to
> those message atts, I get crash. Even without that, when I after
> creation try to create new scene, I get crash. If I comment out the
> connection checking functions, nothing crashes.

The purpose of a node's compute() method is to compute the value of a
requested output attribute using the values of one or more of the
node's input attributes. Maya will call your node's compute() whenever
it needs the value of one of your node's attributes which may have
changed since it was last retrieved. Note that this is true not just
for attributes which you have added to your node, but also for
standard attributes which Maya provides for every node.

In your compute() you are executing your code every time it is called,
regardless of the attribute whose value is being requested.
Furthermore, your code is not computing anything, by which I mean that
it never sets the datablock values for any output attributes. So Maya
is calling your compute() to get values for various attributes, but
you are not providing any. I'm guessing that that is what is causing
the crash, though there are other possibilities as well.

The code that you have in your compute() just seems to be checking to
be sure that the correct types of nodes are connected to the plugs.
The compute() is not the right place to do that. If you really want to
be sure that only the correct type of node is connected, then provide
an override for the MPxNode::legalConnection() method. Do the check
there and refuse the connection if it is to the wrong node type.

As for the compute() itself, the question you must ask yourself is:
what are the outputs and what are the inputs that you need to compute
each of those outputs?

-- 
-deane

--~--~---------~--~----~------------~-------~--~----~
Yours,
Maya-Python Club Team.
-~----------~----~----~----~------~----~------~--~---

Reply via email to