Site Tools


Select Points with a Specified Z Coordinate

Developer: RhinoScript
Summary: Demonstrates how to select point objects with a user-specified z coordinate using RhinoScript.

Example

The following example RhinoScript demonstrates how to select point objects with a user-specified z coordinate.

 Option Explicit 
 
 Sub SelZ()
 
   Dim arr
   arr = Rhino.ObjectsByType(1)
   If Not IsArray(arr) Then
     Rhino.Print "No point objects to select"
     Exit Sub
   End If
 
   Const zero_tol = 1.0e-12
 
   Dim z, obj, pt
   z = Rhino.GetReal("Z coordinate", 0.0)
   If IsNumeric(z) Then
     For Each obj In arr
       pt = Rhino.PointCoordinates(obj)
       If IsArray(pt) Then
         If Abs(pt(2)-z) <= zero_tol Then
           Rhino.SelectObject obj
         End If
       End If
     Next
   End If
 
 End Sub

Here is the toolbar button macro version.

_-NoEcho
_-RunScript (
arr = Rhino.ObjectsByType(1)
If IsArray(arr) Then
z = Rhino.GetReal("Z coordinate", 0.0)
If IsNumeric(z) Then
For Each obj In arr
pt = Rhino.PointCoordinates(obj)
If IsArray(pt) Then
If Abs(pt(2)-z) <= 1.0e-12 Then
Rhino.SelectObject obj
End If
End If
Next
End If
End If
)


developer/scriptsamples/selz.txt ยท Last modified: 2015/09/14 (external edit)