On Fri, Jan 25, 2019, 6:10 AM Rudi Hammad <rudiham...@gmail.com> wrote:

> Hello,
> I know how to get the vertices from an edge with maya.cmds, but I am
> trying to do the same thing using the api just for learning purposes.
> This is what i have
>
> import maya.OpenMaya as OpenMaya
>
> cmds.polySphere(n="mySphere")
>
> mSel = OpenMaya.MSelectionList()
> mSel.add("mySphere")
> mDag = OpenMaya.MDagPath()
> mSel.getDagPath(0, mDag)
> mDag.fullPathName()
>
>
> mFnMesh = OpenMaya.MFnMesh(mDag)
> edge = 634
> mScpUtl = OpenMaya.MScriptUtil()
> mScpUtl.createFromInt(0)
> ref_int2 = mScpUtl.asInt2Ptr()
>
>
> vtx = mFnMesh.getEdgeVertices(edge, ref_int2)
>
> It don't get any error so I assume that the code is okey, but when I print
> vtx the result is None. I am not sure what I am missing. Any suggestion?
> thank you,
> R
>

Check out the docs for the signature of getEdgeVertices()

http://help.autodesk.com/view/MAYAUL/2018/ENU/?guid=__cpp_ref_class_m_fn_mesh_html

MStatus getEdgeVertices(int edgeId, int2 &vertexList)

This means it takes and int, and a reference to and int2 array as an output
parameter. The return value is simply the MStatus to tell you if an error
has occurred. In the python api, that can end up being represented as an
exception (if I remember right).

So after you make you call your ref_int2 has the output values you want and
you need to use MScriptUtil.getInt2ArrayItem(ref_int2, 0) to get the first
vertex value and 1 to get the second. You may be able to index directly
into ref_int2[0] but I am not at a computer to test that.



> --
> 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/bb5180b4-d122-44c6-920a-fb04d7210f6e%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/bb5180b4-d122-44c6-920a-fb04d7210f6e%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/CAPGFgA39Dh0QMuuNKNX1iMmERnPerAjvkqAPdir5-scBN2t%2Bjw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to