Skip to content

Instantly share code, notes, and snippets.

@Alliages
Created April 19, 2017 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Alliages/63669c593b087321d436d47dcdb6459f to your computer and use it in GitHub Desktop.
Save Alliages/63669c593b087321d436d47dcdb6459f to your computer and use it in GitHub Desktop.
Rhinoscript that select objects according to their area
Option Explicit
'Script written by Guillaume Meunier
'Script copyrighted by Guillaume Meunier
'Script version Tuesday, 11 April 2017 17:10:45
'Select all surfaces inferior to xx
'If selection select inside selection
'Everything must be exploded
Call Main()
Public g_min_Surf
Sub Main()
Dim nSurf, arr, strSurf, min_Surf, count, arrObjects
' Initialize global variables, if necessary
If IsEmpty(g_min_Surf) Or IsNull(g_min_Surf) Then g_min_Surf = 1.0
' Prompt for minimum height
min_Surf = Rhino.GetReal("Maximum surface", g_min_Surf, 0.0)
If IsNull(min_Surf) Then Exit Sub
arrObjects = Rhino.SelectedObjects
If IsArray(arrObjects) Then
arr = arrObjects
Rhino.UnselectObjects arrObjects
Else
arr = Rhino.ObjectsByType(8 + 16)
End If
If Not IsArray(arr) Then
Rhino.Print "No point objects to select"
Exit Sub
End If
count = 0
For Each strSurf In arr
nSurf = Rhino.SurfaceArea(strSurf)
If IsNull(nSurf) Then
Rhino.Print "OBJECT ERROR"
' Call Rhino.SelectObject(strSurf)
End If
If IsArray(nSurf) Then
If nSurf(0) < min_Surf Then
Call Rhino.SelectObject(strSurf)
count = count + 1
End If
End If
Next
Rhino.Print "DONE : " & CStr(count) & " surfaces selected"
' More initialization
g_min_Surf = min_Surf
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment