Discussion:
[Maya-Python] Can't read worldMatrix of custom Python API 2.0 node
Marcus Ottosson
2018-12-04 06:33:33 UTC
Permalink
Hi all,
I’ve been writing custom nodes in 1.0 and recently transitioned into 2.0,
but found that one of the commands or methods of retrieving a matrix MPlug
no longer works, returning a Unexpected Internal Failure, which isn’t very
descriptive. I’m hoping you can help me spot what needs to change in order
for this to work.

To reproduce:

1. Save the below to myplugin.py
2. Run the attached example

Any ideas?

Best,
Marcus

"""Can't read worldMatrix of custom node

Example:
from maya import cmds
from maya.api import OpenMaya as om

cmds.loadPlugin(r"c:\path\to\myplugin.py")

fn = om.MFnDagNode()
parent = fn.create("transform", "myTransform")
mobj = fn.create("myLocator", "myLoc", parent)
plug = fn.findPlug("worldMatrix", False)
plug = plug.elementByLogicalIndex(0)
om.MFnMatrixData(plug.asMObject()).matrix()
# RuntimeError: (kFailure): Unexpected Internal Failure

"""
from maya.api import OpenMaya as om, OpenMayaUI as omui
class MyLocator(omui.MPxLocatorNode):
name = "myLocator"
typeid = om.MTypeId(0x999999)
classification = "drawdb/geometry/custom"

@classmethod
def creator(cls):
return cls()

@classmethod
def init(cls):
pass

maya_useNewAPI = True
def initializePlugin(obj):
plugin = om.MFnPlugin(obj, "MyPlugin", "1.0", "Any")

plugin.registerNode(MyLocator.name,
MyLocator.typeid,
MyLocator.creator,
MyLocator.init,
om.MPxNode.kLocatorNode,
MyLocator.classification)
def uninitializePlugin(obj):
om.MFnPlugin(obj).deregisterNode(MyLocator.typeid)
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODD_ZfxdBAxxQcrV%3DqDdsUB8isoiL1opm6ubD7f7acv9w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Tim Fowler
2018-12-04 14:14:28 UTC
Permalink
Not sure what you're hitting. That last line gives me...

om.MFnMatrixData(plug.asMObject()).matrix()
# Result: maya.api.OpenMaya.MMatrix(((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1,
0), (0, 0, 0, 1))) #
Post by Marcus Ottosson
Hi all,
I’ve been writing custom nodes in 1.0 and recently transitioned into 2.0,
but found that one of the commands or methods of retrieving a matrix MPlug
no longer works, returning a Unexpected Internal Failure, which isn’t
very descriptive. I’m hoping you can help me spot what needs to change in
order for this to work.
1. Save the below to myplugin.py
2. Run the attached example
Any ideas?
Best,
Marcus
"""Can't read worldMatrix of custom node
from maya import cmds
from maya.api import OpenMaya as om
cmds.loadPlugin(r"c:\path\to\myplugin.py")
fn = om.MFnDagNode()
parent = fn.create("transform", "myTransform")
mobj = fn.create("myLocator", "myLoc", parent)
plug = fn.findPlug("worldMatrix", False)
plug = plug.elementByLogicalIndex(0)
om.MFnMatrixData(plug.asMObject()).matrix()
# RuntimeError: (kFailure): Unexpected Internal Failure
"""
from maya.api import OpenMaya as om, OpenMayaUI as omui
name = "myLocator"
typeid = om.MTypeId(0x999999)
classification = "drawdb/geometry/custom"
@classmethod
return cls()
@classmethod
pass
maya_useNewAPI = True
plugin = om.MFnPlugin(obj, "MyPlugin", "1.0", "Any")
plugin.registerNode(MyLocator.name,
MyLocator.typeid,
MyLocator.creator,
MyLocator.init,
om.MPxNode.kLocatorNode,
MyLocator.classification)
om.MFnPlugin(obj).deregisterNode(MyLocator.typeid)
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODD_ZfxdBAxxQcrV%3DqDdsUB8isoiL1opm6ubD7f7acv9w%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODD_ZfxdBAxxQcrV%3DqDdsUB8isoiL1opm6ubD7f7acv9w%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CALKD2Wpgj%2BgfVMAHRL3HW7T3Oz-qkoRLQxEoc6fLMxSfH5MhwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Marcus Ottosson
2018-12-04 14:26:36 UTC
Permalink
Wuw! What version of Maya is that, and what OS? I'm on Windows, Maya 2018.
Hadn't considered it might be a version or OS thing, will have a look at
that.
Post by Tim Fowler
Not sure what you're hitting. That last line gives me...
om.MFnMatrixData(plug.asMObject()).matrix()
# Result: maya.api.OpenMaya.MMatrix(((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1,
0), (0, 0, 0, 1))) #
Post by Marcus Ottosson
Hi all,
I’ve been writing custom nodes in 1.0 and recently transitioned into 2.0,
but found that one of the commands or methods of retrieving a matrix MPlug
no longer works, returning a Unexpected Internal Failure, which isn’t
very descriptive. I’m hoping you can help me spot what needs to change in
order for this to work.
1. Save the below to myplugin.py
2. Run the attached example
Any ideas?
Best,
Marcus
"""Can't read worldMatrix of custom node
from maya import cmds
from maya.api import OpenMaya as om
cmds.loadPlugin(r"c:\path\to\myplugin.py")
fn = om.MFnDagNode()
parent = fn.create("transform", "myTransform")
mobj = fn.create("myLocator", "myLoc", parent)
plug = fn.findPlug("worldMatrix", False)
plug = plug.elementByLogicalIndex(0)
om.MFnMatrixData(plug.asMObject()).matrix()
# RuntimeError: (kFailure): Unexpected Internal Failure
"""
from maya.api import OpenMaya as om, OpenMayaUI as omui
name = "myLocator"
typeid = om.MTypeId(0x999999)
classification = "drawdb/geometry/custom"
@classmethod
return cls()
@classmethod
pass
maya_useNewAPI = True
plugin = om.MFnPlugin(obj, "MyPlugin", "1.0", "Any")
plugin.registerNode(MyLocator.name,
MyLocator.typeid,
MyLocator.creator,
MyLocator.init,
om.MPxNode.kLocatorNode,
MyLocator.classification)
om.MFnPlugin(obj).deregisterNode(MyLocator.typeid)
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODD_ZfxdBAxxQcrV%3DqDdsUB8isoiL1opm6ubD7f7acv9w%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODD_ZfxdBAxxQcrV%3DqDdsUB8isoiL1opm6ubD7f7acv9w%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CALKD2Wpgj%2BgfVMAHRL3HW7T3Oz-qkoRLQxEoc6fLMxSfH5MhwQ%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CALKD2Wpgj%2BgfVMAHRL3HW7T3Oz-qkoRLQxEoc6fLMxSfH5MhwQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOB51nh7HjrSp%3DtF5jwhK-a1bqxBSd4rs6W_CMtPtfm%2BVA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Tim Fowler
2018-12-04 14:49:52 UTC
Permalink
Hmm...looks like I tried that on an unreleased version of Maya (and a Debug
version too). Just tried again in Maya 2018 and got the same error as
you. I'll take a quick look and see if I can figure out what fixed it, but
I should warn you that API fixes can sometimes be tricky to get into
Updates since those typically have to remain binary compatible.

