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. @RPTHOMAS108
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.