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 Font for all text-elements

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
GeorgK
2067 Views, 2 Replies

Change Font for all text-elements

Hello together,

 

how could I change all text-fonts from ISOCP to ISOCPEUR for all text-elemts in the drawing (in the frame, title etc.)?

 

Thank you very much

 

Georg

2 REPLIES 2
Message 2 of 3
Vladimir.Ananyev
in reply to: GeorgK

Texts are represented by TextBox objects.  You may change TextBox.Style.Font property or  override font using  TextBox.FormattedText propery value.  If text belongs to Border, Title block or sketched symbol you have to edit corresponding definition:  BorderDefinition, SketchedSymbolDefinition or TitleBlockDefinition objects.  There are several VBA samples in API help (e.g., CreateSketchedSymbolDefinition, CreateTitleBlockDefinition).

Open drawing and run the following sample.  It will dump information about texts in current title block and the change font type and size for Author field. 

Sub OverrideTextFont ()
  Dim oDoc As DrawingDocument
  Set oDoc = ThisApplication.ActiveDocument
  
  Dim oSheet As Sheet
  Set oSheet = oDoc.ActiveSheet
  
  Dim oTB As TitleBlock
  Set oTB = oSheet.TitleBlock

  Dim oTBDef As TitleBlockDefinition
  Set oTBDef = oTB.Definition
  
  Dim oSketch As DrawingSketch
  Set oSketch = oTBDef.Sketch
  
  'dump texts in this title block
  Dim oTextBox As TextBox
  Dim i As Integer
  For i = 1 To oSketch.TextBoxes.Count
    Set oTextBox = oSketch.TextBoxes.Item(i)
    Debug.Print i, oTextBox.Text
    Debug.Print i, oTextBox.FormattedText
    Debug.Print oTextBox.Style.Name
    Debug.Print
  Next
  
  ' change formatted text for box #9  ('Author' in my case)
  ' override font family and size
  Call oTBDef.Edit(oSketch)   ' enter edit mode
  Set oTextBox = oSketch.TextBoxes.Item(9)
  ' text value is derived from to iPropertyc "Author"
  oTextBox.FormattedText = "<StyleOverride Font='Chiller' FontSize='1'><Property Document='drawing' PropertySet='Inventor Summary Information' Property='Author' FormatID='{F29F85E0-4FF9-1068-AB91-08002B27B3D9}' PropertyID='4'>AUTHOR</Property></StyleOverride>"
  Call oTBDef.ExitEdit(True)  ' exit edit mode

  Beep
End Sub

 Hope this could help you to develop your own procedure.
Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 3
GeorgK
in reply to: GeorgK

Thank you very much for your help.

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

Post to forums  

Autodesk Design & Make Report