I am trying to convert some old code to start working in newer maya. It
seems the API has changed as it doesnt recognize intersect as a method
anymore. (
http://download.autodesk.com/us/maya/2009help/api/class_m_fn_mesh.html#4f5a5cc3ab4834b8045239a3438930dc
)
I would like to simply have a start position and direction. Then check if
that vector hits an object/polygon.
Below is how the code used to be structured
dag = nameToDag(mesh_name)
meshFn = om.MFnMesh()
meshFn.setObject( dag )
#This is the Ray being shot
raySource = om.MPoint(source[0])
rayDirection = om.MVector(source[1])
pointsValue = om.MPointArray()
polygonIdsValue = om.MIntArray()
spaceValue = 4
toleranceValue = 0.01
intersectionPoints = om.MFloatPointArray()
ret = om.MFnMesh.intersect(meshFn, raySource, rayDirection.normal(),
pointsValue, toleranceValue, spaceValue, polygonIdsValue )
Now I tried replacing it with:
meshFn.allIntersections( raySource, # raySource -
where we are shooting the ray from.
rayDirection, # rayDirection -
the direction in which we are shooting the ray.
None, # faceIds - here,
we do not care if specific faces are intersected)
None, # triIds - here,
we do not care if specific tri's are intersected)
False, # idsSorted -
here, we do not need to sort the faceId's or triId's indices.
om.MSpace.kTransform, # coordinate space - the
mesh's local coordinate space.
float(9999), # the range of the
ray.
False, #
testBothDirections - we are not checking both directions from the raySource
None, # accelParams -
this object is not applicable here.
False, # sortHits - we do
not need to sort the intersection points along the ray.
intersectionPoints, # hitPoints - the
array of points which have been intersected.
None, # hitRayParams -
we do not need any parametric distances of the points along the ray.
None, # hitFaces - we do
not need the id's of the faces intersected.
None, # hitTriangles -
we do not need the id's of the triangles intersected.
None, # hitBary1s - we
do not need the barycentric coordinates of the points within the triangles.
None, # hitBary2s - we
do not need the barycentric coordinates of the points within the triangles.
toleranceValue # tolerance - a
numeric tolerance threshold which allow intersections to occur just outside
the mesh.
based on the API example from here (
http://help.autodesk.com/view/MAYAUL/2015/ENU/?guid=__files_GUID_767D6572_552D_4D94_90E2_AE626F276D37_htm
)
but it is giving the error:
# Error: TypeError: file <maya console> line 100: function takes at most 11
arguments (17 given) #
Can anyone give a basic working example with a plane, or explain what the
problem is?
Thanks
--
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/CADiWwnRuk-n9gL6%2BFEY48J%3D3Bydnz6dbpar66G_Puy_peb8VOQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.