Scripting a leader

How to get the first two points of a leader with ortho turned off and the final point with ortho turned on.

It seems like it would be easy peazy, but…

Hi Cliff,

_SetOrtho _Off _Leader _Pause _Pause _SetOrtho _On

or simply press the Shift key to toggle Ortho while picking the points.

Thx, Jess.

Here’s what I now have:

strBlock = Rhino.GetObject("Select block: ", 4096)
strName = Rhino.BlockInstanceName(strBlock)
Rhino.Command"_SetOrtho _Off _Leader _Pause _Pause _SetOrtho _On _Pause _strName "

How do I get the block name into the leader and dispense with the text input dialog without the user seeing it at all?

You might also look at this:

https://github.com/mcneel/rhinoscript/blob/master/BlockLeader.rvb

Hi Cliff, here a modification with the ortho constraints.

Option Explicit

Sub BlockLeader()
  
  Dim arrBlock
  
  arrBlock = Rhino.GetObject("Select block instance", 4096, True)
  If IsNull(arrBlock) Then Exit Sub
  
  Dim strName  
  strName = Rhino.BlockInstanceName(arrBlock)
  
  Dim aP1, aP2, aP3
  Dim strTempLine
  
  Call Rhino.Ortho (False)
  
  aP1 = Rhino.GetPoint("Tip of leader arrow")
  If IsArray(aP1) then 
    aP2 = Rhino.GetPoint("Next point of leader", aP1)
    If IsArray(aP2) then 
      strTempLine = Rhino.Addline(aP1, aP2)
      Call Rhino.Ortho (True)
      aP3 = Rhino.GetPoint("End point of leader", aP2)
      If IsArray(aP3) Then
        Call Rhino.AddLeader(array(aP1,aP2,aP3), , strName) 
      End If
      Call Rhino.DeleteObject(strTempLine)
    End If
  End If
  
End Sub

Call BlockLeader()


Perfect. Thank you both so much.