Hi Alec,

Thanks for that link, I will try to figure out what my issue is using that
function.

 However, in both examples they use "allIntersections".  My old code just
used a function "intersect"  from here:
http://download.autodesk.com/us/maya/2009help/api/class_m_fn_mesh.html#4f5a5cc3ab4834b8045239a3438930dc

If the link you gave has API1 and API2 with the same allIntersections
method, do you know what is different than the intersect method I had been
using.


On Thu, Jun 29, 2017 at 1:06 PM, Alec Fredericks <alec.frederi...@gmail.com>
wrote:

> Hey Mat,
> It looks like you might be mixing API 1.0 and 2.0. Take a look at t more
> updated version of the API example here:
> https://knowledge.autodesk.com/search-result/caas/
> CloudHelp/cloudhelp/2016/ENU/Maya-SDK/files/GUID-767D6572-
> 552D-4D94-90E2-AE626F276D37-htm.html
>
> It breaks down the API 1.0 & 2.0 differences. Your example above shows
> what is in the 1.0 API code, while a version of allIntersections with fewer
> arguments is in the 2.0 code.
>
> Alec
>
>
> On Tuesday, June 20, 2017 at 12:33:31 PM UTC-7, Mat wrote:
>>
>> 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 python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/python_inside_maya/906c1fb1-7d4d-4851-99c1-
> fb52ef2475e3%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/906c1fb1-7d4d-4851-99c1-fb52ef2475e3%40googlegroups.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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CADiWwnTmObippcEKATJNZSDy2SHD1%3DzSgfj_CwHQPfA5xgBJ7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to