getting points form MFloatPointArray?

getting points form MFloatPointArray?

bmagner888
Enthusiast Enthusiast
1,066 Views
2 Replies
Message 1 of 3

getting points form MFloatPointArray?

bmagner888
Enthusiast
Enthusiast

Hi, I need to convert an OpenMaya result into usable point data for python (pymel) usage.

from this function:

hit = fnMesh.allIntersections(raySource, rayDir, faceIDs, triIDs, IDsSorted,
worldSpace, maxParam, testBothDirections,
accelParams, sortHits, hitPoints,
hitRayParams, hitFaces, hitTris, hitBarys1,
hitBarys2, tolerance)

 

 

print(hitPoints)

>> [<maya.OpenMaya.MFloatPointArray; proxy of <Swig Object of type 'MFloatPointArray *' at 0x000001ACCFFE0750>

This is useless.  I need points:
points = [(p0[0], p0[1],p0[2]), (p1[0], p1[1],p1[2])...]

How do i get points from the MFloatPointArray?

 

Thanks.

0 Likes
Accepted solutions (1)
1,067 Views
2 Replies
Replies (2)
Message 2 of 3

bmagner888
Enthusiast
Enthusiast

i tried this just to see if I could get any elements of the array, but the results are just as useless.

for i in range(0,10):
    print(hitPoints[i])

 

<maya.OpenMaya.MFloatPoint; proxy of <Swig Object of type 'MFloatPoint *' at 0x000001ACDE2B7210> >
<maya.OpenMaya.MFloatPoint; proxy of <Swig Object of type 'MFloatPoint *' at 0x000001ACDE2B7240> >
<maya.OpenMaya.MFloatPoint; proxy of <Swig Object of type 'MFloatPoint *' at 0x000001ACDE2B4120> >
<maya.OpenMaya.MFloatPoint; proxy of <Swig Object of type 'MFloatPoint *' at 0x000001ACDE2B7210> >
<maya.OpenMaya.MFloatPoint; proxy of <Swig Object of type 'MFloatPoint *' at 0x000001ACDE2B7240> >
<maya.OpenMaya.MFloatPoint; proxy of <Swig Object of type 'MFloatPoint *' at 0x000001ACDE2B4120> >
<maya.OpenMaya.MFloatPoint; proxy of <Swig Object of type 'MFloatPoint *' at 0x000001ACDE2B7210> >
<maya.OpenMaya.MFloatPoint; proxy of <Swig Object of type 'MFloatPoint *' at 0x000001ACDE2B7240> >
<maya.OpenMaya.MFloatPoint; proxy of <Swig Object of type 'MFloatPoint *' at 0x000001ACDE2B4120> >
<maya.OpenMaya.MFloatPoint; proxy of <Swig Object of type 'MFloatPoint *' at 0x000001ACDE2B7210> >

0 Likes
Message 3 of 3

bmagner888
Enthusiast
Enthusiast
Accepted solution

Ok, I solved it, and the solution is pretty simple--which makes it really annoying that there isn't better documentation on this...

points = []
for i in range(0,hitPoints.length()):
    pt = om.MFloatPoint(hitPoints[i])
    points.append((pt.x, pt.y,pt.z))

0 Likes