MPxNode Plug-in Crashing Maya

164 views
Skip to first unread message

Alec Fredericks

unread,
Oct 30, 2017, 2:28:18 PM10/30/17
to Python Programming for Autodesk Maya
Hi there.
I wanted to finally start writing plug-ins for Maya using Python. To start, I created a template for myself that just takes a matrix as an input and outputs the same matrix -- basically, a compute devoid of any computing.
When I plug the matrix of one object into it and connect the output of the matrix (via a decompose matrix node for the time being -- I'll output constituent transform data later) to the translation of another object, I get the expected output. Object 2 follows object 1.

The problem is that after wiggling object 1 around for a little bit, Maya crashes eventually, giving me an error similar to this: undo of command caused reentrant call to undo manager

I guess it could be that I need to add some undo code in there.

I threw my code up on pastebin if anyone has a moment to look at it to see what I did wrong. I'll keep poking at it, too, and maybe adding a debugger to the mix.



Thanks,
Alec

Ravi Jagannadhan

unread,
Oct 30, 2017, 2:40:46 PM10/30/17
to python_in...@googlegroups.com
What's your crash's stack trace?

--
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 python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/7ea5ece7-a6c2-4c23-92a4-b300cbf926d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Where we have strong emotions, we're liable to fool ourselves - Carl Sagan

Alec Fredericks

unread,
Oct 30, 2017, 2:45:48 PM10/30/17
to Python Programming for Autodesk Maya
Sorry I didn't provide that. Once I get home tonight, I'll dig that up and post it, too.

Chad Vernon

unread,
Oct 30, 2017, 3:43:06 PM10/30/17
to Python Programming for Autodesk Maya
Try getting rid of some of your constructors which are unnecessary:

Instead of 
matrixOutDataHandle = om.MDataHandle(pDataBlock.outputValue(TransformHistory.matrixOutputAttribute))
just write
matrixOutDataHandle = pDataBlock.outputValue(TransformHistory.matrixOutputAttribute)

Instead of 
inputMatrix = om.MMatrix(matrixInDataHandle.asMatrix())
just write
inputMatrix = matrixInDataHandle.asMatrix()

Chad Vernon

unread,
Oct 30, 2017, 3:46:23 PM10/30/17
to Python Programming for Autodesk Maya
You also need to set the plug or data handle clean.

matrixOutDataHandle.setClean()
or 
pDataBlock.setClean(pPlug)

Alec Fredericks

unread,
Nov 6, 2017, 12:59:27 AM11/6/17
to Python Programming for Autodesk Maya
Hi. After trying a little bit to sort this out, I still can't figure out why it's crashing. It's choking on foundation.dll and I've discovered that it's sometimes a permissions error that causes it.
Anyway, I've attached the crash log and dump files. I've also updated the plug-in template a little so it represents the latest.

Thanks,
Alec



On Monday, October 30, 2017 at 11:40:46 AM UTC-7, Ravi Jagannadhan wrote:
MayaCrashLog171105.2152.log
MayaCrashLog171105.2152.dmp

Balazs Pataki

unread,
Nov 6, 2017, 9:59:30 AM11/6/17
to Python Programming for Autodesk Maya
You are incorrectly creating matrix attributes:

eg.: The input matrix is created as 
TransformHistory.matrixInputAttribute = matrixAttributeFn.create('inMatrix', 'inMatrix', om.MFnMatrixData.kMatrix)
but it should be  
TransformHistory.matrixInputAttribute = matrixAttributeFn.create('inMatrix', 'inMatrix', om.MFnMatrixAttribute.kDouble) # or om.MFnMatrixAttribute.kFloat depends what you want
(Also your output matrix suffers from the same problem)

The last parameter is just an enum value(in this case om.MFnMatrixData.kMatrix which holds the value 5 and om.MFnMatrixAttribute.kDouble what equals to 1) but since we don't know the underlying implementation is, putting in undocumented values is questionable.

But how do we know that what values are supported? It's in the Python API documentation or also in the C API.

Alec Fredericks

unread,
Nov 6, 2017, 11:53:59 PM11/6/17
to Python Programming for Autodesk Maya
Wow, I think that did it! Thanks for the suggestion, Balazs. I've been trying to get it to crash but so far so good. I think your tip, and probably the other suggestions by Chad, stabilized everything. I'll read the docs more clearly next time.

Alec
Reply all
Reply to author
Forward
0 new messages