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.
On Tuesday, April 14, 2020 at 5:07:05 PM UTC+2, Peter Jemstedt wrote:
>
> 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
>
>
>
--
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/d98d2c50-2110-4da2-86a2-c5bcc1882082%40googlegroups.com.