@lepli wrote:
Hi,
I'm writing a code to generate simple branch structure in grasshopper.
I use couple of 'global list variable' to store lines and points.
The list for points is fine, but the list for curves only stores 'null'.
Please see the screenshot and code below. Thanks for your help in advance.
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import random as rndif go :
wanderpt (attr, walkingDist) checkdistandaggr(attr, boundary, min_dist)
else:
aggr = []
lines = []wander_pt = rg.Curve.PointAt(boundary, rnd.uniform(0, 1)) aggr.append(attr)
a = wander_pt
b = lines
c = aggrdef wanderpt (attr, scaleDist) :
global wander_ptvec = rs.VectorCreate(attr, wander_pt) vec = rs.VectorUnitize(vec) vec = rs.VectorScale(vec, scaleDist) ang = rnd.uniform(-75, 75) vec = rs.VectorRotate(vec, ang, rs.VectorCreate( [0,0,1], [0,0,0])) wander_pt = rs.VectorAdd(vec, wander_pt)
def checkdistandaggr(attr, boundary, m_dist) :
global wander_pt global aggr global lines for i in range(len(aggr)): dist = rs.Distance(wander_pt, aggr[i]) if dist < m_dist: lines.append(rs.AddLine(wander_pt, aggr[i])) aggr.append(wander_pt) wander_pt = rg.Curve.PointAt(boundary, rnd.uniform(0, 1)) break
Posts: 1
Participants: 1