Get BoundingBox of the Text on the Dimension

siknue
Explorer
Explorer

Get BoundingBox of the Text on the Dimension

siknue
Explorer
Explorer

would you tell me how to get the bounding box of the text on the dimension like seen in attached screenshot using Revit API?

I want to detect whether those texts on two dimensions overlap or not.

 

shingoikenoueYRUK8_0-1730105803407.png

 

0 Likes
Reply
405 Views
6 Replies
Replies (6)

jeremy_tammik
Autodesk
Autodesk

Please read the existing questions and answers on this topic first, e.g., by searching this forum for something like "dimension text bounding":

  

  

Please let us know if anything remains unclear and how you end up solving this. Thank you.

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open

siknue
Explorer
Explorer

 

 

0 Likes

siknue
Explorer
Explorer

Thank you for your information.
I followed the solution for the topic and almost solved

 

I added TextNoteOptions to align with angled dimensions by retrieving directional information from the target dimension.

This works well when the dimension is parallel to an axis. However, for rotated dimensions, the location of the TextNote does not perfectly match the position of the dimension text and appears slightly offset."

 

I would be grateful if you could give me some advice

Thank you

 

TextNoteOptions options = new TextNoteOptions(newId);
options.HorizontalAlignment = HorizontalTextAlignment.Center;
options.VerticalAlignment = VerticalTextAlignment.Bottom;
//GeometryUtil.getAngle is the function I made to obation declination of the dimension
options.Rotation = GeometryUtil.getAngle(dimension);

 

shingoikenoueYRUK8_2-1730853925656.png

0 Likes

ctm_mka
Advocate
Advocate

There is a "Text Offset" within the Dimension Style, are you accounting for that when placing the TextNote?

0 Likes

siknue
Explorer
Explorer

Thank you for your reply!

 

I`m putting TextNote with the "TextPosition" property of the Dimension as "Coord" property.

 

TextNote note = TextNote.Create(doc, doc.ActiveView.Id, dimension.TextPosition, dimension.ValueString.Trim(), options);

 

 

I guess  that "Text Offset" is a value shown in Revit application not API and an aspect of the "TextPosition" property.

if possible, would you please tell me how to obtain the parameter in Revit API?

 

0 Likes

ctm_mka
Advocate
Advocate

it is available in the API, something like this:

DimensionType dimtype = dimension.Dimensiontype;
Double offset = dimtype.LookupParameter("Text Offset").AsDouble();
0 Likes