Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do I adjust justification of a dimension text of a vertical linear dimension to be on the left or right side of the dimension?

1 REPLY 1
Reply
Message 1 of 2
ssamuel466QW
101 Views, 1 Reply

How do I adjust justification of a dimension text of a vertical linear dimension to be on the left or right side of the dimension?

Hello, 

 

I have very little programming knowledge but I came across this post that allowed you to automatically justify the dimension text of a horizontal linear dimension to be in the center. I want to do something similar, but with vertical linear dimensions. I want the dimension text to be either on the left or right of the dimension line. Can someone please help me with this? see attached pic for example.2023-01-04_12h16_04.png @RPTHOMAS108 

1 REPLY 1
Message 2 of 2
RPTHOMAS108
in reply to: ssamuel466QW

That is more involved since you need to know the text width. 

 

You would have to establish the value of half the width of the text outside the RevitAPI. Within the API there is TextElement.Width but that is on text notes. People often use FormattedText.Width class which is part of WPF or there is a similar functionality in the older GDI+ namespaces: System.Drawing.Graphics.MeasureString (no longer will you wonder 'how long is a piece of string').

 

You have to match the various font properties which is the awkward part. You may wonder for example about such aspects as 'what is an emSize value' and the answer will be: the desired height of the fonts M character. Therefore WPF version is generally more straightforward to use.

 

Obviously either way the font units you set to be measured and the values you get back will be related to screen units so they need to be converted to and from physical units (mm/ft...) and scaled by view scale.

 

From that point on the principle is the same as the macro i.e. you are offsetting the text from its current position in a certain vector direction by an amount.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups


Rail Community