rvb Curve Divison

rvb animation snippet example

A little piece of code that shows how to divide a curve in a user-defined number of pieces that then will be used as centerpoints to copy planes -this last part will help you understand how local coordinates relate to global XYZ coordinates.

Option explicit

'Script written by Adolfo Nadal

'Script by archiologics · www.archiologics.com

Call CurveParameter()

Sub CurveParameter()

Dim strCurve

Dim intDivisions

Dim arrCurveDom

Dim dblParameter

Dim arrPoint

Dim vecTangent, arrPlane, strCircle

Dim dblRadius : dblRadius = 2

strCurve = rhino.GetObject("select curve",4,vbTrue)

intDivisions = rhino.GetInteger("enter number of divisions",100,1)

arrCurveDom = Rhino.CurveDomain (strCurve)

Dim i

For i = 0 To intDivisions

dblParameter = i * ((arrCurveDom(1) - arrCurveDom(0)) / intDivisions)

arrPoint =rhino.EvaluateCurve(strCurve,dblParameter)

Call rhino.addPoint(arrPoint)

vecTangent = Rhino.CurveTangent(strCurve, dblParameter)

arrPlane = Rhino.PlaneFromNormal (arrPoint, VecTangent)

Call AddSquare(arrplane)


End Sub

Function AddSquare(arrPlane)

Dim arrpoints(3)

Dim dblSize :dblSize = 1

arrPoints(0) = rhino.XformCPlaneToWorld(array(5 * dblSize,dblSize,0),arrPlane)

arrPoints(1) = rhino.XformCPlaneToWorld(Array(-5 * dblSize,dblSize,0),arrPlane)

arrPoints(2) = rhino.XformCPlaneToWorld(Array(-5 * dblSize,-dblSize,0),arrPlane)

arrPoints(3) = rhino.XformCPlaneToWorld(Array(5 * dblSize,-dblSize,0),arrPlane)


End Function