Measuring Text Length

Hello everyone,

I am trying the way to measuring length of a text. Basically, I want to adjust the viewport extension line to fit within the title on sheet. I have made a script to adjust the line. The only problem I am facing now is to measuring the length of the content in the title on sheet.
It’s hard to measure the length based on number of characters in the text because each character has different length, also differs based on font.
Does anyone have an idea?
Thank you for your support


@tranduytankts

you can use BoundingBox and messure length…

Hi, how can I make a boundingbox from a string. Actually, it’s not an annotation in Revit. It’s just a string content, so I don’t know how to get a boundingbox from it. Can you advise me?

@tranduytankts

grafik

you can get all length, are, even intersections …

Hi @tranduytankts you can get the BBbox from label this way here if it can help

1 Like

here is way there probably could work…but guess its very similar to what you already try

Revit_Ux7ElAfsZi

1 Like

Yeah, finally I can solve it. Here below is the code. Just that I need to convert from mm to feet before feeding into the last node.
Also, before run the script, I need to set the extension line to 0 so that I can take the boundingbox of the label correctly. You know as default by Revit, when you place a new view, the extension line is super long, which make the boundingbox of viewport label longer.
Thank you for your help

1 Like

Hi @tranduytankts,

Here’s an example of how you can automatically adjust all viewports based on the length of their title values.
SAMPLE 1.dyn (37.5 KB)