EM_Z Trajectory

This short but effective script is selecting the highest point of a cloud and then drawing a trajectory from this one to the next one in terms of height until it reaches the lowest point. That is a nice starting for the machine to know how to remove tires from a mountain given their center points.

 

Option Explicit
‘If it is working then scripted by Eduardo Mayoral
‘If Not scripted by anyone else
‘Script version Saturday, October 04, 2008 5:40:27 PM

Call Trajectory()
Sub Trajectory()

 ‘============================================
 ‘  Points Selection
 ‘============================================
 
 Dim arrStPt : arrStPt = Rhino.GetPointCoordinates(“Select Points”)
 Dim i, j
 
 For i = 0 To UBound(arrStPt)  

  Dim arrPts, arrBBox, maxZ, arrPt, pt
 
  arrPts = ObjectsByType(1)
  
  ‘============================================
  ‘  Getting Highest Point
  ‘============================================
  
  arrBBox = Rhino.BoundingBox(arrPts)

  maxZ = arrBBox(4)(2)
  ‘Rhino.Print(maxz)
          
  For Each arrPt In arrPts
     
   pt = Rhino.PointCoordinates(arrPt)
       
   If Abs(pt(2)- maxZ) <= 0 Then
      
    arrStPt(i) = Rhino.PointCoordinates(arrPt)
    Rhino.DeleteObject(arrPt)
                       
   End If
   
  Next
 
 Next
 
 ‘============================================
 ‘  Drawing Trajectory
 ‘============================================
 
 For j = 1 To UBound(arrStPt)
  
  Dim k : k = j-1
  Dim Lines, Trajectory
  
  Call Rhino.AddLine(arrStPt(j), arrStPt(k))
   
 Next
 
 Lines = Rhino.ObjectsByType(4)
 Trajectory = Rhino.JoinCurves(Lines)
 Rhino.DeleteObjects(Lines)
 
End Sub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com 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