import rhinoscriptsyntax as rs
point1 = rs.GetPoint("Click First corner of rectangle")
point2 = rs.GetPoint("Click Second corner of rectangle")
point3 = rs.GetPoint("Click Third corner of rectangle")
plane = rs.PlaneFromPoints(point1, point2, point3)
baserectangle = rs.AddRectangle(plane, point1, point3)
offsetrectangle = rs.OffsetCurve(baserectangle, [0,0,0], 0.5)
rs.DeleteObject(baserectangle)
vertices = rs.PolylineVertices(offsetrectangle)
vertices.pop(0) #remove 'duplicate' start point/end point
for vert in vertices:
rs.AddCircle(vert, 5) #adds circle with radius 5 at each corner of the offset curve
It’s a loop. This is an important computer program structure that allows one to apply an operation or a series of operations to each of the items in a list, one at a time.
In case you fall asleep before getting to it in the wikipedia item, this is specifically an example of an “Iterator-based for-loop”. That means that eg: vertices must be an array or structure (not a fundamental type) type that contains implicit knowledge of how many items it contains to iterate over. The type of vert is automatically defined as the same type as each entry in vertices and becomes the variable that the work defined in the loop is performed upon.
Syntactically it’s very intuitive and makes for easy reading.
Yeah, that article was perhaps too detailed. Here is a nicer, simpler one that just covers Python’s For loop structure. OK, it’s aimed at kids, but as beginners, we’re all kids.
Boy! When I was a pre-teen I seriously doubt that I knew what words like “iterate”, “traverse”, etc meant in general, much less in the programming sense.
Of course that was because there was no such thing as computers and programming in civilian life until I got to college.