Grasshopper

algorithmic modeling for Rhino

the every branch should be different random,but now is the same random ,i tried different seed in every branch loop(in Bold),but it has no effects,thank you for help~~~

import random
import rhinoscriptsyntax as rs
import Grasshopper as gh
dt= gh.DataTree[int]()
Length=10000
brickLength=(2000,1500)
brickLengthList=[]
sumLength=0
LastTempLength=0
tempLength=0
sameCount=0
for i in range(4):
    p=gh.Kernel.Data.GH_Path(i)
    random.seed(i)
    while sumLength<Length:
        
        tempLength=random.choice(brickLength)
        if tempLength==LastTempLength:
            sameCount+=1
        if sameCount>=2:
            sameCount=0
            continue
    
        LastTempLength=tempLength
        brickLengthList.append(tempLength)
        sumLength+=tempLength
    dt.AddRange(brickLengthList,p)

a=dt

Views: 497

Attachments:

Replies to This Discussion

Only one FOR loop cycle is outputting anything new since your WHILE loop is always maxed out for failure to reset sumLength within the FOR loop each time:

thank you very much Nik!i have understood the error,thank you again!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service