092612_gbernal_worm03

advertisement
import rhinoscriptsyntax as rs
def putPts():
pts = rs.GetPoints('pick pts',1) # Pick points to generate curve
curveID = rs.AddCurve(pts)
return curveID
def dividedSpline (input): # Divides the curve into gements
points = rs.DivideCurve(input, 50, True,True)
return points
def bodyShape (Spl):
#This function creates the body
for i in range (0,51):
body = rs.AddCircle(Spl[i],1.5)
def VectorFind (input):
points = rs.DivideCurve(input, 50, True,True)
vectorList = []
vectorList2 = []
param = 0
count = 0
for i in points :
# JP: I changed below codes
vector = rs.CurveCurvature(input, param)
unitizedVector = rs.VectorUnitize(vector[4])
reverseVector = -1 * unitizedVector
#print reverseVector
param += 0.02
vectorList.append (unitizedVector)
vectorList2.append(reverseVector)
return [vectorList, vectorList2]
def OffsetPt ( vectors,points):
newPts = []
for i in range(0,50) :
pt = rs.AddPoint(points[i])
vectors[i] = rs.VectorUnitize(vectors[i])
vectors[i]*=4
endPts = rs.MoveObject(pt, vectors[i])
#here I'm tring to do the
other side
#but it doesn't seem to work??
newPts1 = []
for i in range(0,50) :
pt1 = rs.AddPoint(points[i])
vectors[i] = rs.VectorUnitize(vectors[i])
vectors[i]*= -4
newPts1.append (endPts)
rs.AddLine(points[i],endPts) # if I try to do
rs.AddLine(points[i],endPts[i]) gives the error
#
Message: 'Guid' object is
unsubscriptable
result = [ newPts, newPts1, endPts]
return
[ newPts, newPts1, endPts ]
def makeNewWorm():
output = putPts()
pts = dividedSpline (output)
vect = VectorFind(output)
left = OffsetPt(vect[0], pts)
OffsetPt(vect[1], pts)
bod = bodyShape (pts)
makeNewWorm()
# JP: I changed these codes
Download