Difference between revisions of "workshop01G5:Codefarm"

From CECO
Jump to: navigation, search
Line 18: Line 18:
  
 
import rhinoscriptsyntax as rs
 
import rhinoscriptsyntax as rs
 +
 
import random  
 
import random  
import math
+
 
 
import scriptcontext
 
import scriptcontext
  
Line 41: Line 42:
 
             print rs.AddPoint(strPt)
 
             print rs.AddPoint(strPt)
 
strPts=[]
 
strPts=[]
 +
 
strPt1=rs.AddPoint((0,0,0))
 
strPt1=rs.AddPoint((0,0,0))
 +
 
vec1=rs.VectorCreate((1,0,0),(0,0,0))
 
vec1=rs.VectorCreate((1,0,0),(0,0,0))
 +
 
strPt=rs.PointAdd(strPt1,vec1)
 
strPt=rs.PointAdd(strPt1,vec1)
 +
 
generation(3,strPt)
 
generation(3,strPt)
 +
 
print strPts[3]
 
print strPts[3]

Revision as of 11:39, 24 September 2013



cell generation

import rhinoscriptsyntax as rs

import random

import scriptcontext


def generation(x,strPt):

   #have a line so i can use "escape" key
   scriptcontext.escape_test()
   if x==0: return
   else:
       for i in range (0,100):
           #define the direction the starting point will grow
           point=[(0,1,0),(1,0,0),(-1,0,0),(0,-1,0)]
           rnd=random.choice(point)
           vec=rs.VectorCreate(rnd,(0,0,0))
           strPt=rs.PointAdd(strPt,vec)
           strPts.append(strPt)
           #form a volume based on the point
           rs.AddCircle(strPt,0.5)
           print rs.AddPoint(strPt)

strPts=[]

strPt1=rs.AddPoint((0,0,0))

vec1=rs.VectorCreate((1,0,0),(0,0,0))

strPt=rs.PointAdd(strPt1,vec1)

generation(3,strPt)

print strPts[3]