Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Appending FormattedText - Labels

NachitoMax
Advisor

Appending FormattedText - Labels

NachitoMax
Advisor
Advisor

Hey

 

Struggling a little with appending a drawing view label. My labels are like this

FORMATTEDTEXT.jpg

I am trying to append some text to the location of the red box. If the text is already there, i want to remove it and replace it. This is how i am doing it

Dim RefText As String = "-REF-"

'example text - (SCALE - 1" = 1'-0") -REF- A101/2
'split the string at RefText to capture only the left side
Dim ChkSplitStr() As String = Split(ThisView.Label.Text, RefText)

'find the end of the formatted text next to the scale
If Strings.Right(ChkSplitStr(0), 1) = ")" Then

   'split the formatted text at RefText
   Dim SplitStr() As String = Split(ThisView.Label.FormattedText, RefText)

   'create the StyleOverride text for the append text
   Dim FormattedString as String = "<StyleOverride Font='Arial' FontSize='.025' Bold='True' Italic='False' Underline='False'>-REF- A101/2</StyleOverride>"

   'remove any right side text by using the left side formatted text
   ThisView.Label.FormattedText = SplitStr(0) & FormattedString

Sometimes it works, sometimes it doesnt. Mostly, i am getting the actual formatted string appended to the label as text instead of formatted text so, my label ends up like this

 

f2.jpg

What is the best way to append FormattedText?

 

Thanks

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Reply
358 Views
2 Replies
Replies (2)

WCrihfield
Mentor
Mentor

When I'm modifying an existing FormattedText string, I usually use something like an InputBox (or txt file), and set the current FormattedText as the default value, to return the selectable existing string.  Then I copy/paste that back into my code and add/edit it, to make the changes I want. 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

marcin_otręba
Advisor
Advisor

hi,

could you share drawing with your label on it, or copy paste label formatted text here ?
This is (probably) problem from text wrong formatting only.

 

0 Likes