Hi Marcus,
thanks for the reply. It's a very interesting approach!
I've tried it quickly but unfortunately it seems to not work for some
reason.
Here's my code...
import maya.OpenMaya as OM
# read the selection and get the MObject
sel_list = OM.MSelectionList()
OM.MGlobal.getActiveSelectionList(sel_list)
mesh_obj = OM.MObject()
target_obj = OM.MObject()
sel_list.getDependNode(0, mesh_obj)
# get the inMesh plug
dg_fn = OM.MFnDependencyNode(mesh_obj)
plug = dg_fn.findPlug('inMesh')
print plug.isNull()
# get the MObject from the plug
inMesh_obj = plug.asMObject()
# initialize the MFnMesh
fn_mesh = OM.MFnMesh(inMesh_obj)
# get the point array
point_array = OM.MPointArray()
fn_mesh.getPoints(point_array)
print source_point_array.length()
it works ok until the plug.asMObject() command.
I get
# Error: line 1: (kFailure): Unexpected Internal Failure
# Traceback (most recent call last):
# File "<maya console>", line 15, in <module>
# File
"c:\builds\maya-2014-w64\build\Release\runTime\Python\Lib\site-packages\maya\OpenMaya.py",
line 9233, in asMObject
# RuntimeError: (kFailure): Unexpected Internal Failure #
But if I create a cube, select the shape and run the script, then it works
fine.
I don't know where the problem comes from. Maybe it's a Maya bug, or maybe
is just something you can't do with referenced nodes.
If I try to import the object from reference and run the script again, I
still have the same error. I suspect that Maya handles reference node as
special nodes, thus it doesn't really fills in the correct data into the
inMesh attribute.
In my code I also put a call to print plug.isNull() which returns always
False (meaning that the plug is not empty), but still the plug.asMObject()
raise
an Unexpected Internal Failure
I also tried to list the attributes into the 'reference' node (the hidden
node, with the blue diamond icon) but I couldn't find anything interesting.
What do you think?
--
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/a3baa66b-3b46-4e7f-84c1-10b93c365594%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.