Skip to content

Instantly share code, notes, and snippets.

@danvas
Created September 16, 2011 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danvas/1223185 to your computer and use it in GitHub Desktop.
Save danvas/1223185 to your computer and use it in GitHub Desktop.
To find vector between curve points.
def vect(curv, pt2 = 1, pt1 = 0):
"""Returns a vector from two cvs on a curve. The argument curv is a PyMEL instance or string. For example:\vect('curve1', pt2 = 5, pt1 = 2) gives you a direction (i.e. vector) from cv[2] to cv[5] in curve1"""
if type(curv) == str:
curv = pm.ls(curv)[0]
if curv.getShape().numCVs() <= pt2:
print('\n!! There are {0} cvs. Make sure your pt2 value is less than {0}. !!'.format(curv.getShape().numCVs()))
else:
return [curv.cv[pt2].getPosition()[0] - curv.cv[pt1].getPosition()[0],
curv.cv[pt2].getPosition()[1] - curv.cv[pt1].getPosition()[1],
curv.cv[pt2].getPosition()[2] - curv.cv[pt1].getPosition()[2]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment