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

Issues with FormattedText

Hello all,

 

I wanted to remove style overrides from our titleblock. As there are many, many textboxes, I wanted to do this in an automated way.

There seems to be an issue with writing to FormattedText property.

 

The code is like

 Inventor.Application invApp;
            invApp = (Inventor.Application)System.Activator.CreateInstance(System.Type.GetTypeFromProgID("Inventor.Application"));
            
            DrawingDocument drawDoc = (DrawingDocument)invApp.Documents.Open(@"Z:\_pdm\flg\Administration\Inventor\2014\Templates\Drawing_DE_EN.dwg");

            TitleBlock tBlock = drawDoc.ActiveSheet.TitleBlock;

            DrawingSketch sketch = tBlock.Definition.Sketch;

            TextBoxes tboxes = sketch.TextBoxes;

            foreach(TextBox tbox in tboxes)
            {
                
                tbox.Style = drawDoc.StylesManager.TextStyles["Iso"];

                String text = tbox.FormattedText;
                tbox.FormattedText=tbox.FormattedText.Replace("ISOCPEUR", "ISOCP");
                

            }

            drawDoc.SaveAsInventorDWG(@"c:\temp\test.dwg",true);

even if I say

tbox.FormattedText = tbox.FormattedText 

without changing anything, this still causes an exception.

 

Best regards

Erik