MARC FORNES & THEVERYMANY™

PRACTICING AT THE INTERSECTION OF ART + ARCHITECTURE ^ COMPUTATION

Rh3_UsualSuspect_HoneyComb (v.Old&Rusty)


Option Explicit
‘——————————————————————————
‘ Subroutine: HoneyComb
‘ Purpose: Creates form a surface an array of normals, section and loft them.
‘——————————————————————————
Sub HoneyComb()
Dim strObject, nLONGITUDE, nTRANSVERSAL
Dim U, V, i, j, arrParam(1), arrPoint
Dim arrParamNormal, arrNormal, Normal_Line
Dim InterpCurve
Dim strObjectLoft
Dim strInterpCurve
Dim strInterpCurveOnSurf
Dim intDeltaHeight
Dim intLoft_sectionsFrequence
Dim intLoftType
Dim arrInterpCurve
Dim indexCROSS_everyNpoint
Dim k: k = 0
‘ ———————————————————————————
‘ ———————————————————————————
‘ [ Get SURFACE object ]
strObject = Rhino.GetObject(“Select surface”, 8)
If IsNull(strObject) Then Exit Sub

‘ [ PROPERTY LIST BOX ]
‘ set variables
Dim arrParameters, arrResults, arrValues
‘ set paramters names
arrParameters = array(“i: rows/sections (>1)”, “j: columns/isoParms (>1)”, “NORMAL: _height (0)”, “WAVE: _crossEvery”, “LOFT: _Type”, “_____1 / Normal”, “_____2 / Loose”, “_____3 / Tight”, “_____4 / Straight”)
‘ set default values
arrValues = array(“60”, “10”, “0.2”, “3”, “2”, “-“, “-“, “-“, “-“)
‘ create “Property list box”
arrResults = Rhino.PropertyListBox(arrParameters, arrValues, “Parameters”, “ZOOYORK{1117_PAU_Skin_Panels}” )
If IsArray(arrResults) Then
‘ NUMBER of rows/sections:
nLONGITUDE = FormatNumber(arrResults(0))
If IsNull(nLONGITUDE) Then Exit Sub
nLONGITUDE = nLONGITUDE – 1
‘ NUMBER of columns:
nTRANSVERSAL = FormatNumber(arrResults(1))
If IsNull(nTRANSVERSAL) Then Exit Sub
nTRANSVERSAL = nTRANSVERSAL – 1
‘ NORMAL: _height
intDeltaHeight = FormatNumber(arrResults(2))
If IsNull(intDeltaHeight) Then Exit Sub
intDeltaHeight = intDeltaHeight – 1
‘ WAVE: _crossEvery
indexCROSS_everyNpoint = FormatNumber(arrResults(3))
If IsNull (indexCROSS_everyNpoint) Then Exit Sub
indexCROSS_everyNpoint = indexCROSS_everyNpoint -1
indexCROSS_everyNpoint = indexCROSS_everyNpoint +1
‘ LOFT: _Type
intLoftType = FormatNumber(arrResults(4))
If IsNull(intLoftType) Or intLoftType > 4 Then Exit Sub
intLoftType = intLoftType – 1
End If
‘ ———————————————————————————
‘ ———————————————————————————
‘ GET DOMAIN OF SURFACE
U = Rhino.SurfaceDomain(strObject, 0)
V = Rhino.SurfaceDomain(strObject, 1)
If Not IsArray(U) Or Not IsArray(V) Then Exit Sub
‘ ———————————————————————————
‘ FOR each rows/sections:

‘ ———————————————————————————
For i = 0 To nLONGITUDE
arrParam(1) = V(0) + (((V(1) – V(0)) / nLONGITUDE) * i)

‘For i = 0 To nLONGITUDE
‘arrParam(1) = U(0) + (((U(1) – U(0)) / nLONGITUDE) * i)
‘ ———————————————————————————
‘ FOR each columns/isoParms

‘———————————————————————————
‘For j = 0 To nTRANSVERSAL
‘arrParam(0) = V(0) + (((V(1) – V(0)) / nTRANSVERSAL) * j)

For j = 0 To nTRANSVERSAL
arrParam(0) = U(0) + (((U(1) – U(0)) / nTRANSVERSAL) * j)
arrPoint = Rhino.EvaluateSurface(strObject, arrParam)
‘If IsArray(arrPoint) Then Rhino.AddPoint arrPoint
‘ – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
‘ [ ADD NORMAL ]
arrParamNormal = Rhino.SurfaceClosestPoint(strObject, arrPoint)
arrNormal = Rhino.SurfaceNormal(strObject, arrParamNormal)
‘ (arrNormal(0) is point on surf & arrNromal(1) is end of Normal)

‘ [ SET HEIGHT ALONG NORMAL ]
‘ Normal as Vector
Dim arrNormal_VECTOR
arrNormal_VECTOR = array( (arrNormal(1)(0))-(arrNormal(0)(0)), _
(arrNormal(1)(1))-(arrNormal(0)(1)), _
(arrNormal(1)(2))-(arrNormal(0)(2)) )
‘ Normal End Pt: translate along arrNormal_VECTOR and multiply by factor
Dim arrNormal_ScaledEndPt
arrNormal_ScaledEndPt = array( (arrNormal(1)(0))+(arrNormal_VECTOR(0)*intDeltaHeight), _
(arrNormal(1)(1))+(arrNormal_VECTOR(1)*intDeltaHeight), _
(arrNormal(1)(2))+(arrNormal_VECTOR(2)*intDeltaHeight) )
‘ Normal addLine
‘Normal_Line = Rhino.addLine (arrNormal(0), arrNormal_ScaledEndPt)
‘Rhino.objectColor Normal_Line, RGB(255, 0, 255)

