Assign Layers by Curve lengths

This RhinoScript assigns curves of different lengths to different layers allowing the user to specify the level of accuracy of measurement. I have used this script to create part counts for geodesic domes.

Geodesic Dome Members With Layer Assignment by Curve Length
Option Explicit
‘Script written by <Ayodh Kamath>
‘Script copyrighted by <Ayodh Kamath>
‘Script version Tuesday, July 28, 2009 9:01:51 PM
Call Main()
Sub Main()
Dim arrLines, intLinesNum, i, j, realTolerance
Dim realTempLineLength, intCount, intLengthEquality, strOutput, arrSort, realTotalLength
arrLines = Rhino.ObjectsByType(4, vbTrue)
intLinesNum = UBound(arrLines)
intCount = 0
realTolerance = Rhino.GetReal(“Give decimal places for rounding:”)
For i = 0 To intLinesNum
realTempLineLength = Round(Rhino.CurveLength(arrLines(i)), realTolerance)
If i = 0 Then
ReDim Preserve arrLengths(intCount)
arrLengths(0) = realTempLineLength
Rhino.AddLayer CStr(realTempLineLength)
Rhino.ObjectLayer arrLines(0), CStr(realTempLineLength)
End If
intLengthEquality = 0
For j = 0 To intCount
If realTempLineLength = arrLengths(j) And i<>0 Then
intLengthEquality = 1
Rhino.ObjectLayer arrLines(i), CStr(realTempLineLength)
End If
If intLengthEquality <> 1 And i<>0 Then
intCount = intCount+1
ReDim Preserve arrLengths(intCount)
arrLengths(intCount) = realTempLineLength
Rhino.AddLayer CStr(realTempLineLength)
Rhino.ObjectLayer arrLines(i), CStr(realTempLineLength)
End If
realTotalLength = realTotalLength+realTempLineLength
strOutput = “The number of curve lengths is: “&(intCount+1)&”. The total lengths of members is: “&realTotalLength&”. These lengths, in ascending order, are: “
arrSort = Rhino.SortNumbers(arrLengths)
For Each i In arrSort
strOutput = strOutput&CStr(i)&”, “
If i<(UBound(arrSort)-1) Then
realTotalLength = arrSort(i)+arrSort(i+1)
End If
Rhino.TextOut strOutput
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 )

Google+ photo

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


Connecting to %s