algorithmic modeling for Rhino
Hey guys,
I am trying to write a script which produces an aggregation of boxes according to a random number that has been generated through a loop. I want the boxes that have not been generated in the first loop to be generated in the second loop, or third..(depending on how many iterations I give it.) However, for each loop my script has been giving me a new set of boxes, instead filling in the boxes which where not generated from the loop before it. Can anyone help me with this?!
Thanks in advance.
attached is the file and here is the script:
Private Sub RunScript(ByVal point As Point3d, ByVal iterations As Double, ByVal regen As Double, ByVal x As Double, ByRef A As Object, ByRef B As Object)
'defining the outcomes
Dim points As New list(Of point3d)
Dim boxs As New List(Of box)
Dim vects As New list(Of Vector3d)
points.add(point)
Dim rand As New Random(ReGen * 10000)
'defining the variables
Dim rnd As New Double
'generating the aggregation
myfun(boxs, points, rand, iterations, x)
a = boxs
End Sub
'<Custom additional code>
Sub MyFun(ByVal boxs As list(Of box), ByVal points As list(Of point3d), ByVal rand As random, ByVal iterations As Integer, ByVal x As Double)
'base plane
Dim plno As New Plane(New point3d(0, 0, 0), New vector3d(0, 0, 1))
'boxes in y axis
For y As int32 = -iterations To iterations
Dim pty As New point3d
Dim vecty As New vector3d(0, y, 0)
Dim pty2 As New point3d
pty2 = pty + vecty
'boxes in x axis
For l As int32 = -iterations To iterations
Dim ptl As New Point3d
Dim vectl As New Vector3d(l, 0, 0)
ptl = pty2 + vectl
'boxes in z axis
For z As int32= 0 To x
Dim rndl As New Double
rndl = rand.Next(0, x)
Dim vectz As New Vector3d(0, 0, z)
Dim pt2 As New Point3d()
pt2 = ptl + vectz
'generating boxes
Dim newpt As Point3d
Dim newvect As New Vector3d(1, 1, 1)
newpt = pt2 + newvect
Dim pointsb As New List(Of point3d)
pointsb.add(pt2)
pointsb.add(newpt)
Dim bx As New Box(plno, pointsb)
'adding only selected number of boxes
If rndl = x - 1 Then boxs.add(bx)
Next
Next
Next
End Sub
Tags:
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2025 Created by Scott Davidson.
Powered by