rvb Surface Hexagonal Grid

rvb animation snippet example

Simple script that shows how to create a line grid of hexagonal form based on the UV parameters of its control points, regardless and even distribution. Again, it is a perfect introduction if you are beginning to work with surfaces.More complex examples to come.

Option Explicit

'Script written by Adolfo Nadal

'Script by archiologics · www.archiologics.com

Call GridMaker

Sub GridMaker

Dim strSurface, arrPoints, arrCount

Dim arrpt1,arrpt2,arrpt3,arrpt4

strSurface = Rhino.GetObject("Select surface", 8)

If IsNull(strSurface) Then Exit Sub  

arrPoints = Rhino.SurfacePoints(strSurface)

If Not IsArray(arrPoints) Then Exit Sub

arrCount = Rhino.SurfacePointCount(strSurface)

Dim u, v

Dim ulast : ulast = arrCount(0)

Dim vlast : vlast = arrCount(1)

Dim i : i  = 0

For u = 0 To ulast - 2

For v = 0 To vlast - 2

i =v+u*vlast

arrpt1=arrPoints(i)

arrpt2=arrPoints(i+1)

arrpt3=arrpoints((u+1)*vlast+v+1)

arrpt4=arrpoints((u+1)*vlast+v)

Call addpolygon(arrpt1,arrpt2,arrpt3,arrpt4)

Next

Next

Call rhino.HideObject(strSurface)

End Sub

Function addpolygon(arrpt1,arrpt2,arrpt3,arrpt4)

Dim polypt121,polypt122

Dim polypt431,polypt432

Dim polypt411,polypt412

Dim polypt321,polypt322

Dim k1,k2,k3,k4,k5,k6

k1=0.5

k2=0.5

k3=0.15

k4=0.15

k5=0.3

k6=0.3

polypt411=PtonCrv(arrpt1,arrpt4,k1)

polypt321=PtonCrv(arrpt2,arrpt3,k2)

polypt431=PtonCrv(arrpt4,arrpt3,k5)

polypt432=PtonCrv(arrpt3,arrpt4,k6)

polypt121=PtonCrv(arrpt1,arrpt2,k5)

polypt122=PtonCrv(arrpt2,arrpt1,k6)

polypt412=PtonCrv(polypt411,polypt321,k3)

polypt322=PtonCrv(polypt321,polypt411,k4)

Call rhino.AddLine(polypt411,polypt412)

Call rhino.AddLine(polypt322,polypt321)

Call rhino.AddLine(polypt431,polypt432)

Call rhino.AddLine(polypt121,polypt122)

Call rhino.AddLine(polypt412,polypt431)

Call rhino.AddLine(polypt412,polypt121)

Call rhino.AddLine(polypt432,polypt322)

Call rhino.AddLine(polypt322,polypt122)

End Function

 

Function PtonCrv(arrpt1,arrpt2,k)

Dim Crvdom, strLine,ratio

strLine=rhino.addline(arrpt1,arrpt2)

Crvdom=rhino.CurveDomain(strLine)

ratio=Crvdom(0)+k*(Crvdom(1)-Crvdom(0))

PtonCrv=rhino.EvaluateCurve(strLine,ratio)

Call rhino.DeleteObject(strLine)

End Function

Search Site




archi·o·logics survey

I am interested in: