Replace Text in Text Note and keep formatting

Replace Text in Text Note and keep formatting

Anonymous
Not applicable
2,205 Views
8 Replies
Message 1 of 9

Replace Text in Text Note and keep formatting

Anonymous
Not applicable

I have an API that will update parameters in both 3D families and 2D families. Some of those parameters are also included in Text Notes in Details and General Notes. I can replace the text in the the Text Notes but the pieces of the the Text Note that is underline is now not underlined. It seems my only options are either to underline the entire Text Note or none of it.

 

Example Text.

 

[C] FLAT PANEL DISPLAY BOX J6(N2,P2)
FSR PWB-250 WALL BOX. ASSEMBLY COMES STANDARD WITH QTY-1 LOW VOLTAGE ENTRY BOX. ORDER ADDITIONAL LOW VOLTAGE ENTRY BOX FSR PART NO. PWB-250-AVBB OR RACO 565 (SEE DETAIL 4/AV401 FOR APPROPRIATE LOCATIONS), SEE CONDUIT RISER DRAWINGS FOR REQUIRED QUANTITY. TERMINATE CONDUITS TO UPPER OR LOWER LOW-VOLTAGE ENTRY BOXES.  (P2) DUPLEX RECEPTACLE INSTALLED IN PASS-THRU ENCLOSURE, AND (N2) INSTALLED IN LOWER ENTRY BOX WITH A SINGLE GANG BACK BOX (NOT INCLUDED WITH PWB-250).  AT EACH PWB-250 LOCATION SUPPLY A FLAT PANEL DISPLAY MOUNT SEE DETAIL 5/AV401.

 

My API would replace the numbers J6, N2, or P2. You can see they are both underlined and not underlined within the Text Note.

 

Does anyone know how I can keep the fomatting?

Accepted solutions (1)
2,206 Views
8 Replies
Replies (8)
Message 2 of 9

saikat
Autodesk
Autodesk
Accepted solution

I am sorry formatting of TextNotes (or even words that are part of TextNotes) are not possible at the moment. The Development team is aware of this request for API users.

 

Sorry for the bad news.

cheers



Saikat Bhattacharya
Senior Manager - Technology Consulting
Message 3 of 9

Anonymous
Not applicable

Any more updates on this? Looks like its 2013 and the API still provides extremely limited text manipulation functionality.

0 Likes
Message 4 of 9

Anonymous
Not applicable

This appears to still be an issue in 2015. Not only can we not preserve the formatting, we have no way of knowing that it is even there. This leads to stripping the formatting unintentionally.

 

We consider code that makes unintended changes to be a large problem.

0 Likes
Message 5 of 9

arnostlobel
Alumni
Alumni

Dear Jesika DiGregorio,

 

It is indeed very unfortunate that we are still unable to offer proper API for text formatting. And to make the matter worse, I must admit there will not be any significant changes in 2016 still. However, and that is good news, believe me, we have an entire team dedicated to make improvements to text, thus there appears to be very bright light at the end of the tunnel, finally. The team has not made the cut for the next 2016 release, but our hope is that they will finish their job in quite foreseeable future.

 

Again, I am sorry I cannot offer any better news at this moment. And I cannot talk about particular details of future development either. However, I do have an interest in what you suggested. Having an option “to at least know that text contains in-line formatting that might get lost” is an interesting idea. I will raise that as an intermediate option to the team. It sounds like something that could be done rather shortly.

 

Thank you for the suggestion.

Arnošt Löbel
Message 6 of 9

SamBerk
Advocate
Advocate

Hi @arnostlobel 

Do you have some updates about this?

0 Likes
Message 7 of 9

JesikaDG
Contributor
Contributor

The API changes came in 2017, but there is a lot of code needed to support it. There is no simple HasFormatting call, but many for the different types of formatting.

 

Also the code should break down the text will change from the text that won't so the the formatting problem is more isolated. Even then there are cases where the text might span a formatting change and choices will need to be made.

 

It would be possible to interpret the formatting into a GUI, but it won't be natively supported. The translation of the GUI formatting and the Autodesk formatting has to be written out.

 

We handled editing the text but not the formatting in our software, specifically Ideate BIMLink and Ideate Spellcheck.

0 Likes
Message 8 of 9

Revitalizer
Advisor
Advisor

Hi,

 

the class you need is "FormattedText".

 

You can get an instance by yourTextNote.GetFormattedText();

 

Modify this object and re-assign it using yourTextNote.SetFormattedText(yourModifiedObject).

 

A sample from the RevitAPI.chm:

 

    FormattedText formatText = textNote.GetFormattedText();

    TextRange range = formatText.AsTextRange();

    range.Start = range.End - 1;
    // set Length to 0 to insert
    range.Length = 0;
    string someNewText = "\rThis is a new paragraph\vThis is a new line without a paragraph break\r";
    formatText.SetPlainText(range, someNewText);

    // get range for entire text
    range = formatText.AsTextRange();
    range.Start = range.End - 1;
    range.Length = 0;
    string someListText = "\rBulleted List item 1\rItem 2\vSecond line for Item 2\rThird bullet point";
    formatText.SetPlainText(range, someListText);
    range.Start++;
    range.Length = someListText.Length;
    formatText.SetListType(range, ListType.Bullet);

    if (formatText.GetAllCapsStatus(range) != FormatStatus.None)
    {
        formatText.SetAllCapsStatus(range, false);
    }

    textNote.SetFormattedText(formatText);

The method for underlining is "SetUnderlineStatus", obviously.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 9 of 9

Clntnco
Enthusiast
Enthusiast

do you know how to retrieve the existing formatting? I need to find the hard returns "\r" in a textnote.