boring random surface

boring random surface, as seen on the cover of this book.

Here’s the script:

Option Explicit
‘Script written by Dimitrie Stefanescu
‘Script version 11 August 2008 16:47:28

Call Main()
Sub Main()


Dim surf : surf = Rhino.getObject(“Sel plane”)
Dim detL : detL = Rhino.GetReal(“Detail level”, 20)
‘Dim attPt : attPt = Rhino.GetPoint(“get att point”)

Call Rhino.EnableRedraw(False)

Dim uDom, vDom, uStep, vStep

uDom = Rhino.SurfaceDomain(surf,0)
uStep = (uDom(1)-uDom(0)) / detL

vDom = Rhino.SurfaceDomain(surf,1)
vStep = (vDom(1)-vDom(0)) / detL

Dim i, j, pt

Dim arrPnts : arrPnts = Array()
Dim k,m : k = -1 : m = -1
Dim ptN, arrCrv : arrCrv = Array()
Dim range, distance

For i = uDom(0) To uDom(1) + uStep Step uStep
m = m + 1
ReDim Preserve arrCrv(m)
For j = vDom(0) To vDom(1) – vStep Step vStep


k = k + 1
pt = Rhino.EvaluateSurface(surf,Array(i,j))

‘distance = Rhino.distance(pt, attPt)
‘range = distance * distance  / ( distance /3)
range = 0.0001 + j

ptN = Array(pt(0) + RandomNumber(-range, range), pt(1) + RandomNumber(-range, range), pt(2) + RandomNumber(-range, range))

ReDim Preserve arrPnts(k)
arrPnts(k) = ptN
k = -1
arrCrv(m) = Rhino.AddInterpCurve(arrPnts)

Call rhino.AddLoftSrf(arrCrv)

Call Rhino.EnableRedraw(True)
End Sub

Function RandomNumber(nMin, nMax)
RandomNumber = Null
If Not IsNumeric(nMin) Then Exit Function
If Not IsNumeric(nMax) Then Exit Function
If nMin >= nMax Then Exit Function
RandomNumber = ((nMax – nMin + 1) * Rnd + nMin) / 50
End Function


5 thoughts on “boring random surface

  1. nice fantastic blog yea nice job our review blog will soon be adding reviews on blogs and add them to our blogs as the top best 100 websites to visit we also do reviews on Customer Reviews all types of reviews thanks

  2. I really like this script but I am having trouble loading the script into my rhino, it keeps on giving me error messages. would it be possible if you can email me the rvb file?

    • Most common problem would be the ‘ marks for comments: e.g. ‘Script written by Dimitrie Stefanescu

      Which should be a plain apostrophe: ‘Script written by Dimitrie Stefanescu

      • Argh! Stupid WordPress converted my plain apostrophe to very mark I said was wrong. Anyway copy this script, paste it in and replace the back sloping single tick marks with an apostrophe from your keyboard.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

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