18.2.09
phyllotaxis pavilion
The code realizes a pavilion along a selected curve. Pavilion internal radius is influenced by the distance between the curve and an attractor point. Holes-size is related to the distance between the curve and another attractor point (placed in this case near curve's midpoint). In this way holes become smaller moving towards curve's midpoint.
Option Explicit
'Script written by andrea bugli
' "shift" on http://andbug.blogspot.com
'Script version venerdì 20 febbraio 2009 19.54.31
Call fibonaccipavilion
Sub fibonaccipavilion
Dim strBpts
Dim arrcircle, strN
strN = 240
Dim strcurve: strcurve = rhino.GetObject("select a curve", 4, True, True)
Dim arrPoints: arrPoints = rhino.DivideCurve(strcurve, strN, False, True)
ReDim arrcircle(ubound(arrPoints))
'this point influences pavilion radius
Dim ptparam1: ptparam1 = rhino.GetObject("select curve attractor point")
Dim ptcoord1: ptcoord1 = rhino.PointCoordinates(ptparam1)
'this point influences holes size
Dim ptparam2: ptparam2 = rhino.GetObject("select holes attractor point")
Dim ptcoord2: ptcoord2 = rhino.PointCoordinates(ptparam2)
Dim i
Dim ptrot
Dim pt
Dim ptcurve
ReDim ptrot(ubound(arrPoints))
rhino.EnableRedraw(False)
For i = 0 To ubound(arrPoints)
Dim strPoncurve: strPoncurve = rhino.CurveClosestPoint(strcurve, arrPoints(i))
Dim strframe: strframe = rhino.Curveperpframe(strcurve, strPoncurve)
Dim tang: tang = rhino.curvetangent(strcurve, strPoncurve)
Dim dist: dist = rhino.Distance(arrPoints(i), ptcoord1)
Dim dist2: dist2 = rhino.Distance(arrPoints(i), ptcoord2)
'create the tube on which are placed my points
arrcircle(i) = rhino.addcircle(strframe, 60/dist)
ptcurve = rhino.CurveStartPoint(arrcircle(i))
pt = rhino.addpoint(ptcurve)
'points are rotated by a definited angle
ptrot(i) = rhino.RotateObject(pt, arrPoints(i), 137.52*i, tang, True)
rhino.Deleteobject(pt)
Next
Dim strFace1
Dim strHole1
Dim arrHoleSrf1
Dim arrSrfBrep1
Dim centerPt1
Dim dblDist1
Dim strFace2
Dim strHole2
Dim arrHoleSrf2
Dim arrSrfBrep2
Dim centerPt2
Dim dblDist2
Dim strLine
Dim strPlaneLine
Dim strBaseCrv
For i = 0 To ubound(ptrot)-13
'create triangular face between points
strFace1 = rhino.addSrfPt(array(rhino.PointCoordinates(ptrot(i)), rhino.PointCoordinates(ptrot(i+8)), rhino.PointCoordinates(ptrot(i+5)), rhino.PointCoordinates(ptrot(i))))
'create a curve on the triangular face
strHole1 = rhino.addcurve(array(rhino.PointCoordinates(ptrot(i)), rhino.PointCoordinates(ptrot(i+8)), rhino.PointCoordinates(ptrot(i+5)), rhino.PointCoordinates(ptrot(i))), 2)
centerPt1 = rhino.curveAreaCentroid(strHole1)
dblDist1 = rhino.Distance(ptcoord2, centerPt1(0))
'if distance between centerPt1 and second attractor point is bigger than a definited amount, scale curve by means of
'distance and make a hole in the triangular face. if distance is smaller, leave face intact
If Not (1-8/dblDist1<0.2) Then
strHole1 = rhino.ScaleObject(strHole1, centerPt1(0), array(1-8/dblDist1, 1-8/dblDist1, 1-8/dblDist1))
arrHoleSrf1 = rhino.addPlanarSrf(array(strHole1))
arrSrfBrep1 = Rhino.SplitBrep (strFace1, arrHoleSrf1(0), True)
Call rhino.DeleteObject(arrHoleSrf1(0))
Call rhino.DeleteObject(arrSrfBrep1(0))
End If
Call rhino.deleteObject(strHole1)
'------------------
'create triangular face between points
strFace2 = rhino.addSrfPt(array(rhino.PointCoordinates(ptrot(i+5)), rhino.PointCoordinates(ptrot(i+8)), rhino.PointCoordinates(ptrot(i+13)), rhino.PointCoordinates(ptrot(i+5))))
'create a curve on the triangular face
strHole2 = rhino.addcurve(array(rhino.PointCoordinates(ptrot(i+5)), rhino.PointCoordinates(ptrot(i+8)), rhino.PointCoordinates(ptrot(i+13)), rhino.PointCoordinates(ptrot(i+5))), 2)
centerPt2 = rhino.curveAreaCentroid(strHole2)
dblDist2 = rhino.Distance(ptCoord2, centerPt2(0))
'if distance between centerPt2 and second attractor point is bigger than a definited amount, scale curve by means of
'distance and make a hole in the triangular face. if distance is smaller, leave face intact
If Not (1-8/dblDist2<0.2) Then
strHole2 = rhino.ScaleObject(strHole2, centerPt2(0), array(1-8/dblDist2, 1-8/dblDist2, 1-8/dblDist2))
arrHoleSrf2 = rhino.addPlanarSrf(array(strHole2))
arrSrfBrep2 = Rhino.SplitBrep (strFace2, arrHoleSrf2(0), True)
Call rhino.DeleteObject(arrHoleSrf2(0))
Call rhino.DeleteObject(arrSrfBrep2(0))
End If
Call rhino.DeleteObject(strHole2)
Next
'create a tube on each side of the triangle
For i = 0 To ubound(ptrot)-13
strLine = rhino.addline(rhino.PointCoordinates(ptrot(i)), rhino.PointCoordinates(ptrot(i+8)))
strPlaneLine = rhino.PlaneFromNormal(rhino.PointCoordinates(ptrot(i)), rhino.VectorCreate(rhino.PointCoordinates(ptrot(i)), rhino.PointCoordinates(ptrot(i+8))))
strBaseCrv = rhino.addcircle(strPlaneLine, 0.05)
Call rhino.AddSweep1(strLine, strBaseCrv)
strLine = rhino.addline(rhino.PointCoordinates(ptrot(i)), rhino.PointCoordinates(ptrot(i+5)))
strPlaneLine = rhino.PlaneFromNormal(rhino.PointCoordinates(ptrot(i)), rhino.VectorCreate(rhino.PointCoordinates(ptrot(i)), rhino.PointCoordinates(ptrot(i+5))))
strBaseCrv = rhino.addcircle(strPlaneLine, 0.05)
Call rhino.AddSweep1(strLine, strBaseCrv)
strLine = rhino.addline(rhino.PointCoordinates(ptrot(i+5)), rhino.PointCoordinates(ptrot(i+8)))
strPlaneLine = rhino.PlaneFromNormal(rhino.PointCoordinates(ptrot(i+5)), rhino.VectorCreate(rhino.PointCoordinates(ptrot(i+5)), rhino.PointCoordinates(ptrot(i+8))))
strBaseCrv = rhino.addcircle(strPlaneLine, 0.05)
Call rhino.AddSweep1(strLine, strBaseCrv)
Next
call rhino.DeleteObjects(arrcircle)
Call rhino.DeleteObjects(ptrot)
rhino.enableredraw(True)
End Sub
Subscribe to:
Post Comments (Atom)
Nice post Andrea! We might discuss about developing some fabrication strategies for this pavilion...
ReplyDeleteA couple of minor things to consider for the future:
. relations between any organism and its environment are reciprocal, so buildings both affect and are affected by their environment (in short: beware of flat pavements! Haha...)
. remember to place a comment from time to time into the scripts or they can get kinda puzzling...
Awesome! You makes us bite the dust.. But can you put just a few notes? they might be very useful!
ReplyDelete"make"
ReplyDeleteI apologize if the script was a little bit unintelligible....now I put a few notes into it! I hope they might be useful!
ReplyDelete