Text Bounding Box? (to help with 2017 text problems)

Is there such a thing as a Bounding Box for Revit Text in Dynamo?
The Geometry.BoundingBox node gives me an “operation failed” error regardless of whether I feed it a single node or a
list.

Here’s my idea, which I hope would help identify problems in upgrading to 2017
Before converting a project to 2017, run a Dynamo Definition that would Export the Bounding boxes for everyt Text Note in a project.
Upgrade the project to 2017 and run part 2 part the Definition, which would import the information exported from 2016 and compare it to the Bounding Boxes in 2017.
Any differences in the Height of the Bounding Box would mean that the Text had wrapped onto extra lines.
The affected Text could then be color-coded, or somehow reported as a list for the user to investigate/correct.
Theoretically, any unaffected text would still have the same Bounding Box.

But step one is to FIND those Bounding boxes.

a.) Is there an available Text Bounding Box
b.) Does my idea sound like it has any merit?

Element.Bounding box may be the more appropriate node to try. But I’m quite sure that will fail too.

Considering that the way text height is measured has changed in 2017 and that there is no real common rule that applies uniformly across all characters, your idea could be a good way to identify affected text blocks. provided you find a way.

Hello DaveP,

The bounding box from text notes is quite easy to get via the API:

1 Like

Clockwork has element.bounding box available already.

Thanks for the suggestions, gentlemen.
Vikram, you are correct. Element.BoundingBox fails the same as Geometry.BoundingBox
Einar, I’m raw enough at dynamo without trying to get into Python/API in addition, so that’s why I didn’t try to go that route. I’ll try replicating your code. Thanks.
Jon, I saw BoundingBox.ByElement, but since I want to look at Text Notes, which only appear in one View, I was hoping to avoid the extra complication of figuring out which View each instance of the Text appears in.
Then I tried your Element.OwnerView node and got the attached error:

This seems to work for me:

3 Likes

What kind of view is it in?

Doesn’t seem to matter.
I tried again with a Floor Plan, a Legend, and a Drafting View and got the same error for all.
I’m still on Dynamo 0.9.2 and Clockwork 0.90.6 if that matters.
I’m using a couple of nodes from Archi-Lab and it looks like Konrad hasn’t upgraded to 1.0.0 yet.

What if you try to go the other way around, first find the views and then the text notes: (all custom nodes are clockwork)

Haven’t had a chance to work on this lately, just getting back to it now.
In the meantime, I’ve upgraded Dynamo and the Packages to 1.0.0.
Either that or the Flatten Einar suggested seems to have fixed the original problem I was having.
But now all I’m getting is Empty Lists as output from the BoundingBox node.
I’ve replicated the first part of Einar’s May 20 post and I have valid lists going in, but Empty Lists coming out.


I’m also a bit curious what the ListGroupByKey node accomplishes.

You forgot to set lacing to longest on the bounding box node. Good question about that grouping, it dosen’t make sense, I think you can just skip that step.

getTextWidthAndHeight.dyn (6.7 KB)
compareTextWidthAndHeight.dyn (11.4 KB)

The python script (Clockworks Element.ByID doesn’t work in Revit 2017)

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

ids = IN[0]
elements = []
for id in ids:
	elements.append(doc.GetElement(ElementId(id)).ToDSType(True))
OUT = elements
1 Like

Hi @Einar_Raknes, @john_pierson, would you know of a method to modify/ resize a text note bounding box? Just upgraded a Revit file and many text notes were chopped off because of the text wrapping feature. I want to resize all the text notes in different views but this doesn’t seem to be the correct node. Thanks in advance.

@ddelarosa Maybe you can just use the Width property to scale the text witdh with a certain factor. Here is an example that increases the width by 20 % (MANUAL MODE ONLY!)

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

#Preparing input from dynamo to revit
if isinstance(IN[0], list):
	textNotes = UnwrapElement(IN[0])
else:
	textNotes = [UnwrapElement(IN[0])]
	
scale = IN[1]

#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
for textNote in textNotes:
	width = textNote.Width
	textNote.Width = width*scale
TransactionManager.Instance.TransactionTaskDone()

OUT = 0
2 Likes

@ddelarosa
I’ve done something on a very simple file. I noticed that, when recreating a textnote using parameters from the existing ones, the new textnotes align on one single line and the cropbox is adapted to the length of the text. So what I did is:

  • first storing the ID’s of the existing textnotes in an external file
  • then create new textnotes from the existing
  • and lastly deleting the old ones using ID’s from the external file.
    Not sure it helps as such but I wanted to share anyway…
1 Like