Get the locations of points on a curve, pointPosition(), Maya, Python

Posted by:

So Autodesk documentation on this is sparse and a bit inaccurate.

In order to get this function to work you need to separate out the parameters at the ‘.’ (something I am finding is a common thread among many of maya’s library functions)

This is the way to do it:

  1. selectedObject = = True)
  2. #Note that the .cv[0] is separated out from the variable, also note that the .cv index starts at 0, not at 1 as the maya documentation would lead you to believe
  3. pointA = cmds.pointPosition('[0]' % selectedObject[0])
  4. pointB = cmds.pointPosition('[1]' % selectedObject[0])
  5. print('pointA is: ' + str(pointA))
  6. print('pointB is: ' + str(pointB))


Note that this won’t work:

pointA = cmds.pointPosition(str([1]), world = True)

Because the .cv[1] is not separated out.

This however will work:

pointA = cmds.pointPosition(str(selectedCurve) + ‘.cv[0]’, world = True)#this is just another way of converting a variable to a string.

Because the .cv[1] is separated out.


Also as mentioned in the code, the index for the cv points starts as [0].  Autodesk documentation indicates that it starts a [1].

  Related Posts

You must be logged in to post a comment.