MARC FORNES & THEVERYMANY™

PRACTICING AT THE INTERSECTION OF ART + ARCHITECTURE ^ COMPUTATION

Rh3_XefioRetro_Weaves [Old&Rusty]


Option Explicit
‘——————————————————————————
‘ Subroutine: ArraySurfaceNormalSectionLoft
‘ Purpose: Creates form a surface an array of normals, section and loft them.
‘——————————————————————————
Sub ArraySurfaceNormalSectionLoft()

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

‘ ———————————————————————————
‘ [ 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)”, “Loft: _sectFrequence”, “LOFT_Type”, ” _1 / Normal”, ” _2 / Loose”, ” _3 / Tight”, ” _4 / Straight”)
‘ set default values
arrValues = array(“60”, “10”, “0.5”, “2”, “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
‘ LOFT _Frequence:
intLoft_sectionsFrequence = FormatNumber(arrResults(3))
If intLoft_sectionsFrequence < 2 Then Exit Sub
intLoft_sectionsFrequence = intLoft_sectionsFrequence -1
intLoft_sectionsFrequence = intLoft_sectionsFrequence +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(0) = U(0) + (((U(1) – U(0)) / nLONGITUDE) * i)

‘ ———————————————————————————
‘ FOR each columns/isoParms
‘ ———————————————————————————
For j = 0 To nTRANSVERSAL
arrParam(1) = V(0) + (((V(1) – V(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)
‘ – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
‘ [ 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
‘ WAVE UpDown is curve straight via all j points
ReDim Preserve arrPt_WAVE_UpDown(nTRANSVERSAL)
Dim strWAVE_UpDown

‘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
‘ point on this row
arrPt_WAVE(j) = arrNormal_PtOnSurf_Collect(j)
arrPt_WAVE_UpDown(j) = arrNormal_PtOnSurf_Collect(j)
Else
‘ point on the previous row
arrPt_WAVE(j) = arrNormal_PtOnSurf_Collect_PreviousRow(j)
arrPt_WAVE_UpDown(j) = arrNormal_PtEnd_Collect(j)
End If

If j = nTRANSVERSAL Then
‘ addCurve: WAVE GREY
strWAVE = Rhino.AddInterpCrvOnSrf (strObject,arrPt_WAVE)
Rhino.objectColor strWAVE, RGB(150, 150, 150)
‘ addCurve: WAVE PINK
strWAVE_UpDown = Rhino.AddInterpCurve (arrPt_WAVE_UpDown, 3)
Rhino.objectColor strWAVE_UpDown, RGB(200, 0, 200)

‘ ADD LOFT SURFACE:
arrInterpCurve = array(strWAVE_previous(i-1), strWAVE_UpDown_previous(i-1), strWAVE)
strObjectLoft = Rhino.AddLoftSrf (arrInterpCurve, , ,intLoftType,1,100, False)
Rhino.SurfaceIsocurveDensity strObjectLoft, -1
Rhino.objectColor strObjectLoft, RGB(225, 225, 255)
End If

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

If j = nTRANSVERSAL Then
‘ addCurve: WAVE BLACK
strWAVE = Rhino.AddInterpCrvOnSrf (strObject,arrPt_WAVE)
Rhino.objectColor strWAVE, RGB(0, 0, 0)
‘ addCurve: WAVE PURPLE
strWAVE_UpDown = Rhino.AddInterpCurve (arrPt_WAVE_UpDown, 3)
Rhino.objectColor strWAVE_UpDown, RGB(100, 0, 100)

‘ ADD LOFT SURFACE:
If i>1 Then
arrInterpCurve = array(strWAVE_previous(i-1), strWAVE_UpDown_previous(i-1), strWAVE)
strObjectLoft = Rhino.AddLoftSrf (arrInterpCurve, , ,intLoftType,1,100, False)
Rhino.SurfaceIsocurveDensity strObjectLoft, -1
Rhino.objectColor strObjectLoft, RGB(0, 0, 0)
End If
End If
‘ … … … … … … … … … … … … … … … … … … … … … … … … … … …
End If

‘keep WAVE
ReDim Preserve strWAVE_previous(nLONGITUDE)
strWAVE_previous(i) = strWAVE
ReDim Preserve strWAVE_UpDown_previous(nLONGITUDE)
strWAVE_UpDown_previous(i) = strWAVE_UpDown

‘ 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)
ReDim Preserve arrNormal_PtEnd_Collect_PreviousRow(nTRANSVERSAL)
arrNormal_PtEnd_Collect_PreviousRow(j) = arrNormal_PtEnd_Collect(j)
‘[ END EXPERIMENT ]
‘ – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
‘ ———————————————————————————
Next
‘ ———————————————————————————
‘ ———————————————————————————
Next
‘ ———————————————————————————

End Sub
ArraySurfaceNormalSectionLoft

3 Comments»

  bdfytoday wrote @

I love your website. It has a lot of great pictures and is very informative.< HREF="http://edma.at/betrieblich_altersvorsorge_guenstig.html" REL="nofollow">»<>

  Paskalis Khrisno Ayodyantoro wrote @

Hi Marc, are there something different with rhino script ver 3 and ver 4 in array commands, because i tried xerio script, and get an error message. “type mismatch arrnormal ()”. sorry i just new beginner. just started rhino for this 1 month..

  Mikk wrote @

same problem here


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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s