rvb Surface Population

rvb animation snippet example

Simple script that shows how to evaluate and frame a surface. It uses the UV parameters of the surface in order to populate it with pretty much any geometry (which you can select as input, in form of polysurfaces]. It is a good introduction to the topology of NURBS surfaces. More complex examples to come.

Option Explicit

'Script written by Adolfo Nadal

'Script by archiologics · www.archiologics.com

Call WhoFramedTheSurface()

Sub WhoFramedTheSurface()

Dim idSurface : idSurface = Rhino.GetObject("Surface to populate", 8, True, True)

If IsNull(idSurface) Then Exit Sub

Dim strBlock, BoundingBox

Dim d1, d2 

 

strBlock =Rhino.GetObject ("please select polysurface to populate surface with", 16,, True)

 

BoundingBox = Rhino.BoundingBox (strBlock)

 

d1 = Rhino.Distance (BoundingBox(0), BoundingBox(1))

d2 = Rhino.Distance (BoundingBox(1), BoundingBox(2)) 

 

Dim uDomain : uDomain = Rhino.SurfaceDomain(idSurface, 0)

Dim vDomain : vDomain = Rhino.SurfaceDomain(idSurface, 1)

Dim uStep : uStep = d1

Dim vStep : vStep = d2

 

Dim u, v, ucenter, vcenter,srfuv , add

Dim arrNormalSrf, arrReference(2), arrTarget (2)

Dim arrPtInsert, arrCenterBlock, strDiagonal1, strDiagonal2, strDiagonal3, strDiagonal4, arrSupCenter

Dim arrIntersection1, arrIntersection2

 

strDiagonal1 = Rhino.addLine(BoundingBox(0),BoundingBox(6))

strDiagonal2 = Rhino.addLine(BoundingBox(1),BoundingBox(7))

arrIntersection2 = Rhino.CurveCurveIntersection (strDiagonal1, strDiagonal2)

arrCenterBlock = arrIntersection2 (0,1)

    

strDiagonal3 = Rhino.addLine(BoundingBox(4),BoundingBox(6))

strDiagonal4 = Rhino.addLine(BoundingBox(5),BoundingBox(7))

arrIntersection1 = Rhino.CurveCurveIntersection (strDiagonal3, strDiagonal4)

arrSupCenter = arrIntersection1 (0,1)

 

'arrReference is the array of 3 points in the block that we are going to orient on the surface  

arrReference(0) = BoundingBox(0) 

arrReference(1) = arrCenterBlock

arrReference(2) = arrSupCenter 

 

Call rhino.DeleteObject(strDiagonal1)

Call rhino.DeleteObject(strDiagonal2)

Call rhino.DeleteObject(strDiagonal3)

Call rhino.DeleteObject(strDiagonal4) 

 

For u = uDomain(0) To uDomain(1) Step uStep

For v = vdomain(0) To vDomain(1) Step vStep

Ucenter = u + uStep/2

Vcenter = v + vStep/2

arrPtInsert = Rhino.EvaluateSurface(idSurface, Array(Ucenter, Vcenter))

srfuv = Rhino.SurfaceClosestPoint (idSurface, arrPtInsert) 

arrNormalSrf = Rhino.SurfaceNormal (idSurface, srfuv)

add = rhino.vectoradd(arrPtInsert,arrNormalSrf)

arrTarget(0) = Rhino.EvaluateSurface(idSurface, array(u,v))

arrTarget(1) = arrPtInsert

arrTarget(2) = add

Call Rhino.OrientObject (strBlock, arrReference, arrTarget, 1) 

Next

Next

End Sub

Search Site




archi·o·logics survey

I am interested in: