Created
September 16, 2011 21:20
-
-
Save danvas/1223185 to your computer and use it in GitHub Desktop.
To find vector between curve points.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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