-Tim
Post by Marcus Ottosson
Wuw! What version of Maya is that, and what OS? I'm on Windows, Maya 2018.
Hadn't considered it might be a version or OS thing, will have a look at
that.
Post by Tim Fowler
Not sure what you're hitting. That last line gives me...
om.MFnMatrixData(plug.asMObject()).matrix()
# Result: maya.api.OpenMaya.MMatrix(((1, 0, 0, 0), (0, 1, 0, 0), (0, 0,
1, 0), (0, 0, 0, 1))) #
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CALKD2WpxdzsLdBWBnhSS_cMoxMZ33v4FRQ9P%2BPjiUaB%3Dwi7xtA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Marcus Ottosson
2018-12-04 15:02:07 UTC
Permalink
Mm, I'm looking to get a matrix out of Maya 2015 and above, so a patch
would unfortunately not help me in this case. Do you know of another way of
getting hold of that matrix?
Post by Tim Fowler
Hmm...looks like I tried that on an unreleased version of Maya (and a
Debug version too). Just tried again in Maya 2018 and got the same error
as you. I'll take a quick look and see if I can figure out what fixed it,
but I should warn you that API fixes can sometimes be tricky to get into
Updates since those typically have to remain binary compatible.
-Tim
Post by Marcus Ottosson
Wuw! What version of Maya is that, and what OS? I'm on Windows, Maya
2018. Hadn't considered it might be a version or OS thing, will have a look
at that.
Post by Tim Fowler
Not sure what you're hitting. That last line gives me...
om.MFnMatrixData(plug.asMObject()).matrix()
# Result: maya.api.OpenMaya.MMatrix(((1, 0, 0, 0), (0, 1, 0, 0), (0, 0,
1, 0), (0, 0, 0, 1))) #
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CALKD2WpxdzsLdBWBnhSS_cMoxMZ33v4FRQ9P%2BPjiUaB%3Dwi7xtA%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CALKD2WpxdzsLdBWBnhSS_cMoxMZ33v4FRQ9P%2BPjiUaB%3Dwi7xtA%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBFARzXF-kfatuWq9p7w7UqNa1-60WviGFtzxbjeMMrhQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Michael Boon
2018-12-04 21:25:43 UTC
Permalink
Can you use fn.dagPath().inclusiveMatrix() ?
Post by Marcus Ottosson
Mm, I'm looking to get a matrix out of Maya 2015 and above, so a patch
would unfortunately not help me in this case. Do you know of another way of
getting hold of that matrix?
Post by Tim Fowler
Hmm...looks like I tried that on an unreleased version of Maya (and a
Debug version too). Just tried again in Maya 2018 and got the same error
as you. I'll take a quick look and see if I can figure out what fixed it,
but I should warn you that API fixes can sometimes be tricky to get into
Updates since those typically have to remain binary compatible.
-Tim
Post by Marcus Ottosson
Wuw! What version of Maya is that, and what OS? I'm on Windows, Maya
2018. Hadn't considered it might be a version or OS thing, will have a look
at that.
Post by Tim Fowler
Not sure what you're hitting. That last line gives me...
om.MFnMatrixData(plug.asMObject()).matrix()
# Result: maya.api.OpenMaya.MMatrix(((1, 0, 0, 0), (0, 1, 0, 0), (0, 0,
1, 0), (0, 0, 0, 1))) #
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CALKD2WpxdzsLdBWBnhSS_cMoxMZ33v4FRQ9P%2BPjiUaB%3Dwi7xtA%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CALKD2WpxdzsLdBWBnhSS_cMoxMZ33v4FRQ9P%2BPjiUaB%3Dwi7xtA%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/1100aff0-f149-4c2d-93e0-2c99af1e5912%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...