D.S

adndevblog.typepad.com

Remove illegal text formatting - Manufacturing DevBlog

Remove illegal text formatting - Manufacturing DevBlog Manufacturing DevBlog The resource for software developers working with Design, Lifecycle and Simulation technologies from Autodesk. Home Subscribe Follow Useful Links Autodesk About this Blog « Cast between COM types in C++ | Main | Cloud and AppStore Usage Grows – Portathon Reminder » 09/10/2013 Remove illegal text formatting By Adam Nagy Not sure how you end up with text formatting in DrawingNote's where the Font is set to nothing, i.e. the DrawingNote.FormattedText contains things like this: <StyleOverride Font=''> Maybe the Font type being used on the system where the drawing was created does not exist on the other system where the drawing has been opened?  Unfortunately, this seems to cause issues when exporting your drawing to other formats like PDF or DWF and you will get a message like the following: ... and the exported document might contain illegible text: If you know the exact problem you are looking for - in our case Font='' - then you could simply remove these from the FormattedText of the notes. In case of VBA you could use the Microsoft VBScript Regular Expressions COM library. If you are using .NET or C++ there would be other options. ' Using 'Microsoft VBScript Regular Expressions 5.5' COM library ' C:\Windows\System32\vbscript.dll\3 Public Sub RemoveInvalidNoteFormatting(ByRef note As DrawingNote) ' Remove bad formatting in tags like <StyleOverride Font=''> ' where Font is set to nothing '' Dim r As New RegExp r.Global = True r.IgnoreCase = True r.Pattern = "Font=''" note.formattedText = r.Replace(note.formattedText, "") End Sub Public Sub RemoveInvalidFormatting() Dim doc As DrawingDocument Set doc = ThisApplication.ActiveDocument Dim sht As Sheet For Each sht In doc.Sheets Dim note As DrawingNote For Each note In sht.DrawingNotes Call RemoveInvalidNoteFormatting(note) Next Next End Sub Once I've run the above code on the drawing, I could export it without any problem. Posted at 05:20 AM in Adam Nagy , Inventor | Permalink | | | Comments Remove illegal text formatting By Adam Nagy Not sure how you end up with text formatting in DrawingNote's where the Font is set to nothing, i.e. the DrawingNote.FormattedText contains things like this: <StyleOverride Font=''> Maybe the Font type being used on the system where the drawing was created does not exist on the other system where the drawing has been opened?  Unfortunately, this seems to cause issues when exporting your drawing to other formats like PDF or DWF and you will get a message like the following: ... and the exported document might contain illegible text: If you know the exact problem you are looking for - in our case Font='' - then you could simply remove these from the FormattedText of the notes. In case of VBA you could use the Microsoft VBScript Regular Expressions COM library. If you are using .NET or C++ there would be other options. ' Using 'Microsoft VBScript Regular Expressions 5.5' COM library ' C:\Windows\System32\vbscript.dll\3 Public Sub RemoveInvalidNoteFormatting(ByRef note As DrawingNote) ' Remove bad formatting in tags like <StyleOverride Font=''> ' where Font is set to nothing '' Dim r As New RegExp r.Global = True r.IgnoreCase = True r.Pattern = "Font=''" note.formattedText = r.Replace(note.formattedText, "") End Sub Public Sub RemoveInvalidFormatting() Dim doc As DrawingDocument Set doc = ThisApplication.ActiveDocument Dim sht As Sheet For Each sht In doc.Sheets Dim note As DrawingNote For Each note In sht.DrawingNotes Call RemoveInvalidNoteFormatting(note) Next Next End Sub Once I've run the above code on the drawing, I could export it without any problem. View the entire comment thread. Please enable JavaScript if you would like to comment on this blog. Search Submit Mfg DevBloggers Adam Nagy Augusto Goncalves Balaji Ramamoorthy Daniel Du Philippe Leefsma Vladimir Ananyev Wayne Brill Xiaodong Liang November 2016 Sun Mon Tue Wed Thu Fri Sat     1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30       Autodesk Blogs ADN DevBlog - AEC Our DevBlog for Revit, Navisworks, AEC and BIM technology APIs. ADN DevBlog - AutoCAD Our DevBlog for AutoCAD and other platform technology APIs. ADN DevBlog - Cloud and Mobile Our DevBlog for Cloud and Mobile technologies. ADN DevBlog - Infrastructure Modeling Our DevBlog for Infrastructure Modeling technology APIs. ADN DevBlog - Manufacturing Our DevBlog for Design, Lifecycle and Simulation technologies. Around the Corner Cyrille Fauvel's Maya platform developer blog - Autodesk Media and Entertainment technology. Civilized Development Isaac Rodriguez's AutoCAD Civil 3D developer blog Dances with Elephants Jim Quanci's blog on partnering with large companies. It's All Just Ones and Zeros Doug Redmond's Vault developer blog Mod the Machine Brian Ekins' and Adam Nagy's Inventor developer blog The 360 View Mikako Harada's BIM 360 developer blog The 3D Web Coder Jeremy Tammik's web and mobile programming