algorithmic modeling for Rhino
Hey,
I seperated a bowlike curve in several segments and want now to measure the distance between the points...
Without loops it works well for 2 points:
copts = []
bopts = []
copts = rs.AddPoints (rs.DivideCurve (uplay, sep, create_points=True, return_points=True))
bopts = rs.AddPoints (rs.DivideCurve (bolay, sep, create_points=True, return_points=True))
distance = []
tempLaenge = rs.Distance (copts [0], copts [1])
distance.append(tempLaenge)
As soon as I put it in a loop, it breaks rhino and I have to start again...
i=0
while i <= sep:
tempLaenge = rs.Distance (copts [i], copts [i+1])
distance.append(tempLaenge)
i = i+1
Thx very much! Benny
Tags:
Sounds like you might have written an infinite loop. This happens if your while loop never meets a condition in which it stops looping (i.e. i is never smaller or equal to sep). I would suggest building your logic using a for loop instead (in general really)..
solved the problem with a for loop...
for i in range (0, sep):
tempLaenge = rs.Distance (copts [i], copts [i+1])
distance.append(tempLaenge)
i+1
but I am still interested in a while solution...
thanks and regards, Benny
Not sure I understand what are you trying to do, but maybe this was a problem with the "while" loop:
while i < sep:
(less than, instead of less than or equals)
Hi Benny,
I'm just adding a few thoughts. You don't really need the (i+1) at the end of the for loop. On the other hand, it's absolutely required at the end of the while loop. Also, before starting the while loop, you should make absolutely sure that it will end. For example, you could add a test for sep to be < 1000, or any maximum number that would fit. i = i+1 can also be written as i += 1, btw.
Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com
thx everybody... I started yesterday with python so there will be more basic stuff coming ;)
regards, Benny
No worries :) While it mainly targets the use of Python within Rhino (as in, it does not cover the Grasshopper component) I would still recommend the RhinoPython primer for getting the basics down. It's a nice concise introduction to both Python and the RhinoScriptSyntax library. Best, Anders
thx Anders! like u probably already saw you are right!
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by