TextNote Leader start point

Hello. I have been trying to expand my programming knowledge by using Python nodes to access RevitAPI within Dynamo. I am currently stuck on how to access the location of the point circled in red in the picture below.

I have been looking into Revit’s API extensively and cannot find any reference to that point. I have also been trying to use the height of the total textnote and just halving it but to no avail. It has no boundingbox attribute.

The goal is to redo all the leaders on selected textnotes so that the angle at the elbow is always 135 degrees. I am almost done except that the line between the elbow and TextNote is not horizontal. The python script is messy and has unused variables but I can clean it up after it works. Any info would be greatly appreciated!

import clr
from Autodesk.DesignScript.Geometry import *
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Plumbing import *
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
import math

#The inputs to this node will be stored as a list in the IN variables.
doc = DocumentManager.Instance.CurrentDBDocument
textNote = UnwrapElement(IN[0])
textType = textNote.TextNoteType
textSize = textType.GetParameters('Text Size')


textLoc = textNote.Coord
textW = textNote.Width
textH = textNote.Height
textX = textLoc.X
textY = textLoc.Y
leaderStart = XYZ(textX,textY,textLoc.Z)
leader = textNote.Leaders
leaderEnd = []
for i in leader:
	leaderEnd = i.End
	j = leaderStart.Y-leaderEnd.Y
	elbowX = leaderEnd.X-j
	elbowY = leaderStart.Y
	leaderElbow = XYZ(elbowX,elbowY,leaderStart.Z)
	newLeader = textNote.AddLeader(TextNoteLeaderTypes.TNLT_STRAIGHT_R)
	newLeader.End = leaderEnd
	newLeader.Elbow = leaderElbow

OUT = 0
1 Like

Have you looked at this post for getting the bounding box?

1 Like

After a little searching it seems like you can get the leader points pretty easily.

import clr
import Revit
from Autodesk.Revit.DB import *
#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
textNote = UnwrapElement(IN[0])
output = []
leaders = textNote.GetLeaders()

for leader in leaders:
	out = []

#Assign your output to the OUT variable.
OUT = output

EDIT: Updated code to return points as Dynamo objects.


Thank you for the replies. Sorry, I forgot to mention that I am using Revit 2015, for which the Leader.Anchor is not in the API.

So I tried using bounding box again using your link but have run into problems.

  1. Even if I remove the leaders before calling the boundingbox, it still encapsulates the entire area including the previous leader.
  2. Then I tried taking the boundingbox.Max.Y and subtracting the textnote.Height but for some reason the Height is not on the same scale as the actual text height, so it barely moves from the max point.

I am kind of lost at why the scale is so off between RevitAPI coordinate values and actual project values.