Difference between revisions of "workshop01G5:Codefarm"
From CECO
(Created page with "__NOTOC__ __NOTITLE__ <div style="height:30px; width: 850px; margin:0px; padding: 0px; padding-top: 20px; border: 0px;"> <div style="float:left; width: 160px; height 30px; b...") |
|||
Line 15: | Line 15: | ||
</div><br> | </div><br> | ||
− | == | + | ==cell generation== |
− | + | import rhinoscriptsyntax as rs | |
+ | import random | ||
+ | import math | ||
+ | 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] |
Revision as of 11:37, 24 September 2013
cell generation
import rhinoscriptsyntax as rs import random import math 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]