Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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