1: run trajectory.rvb
2: run splitcurves.rvb

1: trajectory
Option Explicit

‘Script written by
‘Script will prompt user for existing point(s)

Call Trajectory()
Sub Trajectory()

Dim FrstPt : FrstPt = Rhino.GetPointCoordinates (“first pts”)
If IsNull (FrstPt) Then Exit Sub
Dim CPts(), trajec()
Dim i, q, v
For q = 0 To Ubound(FrstPt)

Dim count : count = 9 ‘CInt( random(3,9))
ReDim CPts(count) : CPts(0) = FrstPt(q)

For i=1 To count

ReDim Preserve RPts(i)
ReDim Preserve SPts(i)
ReDim Preserve trajec(i-1)
ReDim Preserve arrPoints(i-1)

v = i-1
CPts(i) = Rhino.PointAdd(CPts(v), funcVector(CPts,v))
trajec(v) = Rhino.AddLine (CPts(v), CPts(i))
‘Rhino.AddPoint (CPts(i))


Dim trajectory, trPt, strCurve
trajectory = Rhino.JoinCurves (trajec,True)
trPt = Rhino.CurveEditPoints(trajectory(0))
strCurve = Rhino.AddInterpCurve(trPt) ‘thanks Adolfo

Call Rhino.AddLayer (“trajectory”, RGB(255,0,0))
Call Rhino.AddLayer (“curves”, RGB(255,0,255))
Call Rhino.ObjectLayer (trajectory, “trajectory”)
Call Rhino.ObjectLayer (strCurve, “curves”)


End Sub

Function random(min,max)
random = (max-min) * Rnd + min
End Function

Function funcVector(CenterPoint,n)

Dim x, y, z
Dim min : min = 50
Dim max : max = 250

‘If CenterPoint(n)(0) > CenterPoint(0)(0) Then
If CenterPoint(n)(0) > 0 Then
x = random(-max,min)
x = random(-min,max)
End If

‘If CenterPoint(n)(1) > CenterPoint(0)(1) Then
If CenterPoint(n)(1) > 0 Then
y = random(-max,min)
y = random(-min,max)
End If

z = random(250,500)

funcVector = Array(x, y, z)

End Function

2 Split Curve
Option Explicit

‘Script written by
‘script will prompt user for existing curves

Call Main()
Sub Main()

Dim crvObjectsT : crvObjectsT = Rhino.GetObjects(“Pick curve(s)”, 4)
If IsNull(crvObjectsT) Then Exit Sub

Dim intL : intL = 1000

Dim k : k = -1

Dim i
For i = 0 To Ubound(crvObjectsT)

Dim crvDomain : crvDomain = Rhino.CurveDomain(crvObjectsT(i))
Dim crvLength : crvLength = Rhino.CurveLength(crvObjectsT(i))

Dim intUnits : intUnits = CInt(crvLength/intL)

If intUnits > 1 Then
Dim arrCrvP : arrCrvP = Rhino.DivideCurve (crvObjectsT(i), intUnits , True, False)
Dim crvObjects : crvObjects = Rhino.SplitCurve (crvObjectsT(i), arrCrvP)
Dim j
For j = 0 To ubound(crvObjects)
Call Rhino.RebuildCurve (crvObjects(j),5,6)
End If

End Sub

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