here’s what i did (and hey, realize i’m a beginner too… there are some real writers around here though that will really help you if you want to get into it)
import rhinoscriptsyntax as rs
import math
these two lines are saying 'hey python, i’m going to be using a couple of modules in this script… one is rhino specific commands (the stuff that starts with rs.) and the other is math
ptlist = []
here i’ve created an empty list… it’s like a bucket that will catch all the points created in the script.
cPt= rs.coerce3dpoint([0,0,0])
this is making a point object… cPt stands for centerpoint and it’s the point which will be used later for rotating.
angle = math.radians(15)
angleD = 15
these are the angles used in the script… they’re the same thing… angleD is 15º and the other one is converted to radians… most of the rhino stuff needs to be told angles in degrees while the python stuff works in radians.
x=0
y=1
z=0
this is how you assign variables … pretty easy.
ptlist.append(rs.AddPoint (x,y,z))
this might be bad practice? doing two things at once… the thing in parenthesis is a rhino command saying 'add a point at this location (x,y,z) which were the variables set earlier… that point is dropped into the list created earlier… so ptlist now has one object inside it.
x= math.tan(angle)*y
this is the first calculation… x will no longer be 0 after this (as it was earlier in the script)… soh cah toa
(tangent = opposite/adjacent)
for i in range(1,102):
y= x/math.sin(angle)
x= math.tan(angle)*y
point=rs.AddPoint(x,y,z)
rs.RotateObject(point,cPt,-angleD * i)
ptlist.append(point)
this is a loop… the first time it goes through… i will be equal to 1… the next time, i will be equal to 2 …etcetc until the end of the range has been met… the range here is from 1 to 102
the new x and y coordinates are calculated then a point is created with the new numbers… that point is then rotated by the amount of our angle times whichever cycle of the loop we’re on… if we’re on cycle 10 then it’s going to rotate 150º…
that point is then dropped into the list and the loop repeats…
rs.AddInterpCurve(ptlist)
so once the loop is finished, the script drops back down to this level of indentation… this line tells it to take all the points which were collected (and they’re generally collected in the order they’re created in) and have an interpolated curve drawn through them.
the end.