‘ Normal: keep the first as path for the extrusion
‘If j=0 Then Normal_Line = Rhino.addLine (arrNormal(0), arrNormal_ScaledEndPt)
If STRIPE_FrequenceNumber Mod 2 Then
If j=0 Then Normal_Line = Rhino.AddInterpCurveEx (array(arrNormal(0), arrNormal_ScaledEndPt))
End If
‘ – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
‘ – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
‘ [ COLLECT NORMAL POINTS ]
‘ Normal PtOnSurface:
ReDim Preserve arrNormal_PtOnSurf_Collect(nTRANSVERSAL)
arrNormal_PtOnSurf_Collect(j) = arrNormal(0)
‘ Normal Scaled End PT:
ReDim Preserve arrNormal_PtEnd_Collect(nTRANSVERSAL)
‘ special case for the EDGE
If i=0 And i=nLONGITUDE And j=0 And j=nTRANSVERSAL Then
‘ else keep the point on the Edge
arrNormal_PtEnd_Collect(j) = arrNormal(0)
Else
‘ if different from first or last Pt:
arrNormal_PtEnd_Collect(j) = arrNormal_ScaledEndPt
End If
‘ – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

‘ – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
‘[ EXPERIMENT ]
‘Dim indexCROSS_everyNpoint: indexCROSS_everyNpoint = 2
‘ in order to start the count of every two, one stripe before
‘ catch on LONGITUDE (i) some points on the previous: it only start starting from the 2
Dim STRIPE_FrequenceNumber: STRIPE_FrequenceNumber = i+1

ReDim Preserve arrPt_WAVE(nTRANSVERSAL)
Dim strWAVE

‘in order to start the count of every two, one stripe before
If STRIPE_FrequenceNumber Mod 2 Then
‘ … … … … … … … … … … … … … … … … … … … … … … … … … … …
‘ [ GREY & PINK ]
If STRIPE_FrequenceNumber 1 Then
‘ first stripe doesn’t have any previous history

‘If j Mod indexCROSS_everyNpoint Then
‘If j Mod indexCROSS_everyNpoint And J Mod (indexCROSS_everyNpoint+1) Then
If j Mod ((Rnd*10)+1) Then
‘ point on this row
arrPt_WAVE(j) = arrNormal_PtOnSurf_Collect(j)
Else
‘ point on the previous row
arrPt_WAVE(j) = arrNormal_PtOnSurf_Collect_PreviousRow(j)
End If

k = k + 1
If k = indexCROSS_everyNpoint Then k = 0

If j = nTRANSVERSAL Then
‘ addCurve: WAVE GREY
‘strWAVE = Rhino.AddInterpCrvOnSrf (strObject,arrPt_WAVE)
strWAVE = Rhino.AddInterpCurve (arrPt_WAVE, 1)
Rhino.objectColor strWAVE, RGB(150, 150, 150)

‘ EXTRUDE CURVE
Rhino.ExtrudeCurve strWAVE, Normal_Line

End If

End If
‘ … … … … … … … … … … … … … … … … … … … … … … … … … … …
Else
‘ … … … … … … … … … … … … … … … … … … … … … … … … … … …
‘ [ BLACK & PURPLE]
‘ one point every two
‘If j Mod indexCROSS_everyNpoint Then
If j Mod ((Rnd*10)+1) Then
‘ point on this row
arrPt_WAVE(j) = arrNormal_PtOnSurf_Collect_PreviousRow(j)
Else
‘ point on the previous row
arrPt_WAVE(j) = arrNormal_PtOnSurf_Collect(j)
End If

k = k + 1
If k = indexCROSS_everyNpoint Then k = 0

If j = nTRANSVERSAL Then
‘ addCurve: WAVE BLACK
‘strWAVE = Rhino.AddInterpCrvOnSrf (strObject,arrPt_WAVE)
strWAVE = Rhino.AddInterpCurve (arrPt_WAVE, 1)
Rhino.objectColor strWAVE, RGB(0, 0, 0)

‘ EXTRUDE CURVE
Rhino.ExtrudeCurve strWAVE, Normal_Line

End If
‘ … … … … … … … … … … … … … … … … … … … … … … … … … … …
End If

‘keep WAVE
ReDim Preserve strWAVE_previous(nLONGITUDE)
strWAVE_previous(i) = strWAVE
‘ keep the collection of point of the previous row
ReDim Preserve arrNormal_PtOnSurf_Collect_PreviousRow(nTRANSVERSAL)
arrNormal_PtOnSurf_Collect_PreviousRow(j) = arrNormal_PtOnSurf_Collect(j)
‘[ END EXPERIMENT ]
‘ – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
‘ ———————————————————————————
Next
‘ ———————————————————————————
‘ ———————————————————————————
Next
‘ ———————————————————————————
End Sub
HoneyComb

Advertisements

No comments yet»

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s