30 January 2009

Honeycomb panels 03


Honeycomb tesselation rhinoscript optimized:
-contouring curves created by rhinoscript
-equal distance of contouring curves is variable
-selection of curves more fast, not one by one
-number of division points is variable
-more fast honeycomb construction

Option Explicit
' Author: Milutin Cerovic 2009
' www.4ofseven.com
' adapted:http://www.madeincalifornia.blogspot.com/
Call Main()
Sub Main()
'---------------------
'declare variables
'---------------------
Dim arrPoints
Dim i,j
Dim strObject, arrStartPoint, arrEndPoint, arrContours, divnumber
Dim arrIsoCurves
Const rhObjectCurve = 4
'---------------------
'select surface or Polysurface
'---------------------
strObject = Rhino.GetObject("Select object", rhObjectSurface + rhObjectPolysurface)
'define plane of section
'---------------------
arrStartPoint = Rhino.GetPoint("select contour base plane startpoint")
arrEndPoint = Rhino.GetPoint("select contour plane endpoint", arrStartPoint)
'---------------------
'define distance of sections
'---------------------
divnumber= rhino.GetReal("enter equal distance of sections contour")
arrContours = Rhino.SurfaceContourPoints(strObject, arrStartPoint, arrEndPoint,divnumber)
'---------------------
'draw curve through section arraypoints
'---------------------
If IsArray(arrContours) Then
For Each arrPoints In arrContours
Rhino.Addcurve arrPoints
Next

End If
'---------------------
'select isocurves
'---------------------
arrIsoCurves=Rhino.GetObjects ("Select Section curves, from left to right or viceversa",rhObjectcurve)
ReDim arrPoints(UBound(arrIsoCurves))
'---------------------
'divide curve into equal distances and array points
'-------------------------------
DivNumber = Rhino.GetReal ("enter divide number curves")
For i=0 To UBound(arrIsoCurves)
arrPoints(i)=Rhino.DivideCurve(arrIsoCurves(i),DivNumber,True)
Next
'---------------------
'draw lines with honeycomb pattern
'-------------------------------
'>>>>>>>>>>>>>ACTIVE NEXT LINE FOR FAST CALCULATION<<<<<<<<<<<<<<<<<<

' Call rhino.EnableRedraw (False)
For i=0 To (UBound(arrIsoCurves)-1)Step 4
For j=0 To (DivNumber-2)
If j Mod 2 <> 0 Then
Rhino.addLine arrPoints(i)(j),arrPoints(i+1)(j)
Rhino.addLine arrPoints(i+1)(j),arrPoints(i+2)(j+1)
Rhino.addLine arrPoints(i+2)(j+1),arrPoints(i+1)(j+2)
Rhino.addLine arrPoints(i+2)(j+1),arrPoints(i+3)(j+1)
Rhino.addLine arrPoints(i+3)(j+1),arrPoints(i+4)(j+2)
Rhino.addLine arrPoints(i+3)(j+1),arrPoints(i+4)(j)


End If
Next
Next
'>>>>>>>>>>>>>ACTIVE NEXT LINE FOR FAST CALCULATION<<<<<<<<<<<<<<<<<<

'Call rhino.EnableRedraw (True)
End Sub

1 commenti:

Andrea Graziano said...

mi sbalordisci ogni volta.... come hai fatto?!