import rhinoscriptsyntax as rs
import math
points=[]
n=10
for i in range(0, n):
x = math.sin(i)
y = math.cos(i)
z = i
pt = rs.AddPoint(x,y,z) ## add point using the equation
points.append(pt)
crv = rs.AddInterpCurve(points) ## interpolate crv along the list of points
crvDomain = rs.CurveDomain(crv) ## get the domain of curve U value
points = []
m=100 ## define number of segments for new spiral
for i in range(0,m+1): ## FOR LOOP for 'm' segments, segment for a new spiral
i = ((crvDomain[1]-crvDomain[0])/m)*i ## translate 'm' to curve domain range
uValue = rs.EvaluateCurve(crv,i)
pt = rs.AddPoint(uValue)
crvF = rs.CurvePerpFrame(crv,i) ## rs.CurvePerpFrame() returns list of [origin,xAxis,yAxis,zAxis]
vect = crvF[2] ## use yAxis of perpendicular frame
vect = rs.VectorScale(vect, 0.1) ## too big? scale it
vect = rs.VectorRotate(vect, 90*(m/n)*i, crvF[3])## rotate according to steps -> get new vector
pt = rs.MoveObject(pt,vect) ## move the pt on the U value based on new vector
points.append(pt)
crv = rs.AddInterpCurve(points)
another way to do the same - by moving along the X axis and rotating along the Z axis
ReplyDeletelead = rs.GetCurveObject(message = "please select curve")
steps = 100
stepSize = 1/steps
dist = 0.1
rotation = 30
for t in range(steps+1):
###normalize the curve t parameter to fit different curve length
par = rs.CurveParameter(lead[0],t*stepSize)
frame = rs.CurvePerpFrame(lead[0],par)
origin = frame[0]
xAxis= frame[1]
yAxis = frame[2]
zAxis = frame[3]
pt =rs.AddPoint(origin)
scaledXAxis=rs.VectorScale(xAxis,dist)
rs.MoveObject(pt,scaledXAxis)
rs.RotateObject(pt,origin,rotation*t,axis=zAxis)