Custom plugin node crashes, can't figure out why

99 views
Skip to first unread message

Peter Jemstedt

unread,
Apr 14, 2020, 11:07:05 AM4/14/20
to Python Programming for Autodesk Maya
Hello everyone!

I'm trying to create my first custom MpxNode for Maya, and the node keeps crashing on me.
The node takes two inputs and has an integer attribute.
The integer attribute selects which output should take the first input, all the other outputs will take the second input. Basically, it's a node that would toggle (for example visibility) on one out of many objects, while off on any other.

Now, I also wanted the node to be more flexible, so you could toggle other types of attributes, like, one object gets a certain vector or color or whatever.
So the two inputs and the output are generic attributes.

Using Api 2.0, cuz it feels right, if that could be anything.

My code as it lewks right now:
https://pastebin.ubuntu.com/p/xbCwP85dk6/

With some debuggy prints, I've noticed it can parse the whole compute function without crashing, it's after that it just crashes, no errors.

/Peter


Peter Jemstedt

unread,
Apr 15, 2020, 6:17:40 AM4/15/20
to Python Programming for Autodesk Maya
Well, I found how not to get it to crash!

In my loop over the multi indexes, which I've now turned into a
for m_id in range(multi_output_handle.__len__():

where before, I got every child output handle with:
for m_id in multi_indices:
   
m_child = plug.selectAncestorLogicalIndex(m_id)
   
output_handle = data.outputValue(m_child)

I now get the handle using:
for m_id in range(multi_output_length):
    multi_output_handle
.jumpToLogicalElement(m_id)
    output_handle
= multi_output_handle.outputValue()

So, apparently Maya didn't like me trying to get the MDataHandle of the output[0], that's what caused the crashing when i tried setting its value.
Instead, I get the MArrayDataHandle, iterate through its length, and get the current output handle by using .jumpToLogicalElement.

Now I just have to figure out why it always outputs zero-values, it can't get the inputs as anything other than zero or a list of zero.

Peter Jemstedt

unread,
Apr 15, 2020, 7:04:14 AM4/15/20
to Python Programming for Autodesk Maya
Even better, since I'm not treating the data from the active and passive handles, I could just set the output using setMObject() with the data from the input handle:

for m_id in range(multi_output_length):
 multi_output_handle
.jumpToLogicalElement(m_id)
 output_handle
= multi_output_handle.outputValue()


 
if m_id == selector_value:
 use_handle
= active_handle
 
else:
 use_handle
= passive_handle

 output_handle
.setMObject(use_handle.data())


On Tuesday, April 14, 2020 at 5:07:05 PM UTC+2, Peter Jemstedt wrote:
Reply all
Reply to author
Forward
0 new messages