Thanks for your reply! I still have a question about outPoint. How do
you get that initial value?

On May 18, 11:53 am, Kamil Hepner <[email protected]> wrote:
> If you want to use maya python API, try this:
>
> import maya.OpenMaya as om
>
> om.MGlobal.clearSelectionList()
>
> om.MGlobal.selectByName('pCube1')
>
> sList = om.MSelectionList()
>
> om.MGlobal.getActiveSelectionList(sList)
>
> item = om.MDagPath()
>
> sList.getDagPath(0, item)
>
> item.extendToShape()
>
> fnMesh = om.MFnMesh(item)
>
> inPoint = om.MPoint(0, 2, 3)
>
> outPoint = om.MPoint(0.0, 0.0, 0.0)
>
> worldSpace = om.MSpace.kWorld
>
> fnMesh.getClosestPoint(inPoint, outPoint, worldSpace)
>
> print outPoint[2]
>
> Or you can use simpler pymel function getClosestPoint(), from Mesh class,
> it's depend of what you want.
>
> Cya!
>
> 2012/5/18 Serena Xu <[email protected]>
>
>
>
>
>
>
>
> > I would like to get the information of closest vertex on a cube to the
> > given point. I'm unsure of the type of argument I'm suppose to put as
> > the second argument of the getClosestPoint()
> > Please help!
>
> > def test():
> >    cube = cmds.polyCube()
>
> >    pointInfo = om.MPointOnMesh()
> >    point = om.MPoint( 0, 8, 3)
> >    cubeWS = om.MMeshIntersector()
> >    result = cubeWS.getClosestPoint (point, pointInfo, 10)
> >    position = [(result.x), (result.y), (result.z)]
>
> >    return (position)
>
> > --
> > view archives:http://groups.google.com/group/python_inside_maya
> > change your subscription settings:
> >http://groups.google.com/group/python_inside_maya/subscribe

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to