- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Try
String text = tbox.FormattedText;
tbox.FormattedText=text.Replace("ISOCPEUR", "ISOCP");Or even:
String text = tbox.Text;
tbox.Text=text.Replace("ISOCPEUR", "ISOCP");That's what I would try...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
that has been my first try. Somewhere on the internet it says there might be problems with custom iProperties.
tbox.Text cannot be used in my opinion, as I do not want to change the text but the formatting.
Best regards
Erik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Solved it.
I forgot to enter edit mode for the titleblock sketch
tBlock.Definition.Edit(out sketch);
That did the trick.
Best regards
Erik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Erik,
I had the same problem some time ago, I tried to change the formatted text with the "Replace" function and something went wrong.
Then I've tried the following solution and it started working properly
Bregs
Rossano Praderi
--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------