Change Font for all text-elements

Change Font for all text-elements

GeorgK
Advisor Advisor
2,201 Views
2 Replies
Message 1 of 3

Change Font for all text-elements

GeorgK
Advisor
Advisor

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

0 Likes
Accepted solutions (1)
2,202 Views
2 Replies
Replies (2)
Message 2 of 3

Vladimir.Ananyev
Alumni
Alumni
Accepted solution

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

0 Likes
Message 3 of 3

GeorgK
Advisor
Advisor

Thank you very much for your help.

0 Likes