(n)certainties – Columbia – Fall 2008

EM_Z Trajectory 02

This script is a more complete alternative to the first Z Trajectory one. Is recognizing the highest point and drawing a line from it to the lowest one:

Option Explicit
‘If it is working then scripted by Eduardo Mayoral
‘If Not scripted by anyone else

Call Trajectory()

Sub Trajectory()

 ’============================================
 ’  Points Selection
 ’============================================
 
 Dim arrPts, arrStPt, arrStPtCoord()
 Dim i, j
 Dim arrBBox, maxZ, arrPt, pt

 arrStPt = Rhino.GetObjects(“point”,1)
 arrPts = arrStPt
 
 For i = 0 To UBound(arrStPt)
  
  ReDim Preserve arrStPtCoord(i) : arrStPtCoord(i) = Rhino.PointCoordinates(arrStPt(i)) 
  
  ’============================================
  ’  Getting Highest Point
  ’============================================
  
  arrBBox = Rhino.BoundingBox(arrPts)

  maxZ = arrBBox(4)(2)
  ’Rhino.Print(maxz)
                    
  If Abs(arrStPtCoord(i)(2)- maxZ) <= 0 Then
      
   arrStPt(i) = Rhino.PointCoordinates(arrPts(j))
   Rhino.DeleteObject(arrPts(j))
                       
  End If
   
 Next
 
 ’============================================
 ’  Drawing Trajectory
 ’============================================
 
 Dim arrLine()
 Dim m : m=0
 
 For j = 1 To UBound(arrStPtCoord)
  
  Dim k : k = j-1   
  ReDim Preserve arrLine(m)
  arrLine(m) = Rhino.AddLine (arrStPtCoord(j), arrStPtCoord(k))
  m= m+1
  
 Next
  
 Call Rhino.SelectObjects(arrLine)
 Call Rhino.JoinCurves(arrLine,True)
 
End Sub

Leave a Comment

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment