Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:scriptsamples:selz [2015/09/14] (current)
Line 1: Line 1:
 +====== Select Points with a Specified Z Coordinate ======
 +> **Developer:​** //​[[developer:​rhinoscript|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.
 +
 +<code vb>
 + ​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
 +
 +</​code>​
 +
 +Here is the toolbar button macro version.
 +
 +<code vb>
 +_-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
 +)
 +</​code>​
 +
 +\\
 +
 +{{tag>​Developer RhinoScript}}
  
developer/scriptsamples/selz.txt ยท Last modified: 2015/09/14 (external edit)