Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Change text style font for all text styles

1 REPLY 1
SOLVED
Reply
Message 1 of 2
dialunau
166 Views, 1 Reply

Change text style font for all text styles

I'm trying to change all text style font in a drawing document, regardless of the style they belong to. The problem is I'm getting an error while overwriting some text styles (it works for some styles, then I get the error below). Can someone help with this? I would really appreciate it.


err1.PNG

 

Here is the code I'm using:

 

Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oTM As TransactionManager = ThisApplication.TransactionManager
Dim oTS As TextStylesEnumerator = oDDoc.StylesManager.TextStyles
Dim sNameTextB As String = "MyTxtStyle"
Dim oStyleB As TextStyle = oTS.Item(sNameTextB)
Dim newTM As Transaction = oTM.StartTransaction(oDDoc, "ChangeTextStyle")

For Each oStyleA As TextStyle In oDDoc.StylesManager.TextStyles
	If oStyleA.Font <> oStyleB.Font Then
		oStyleA.Font = oStyleB.Font
	End If
Next oStyleA
newTM.End()
1 REPLY 1
Message 2 of 2
dialunau
in reply to: dialunau

It turns out that running the code would try to change all style, including the not in use text styles included in the global styles, so I just had to tweak the code to work only on the in use text styles and now it works just fine.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report