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)
  If Abs(arrStPtCoord(i)(2)- maxZ) <= 0 Then
   arrStPt(i) = Rhino.PointCoordinates(arrPts(j))
  End If
 ‘  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
 Call Rhino.SelectObjects(arrLine)
 Call Rhino.JoinCurves(arrLine,True)
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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s