List All Pages
Juergen Weiss, Architect, is the founder of Script Library, a page which contains functions for Rhinoscripting. He graduated with a Diplom of Architecture form the University of Applied Science...
http://scripting.wikidot.com/system:list-all-pages
'
' returns the number of elements in an array
'
'
' IN: arr - the array to work with
' OUT: array_count - Integer number of elements (NULL if not an array)
'
Function array_count(ByVal arr)
If...
'
' returns the number of dimensions for a given array
'
'
' IN: arr - the array to test (can be n-dimensional)
' OUT: array_dimensions - Integer number of dimensions (0 if not an array)
'
Function...
'
' fills an array with the given value up to the given ubound
'
'
' IN: ub - The ubound of the array
' IN: val - The value to fill in
' OUT: Array: the new array
'
Function array_fill(ByVal ub,...
'
' dimensions a two-dimensional array with the given ubound
'
' IN: ub1 - Integer of the ubound for 1st dimension
' IN: ub2 - Integer of the ubound for 2nd dimension
' OUT: array_dim2 - the new...
For future we like to show here what people are able to do with scripting and with our library
'
' Generates a Bounding Box and generates the CenterPoint of each of the objects in the ground surface
'
' IN: arrobject - Array of object
' OUT: arr CenterPoint - Center Points
'
Function...
'
' Generates the centerpoint of a object with a bounding box
'
' IN: arrObject - Array of the Objects
' OUT: arrCenterPoint - Array of the Center Points
'
Function centerpoint (arrObject)
Dim...
'
' Cleans Rhino from everything Viewports
'
' IN: -
' Out: -
'
Function Clear
Rhino.Command "SelAll "
Rhino.Command "Delete "
End Function
'
' Searchs for the closest Point
'—-
Function functNearestNeighbor (arrPts, index)
Dim k, dblDist
Dim dblDistMin : dblDistMin = 100
For k = 0 To UBound(arrPts)
dblDist =...
'''
''' changes the color, depending to a distance of two objects
'''—-
Function at_ChangeColor(obj,tDist,aDist,sFactor)
Dim objColor, newColor
' caculate color
newColor = 255 - ((1 - ((tDist -...
To report problems or for contribution on this page, please send an email to
weiss-juergen @ hotmail com
'''
''' Divides a curve with specific length
'''' —-
Function DivCurve3(idCurve, dblLength)
Dim lenPt, i, d
Dim allID()
lenPt = Rhino.DivideCurveLength(idCurve, dblLength)
If IsNull(lenPt) Then...
'
' Diviides a curve in different sections
' —-
Function curvedivision (strcurve,sections)
Dim Domain, Param, Point, i
ReDim collection(sections)
Domain = Rhino.CurveDomain(strcurve) ' here we...
''' ---
''' Export Properties of a curve to Excel
''' ---
Function ExtractProperties
' Declare variables
Dim xlApp, xlBook, xlSheet ' Declare variable to hold the reference.
Dim strObject
Dim...
''' ---
''' import excel files into variables
''' ---
Function Excel_Variables()
Dim FileName, file, excel
FileName = Rhino.OpenFileName("Select Excel File","Excel Files (*.xls)|*.xls||")
If...
Soon we will find here a bunch of finished scriptes
''' -
''' Group access
''' -
Function groupsFromObjects(obj)
groupsFromObjects = Null
Dim i,j,r,s, count, grp, box, grpObj()
count = uBound(obj)
ReDim grp(count), group(0)
s=0
For i = 0 To...
If you are allowed to edit pages in this Site, simply click on edit button at the bottom of the page. This will open an editor.
To create a link to a new page, use syntax: [[[new page name]]] or...
This page should help all users of Rhino Scripting, to develop their script more efficient and faster. For this we are working on libraries of functions, which only have to be copied into an...
Please change this page according to your policy (configure first using Site Manager) and remove this note.
Who can join?
You can write here who can become a member of this site.
Join!
So you...
''' ---
''' check Layer
''' ---
Function CheckLayer(layername,color)
If Rhino.IsLayerChildOf(parentLayer, layername+"_"+parentLayer)...
How should a collection of functions help you to develope a script easier and faster?
This is pretty easy to explain. What you can find on this wiki is a collection of function which each of used...
My Blog
http://www.rethinkarchitecture.blogspot.com/
Other Libraries
http://digitoolbox.wikidot.com/rhinoscripting-library#toc1
Usefull resources online for...
''' ---
''' mesh the last object
''' ---
Function mesh()
Rhino.Command "SelNone"
Rhino.Command "Sellast"
Rhino.Command "_mesh Enter"
End Function
'''
''' Pipe a curve
''' —-
Function PipeOne(strRail, pipeRadius)
Dim strCmd
'Pipe the curve using rhino's command string format
strCmd = " !_Pipe _SelID " & strRail & " " &...
''' ---
''' Random Number
''' ---
Function RandomNumber(nMin, nMax)
RandomNumber = vbNull
If Not IsNumeric(nMin) Then Exit Function
If Not IsNumeric(nMax) Then Exit Function
If nMin >= nMax Then...
'''
''' Random points on curve
''' —-
Function randomPtsOnCrv(strObject, intPts)
Dim domain, i
domain = Rhino.CurveDomain (strObject)
For i = 0 To intPts
Rhino.AddPoint Rhino.EvaluateCurve...
'''
''' Gives you an positive random vector
'''——
Function rndVec(range)
rndVec=Array(Rnd*range-range/2,Rnd*range-range/2,Rnd*range-range/2)
End Function
' Renders and saves Pictures, which is really usefull for Animation
' befor starting the script change your renderoptions
' (f) gives you the possibility of numbering the pictures
Function...
'''
''' scale function for surfaces
''' —-
Function scalesurface (strsurface, xScale, yScale, zScale)
Dim strscale, domu, domv, paramu, paramv
domu = Rhino.SurfaceDomain(strsurface,0) 'gets the...
'''
''' Scale to centerpoint of a boundingbox
''' —-
Function scaleAll (arrObject, xScale, yScale, zScale)
Dim strObject, dblDistance, strOffsetDirection, arrCenterPoint, arrBBox,tempLn
' loop...
'''
''' Scales All
''' —-
Function scaleAll (arrObject, xScale, yScale, zScale)
Dim strObject, dblDistance, strOffsetDirection, arrCenterPoint, arrBBox
' loop through each curve and offset
For...
Introduction
About
Library
Finished Scripts
Case Studies
Tutorials-Rhino
Tutorials-Grasshopper
Tutorials-Scripting
All Pages
Links
Library tags
Add a new...
Members:
Moderators
Admins
SPEED UP YOUR CAPACITY OF SCRIPTING
This page should help all users of Rhino Scripting, to develop their script more efficient and faster. For this we are working on libraries of functions, which...
'''
''' rotate surfaces to align their normal to a point
''' —-
Function Surfaceorientation (arrSurfaces, point)
'calcuate vector from point to each srf
Dim srf
For Each srf In arrSurfaces
'find...
'''
''' Surface division
''' —-
Function surfacedivision (strsurface, secu, secv)
Dim i,j
ReDim colec (secu,secv)
Dim udomain: udomain= rhino.SurfaceDomain (strsurface,0)
Dim vdomain: vdomain=...
'''
''' function for unrolling all surfaces
''' —-
Function unroll (arrObjects)
Dim arrUnrolledObj, arrEdge
Dim i, cnt:cnt = 0
Dim strTempPSrf, strText, strMacro, strPoint
Dim matPts(),pt
Dim...
example menu
example item 1
example item 2
contact
'''
''' Transforms objects in scale and orientation
''' —-
Function transformEach(objects)
transformEach = Null
Dim arrItems, arrValues, arrReturns
arrItems =...
Attached you can find a Rhino Script Tutorial
Coole...
''' ---------------
''' Add two 3D vectors
''' ---------------
Function VectorAdd(v1, v2)
VectorAdd = Null
VectorAdd = Array(v1(XX) + v2(XX), v1(YY) + v2(YY), v1(ZZ) + v2(ZZ))
End Function
''' ---------------
''' Compare two 3D vectors for equality
''' ---------------
Function VectorCompare(v1, v2)
VectorCompare = vbFalse
If v1(XX) = v2(XX) And v1(YY) = v2(YY) And v1(ZZ) = v2(ZZ)...
''' ---------------
''' Return the cross product of two 3D vectors
''' ---------------
Public Function VectorCrossProduct(v1, v2)
VectorCrossProduct = Null
Dim x, y, z
x = v1(YY) * v2(ZZ) - v1(ZZ)...
''' ---------------
''' Return the length of a 3D vector
''' ---------------
Function VectorLength(v)
VectorLength = Null
Dim dist, x, y, z, x2, y2, z2
x = v(XX) : y = v(YY) : z = v(ZZ)
x2 = x * x...
''' ---------------
''' Find midpoint between two vectors
''' ---------------
Function VectorMidpoint(v1, v2)
VectorMidpoint = Null
VectorMidpoint = Array((v1(XX) + v2(XX))/2, (v1(YY) +...
''' ---------------
''' Return the dot product of two 3D vectors
''' ---------------
Function VectorDotProduct(v1, v2)
VectorDotProduct = v1(XX) * v2(XX) + v1(YY) * v2(YY) + v1(ZZ) * v2(ZZ)
End...
''' ---------------
''' Make a vector from two 3D points
''' ---------------
Function VectorCreate(p1, p2)
VectorCreate = Array(p2(0) - p1(0), p2(1) - p1(1), p2(2) - p1(2))
End Function
''' ---------------
''' Scale a 3D vectors by a value
''' ---------------
Function VectorScale(v, d)
VectorScale = Null
VectorScale = Array(v(XX) * d, v(YY) * d, v(ZZ) * d)
End Function
''' ---------------
''' Subtract two 3D vectors
''' ---------------
Function VectorSubtract(v1, v2)
VectorSubtract = Null
VectorSubtract = Array(v1(XX) - v2(XX), v1(YY) - v2(YY), v1(ZZ) -...
''' ---------------
''' Tiny vector test
''' ---------------
Function IsVectorTiny(v)
IsVectorTiny = vbFalse
Dim tol : tol = 1.0e-12 ' ON_ZERO_TOLERANCE
If (Abs(v(XX)) <= tol) And (Abs(v(YY))...
''' ---------------
''' Unitize a 3D vector
''' ---------------
Function VectorUnitize(v)
VectorUnitize = Null
Dim dist, x, y, z, x2, y2, z2
x = v(XX) : y = v(YY) : z = v(ZZ)
x2 = x * x : y2 = y *...
''' ---------------
''' Zero vector test
''' ---------------
Function IsVectorZero(v)
IsVectorZero = vbFalse
If (v(XX) = 0.0) And (v(YY) = 0.0) And (v(ZZ) = 0.0) Then IsVectorZero = vbTrue
End...





