MMeshIntersector in Python API 2.0

492 views
Skip to first unread message

Angelo

unread,
Nov 6, 2017, 3:26:36 PM11/6/17
to Python Programming for Autodesk Maya
Has anyone had any success using MMeshIntersector in python api 2.0?

import maya.api.OpenMaya as om
import pymel.core as pm

obj = pm.polyCube(ch=0)[0]
path = om.MGlobal.getSelectionListByName(obj.name()).getDagPath(0)
matrix = path.inclusiveMatrix()
node = path.node()

intersector = om.MMeshIntersector()
intersector.create(node, matrix)

This bit of code gives me a RuntimeError:
"More keyword list entries (12) than format specifiers (2)"


mnhan

unread,
Nov 10, 2017, 12:07:42 PM11/10/17
to Python Programming for Autodesk Maya
I had the same problem, I also tried mesh.extendToShape().node() but got the same RuntimeError.
could not figure out why, I end up using MFnMesh.getClosestPoint()

Angelo

unread,
Nov 10, 2017, 12:33:12 PM11/10/17
to Python Programming for Autodesk Maya
So I'm convinced this is a Maya bug. I was able to partially create it. I figured out you have to get the path to the shape node instead of the transform. Maya is usually able to handle this but it doesn't for MMeshIntersector for some reason. What still doesn't work is the second parameter for the MMeshIntersector.create(). For some reason, it doesn't want to accept the MMatrix. Its not in the documentation but I found out you don't have to feed in the matrix to create the MMeshIntersector object.

import maya.api.OpenMaya as om
import pymel.core as pm

obj = pm.polyCube(ch=0)[0].getShape()
path = om.MGlobal.getSelectionListByName(obj.name()).getDependNode(0)

intersector = om.MMeshIntersector()
intersector.create(node)

This bit of code should work. The obj's matrix isn't taken into account, again because I think its bugged.

Meng-Han Ho@Gmail

unread,
Nov 10, 2017, 9:51:58 PM11/10/17
to python_in...@googlegroups.com
You are right, creation without feeding matrix to intersector will work.
But, the same Runtime error will still happen when you run
intersector.getClosestPoint(referencePnt, maxDist)

--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/axX7W8imeEU/unsubscribe.
To unsubscribe from this group and all its topics, 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/4894dd0b-6c07-4c53-914d-d04317d1cc2a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages