Hi friends,
after a long time I am trying to get back into Rhino / Python. Are there any good recommended tutorials, I am struggling mostly with all the different Classes and Geometry Types in Rhino / Grasshopper / Python.
Here is a learning script with a problem, Iam trying to make a recursive “Substrate” style algorithm, simular to the build in one from Grasshopper. I got it going somehow, struggled with “rs.SpiltCurve”, had to use “rs.Coercecurve” and “rg.Interval” to reparametrize the domain and get it going.
Somehow some of my new lines get scaled (not the same length anymore as before) in the next iteration. Not every line, not in every iteration. I got no clue whats happening. Any Ideas? Sorry for this noob questions…
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import random
def substrate_line(curve_list):
rnd_sel = random.randrange(len(curve_list))
crv = rs.coercecurve(curve_list[rnd_sel],1)
crv.Domain = rg.Interval(0.0, 1.0)
rnd_pos = random.uniform(0.40, 0.6)
crv_pt = rs.EvaluateCurve(crv, rnd_pos )
crv_tan = rs.CurveTangent (crv, rnd_pos )
tan_pt = crv_pt + rs.VectorRotate(crv_tan, 90.0, [0,0,1])
my_line = rs.AddLine(crv_pt,tan_pt)
rs.ExtendCurve( my_line, 0, 1, curve_list )
split_crvs = rs.SplitCurve(crv, rnd_pos, delete_input=False)
del curve_list[rnd_sel]
curve_list.extend(( split_crvs[0], split_crvs[1], my_line ))
pt_list.append(crv_pt)
return curve_list
# input
curve_list = rs.ExplodeCurves(rectangle_curve)
pt_list = []
random.seed(seed)
# function
for i in range(count):
result = substrate_line(curve_list)