I wrote my first lines (with the help of SO):
import rhinoscriptsyntax as rs
obj = rs.GetObject("Select a curve", rs.filter.curve)
maxd = input("max offset: ")
a = input("first offset: ")
b = input("next offset: ")
if rs.IsCurve(obj):
i=0
while i < maxd:
rs.OffsetCurve( obj, [0,0,0], -i )
i += a
rs.OffsetCurve( obj, [0,0,0], -i )
i += b
Now I've tried to take it further by inserting a list for the offset inputs. But it seems I get an infinite loop at the end. Also, the first rs.OffsetCurve()
seems to run twice or i
is not updated with the first run of the second rs.OffserCurve()
while loop.
import rhinoscriptsyntax as rs
obj = rs.GetObject("Select a curve", rs.filter.curve)
maxd = input("max offset: ")
a = input("first offset: ")
offlist = []
while True:
b = input("next offset or 0 for exit: ")
offlist.append(b)
if b == 0:
break
if rs.IsCurve(obj):
i=0
while i < maxd:
rs.OffsetCurve( obj, [0,0,0], -i )
i = a
c = len(offlist)
k = 0
while k != c:
rs.OffsetCurve( obj, [0,0,0], -i )
i = offlist[k]
k += 1
while i < maxd:
along with i = a
at each step of the cycle and not changing maxd
nor a
at both cycles at all may cause this behavior.
Btw, I'd consider naming your variables in such way that you or any other dev could understand what's going on here just with a single look. Also, you can consider whether it is a good idea to use nested while
loops in this case.