API: Best way to get an MPointArray of vertex positions from selected components

501 views
Skip to first unread message

Jesse Capper

unread,
Sep 27, 2012, 4:42:34 PM9/27/12
to python_in...@googlegroups.com
I'm very new to maya's API so this may be an obvious question.

Given an MObject of selected components, what is the most efficient way of getting an MPointArray of their positions? For all points on an object I'm using MFnMesh.getPoints(MPointArray), but I haven't been able to find a function that fills an MPointArray from a component set. I was hoping MFnSingledIndexedComponent would have something :/. Is iterating over the components with MItMeshVertex the only way?

Chad Vernon

unread,
Sep 27, 2012, 5:11:08 PM9/27/12
to python_in...@googlegroups.com
The fastest would probably be just to get the full point array and loop through and pick out the ones you want.  There's no one function to call to get a subset of points.

On Thu, Sep 27, 2012 at 1:42 PM, Jesse Capper <jesse....@gmail.com> wrote:
I'm very new to maya's API so this may be an obvious question.

Given an MObject of selected components, what is the most efficient way of getting an MPointArray of their positions? For all points on an object I'm using MFnMesh.getPoints(MPointArray), but I haven't been able to find a function that fills an MPointArray from a component set. I was hoping MFnSingledIndexedComponent would have something :/. Is iterating over the components with MItMeshVertex the only way?

Message has been deleted

Jesse Capper

unread,
Sep 27, 2012, 8:45:56 PM9/27/12
to python_in...@googlegroups.com
Great, thanks.

Chad Vernon

unread,
Sep 27, 2012, 8:52:08 PM9/27/12
to python_in...@googlegroups.com
I usually set the size of the array first and then fill it up so it's not constantly resizing it to add more elements.
Reply all
Reply to author
Forward
0 new messages