- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All.
Is it possible to change the text height of a drawing view label through VBA?
I have tried to change it by creating a new text style manually with the text height I require and then through VBA set the view label to use that style.
The View label takes on the new style but does not change the text height.
I have tried to use 'StyleOverride FontSize=' but I have text that is multi lined and using this command converts all my text onto one line.
Is it possible to change the text height of a drawing view label through VBA?
Below is my code so far,
Sub HoleDetailSheetLabels()
' Declare the Application object
Dim oApp As Inventor.Application
' Obtain the Inventor Application object.
' This assumes Inventor is already running.
'Set oApp = GetObject(, "Inventor.Application")
Set oApp = ThisApplication
' Set a reference to the active document.
' This assumes a document is open.
Dim oDoc As Inventor.Document
Set oDoc = oApp.ActiveDocument
If oDoc.DocumentType <> kDrawingDocumentObject Then
MsgBox "You must be in a Drawing file"
Exit Sub
End If
If oDoc.FileSaveCounter = 0 Then
MsgBox "Please save this file first"
Exit Sub
End If
Dim oSheets As Inventor.sheets
Set oSheets = oDoc.sheets
If oDoc.sheets.Count = 0 Then
MsgBox "Please Add a Drawing Sheet first"
Exit Sub
End If
Dim oActiveSheet As Inventor.sheet
Set oActiveSheet = oDoc.ActiveSheet
If InStr(1, "HOLE DETAIL SHEET", UCase(oActiveSheet.Name), vbTextCompare) > 0 Then
MsgBox "Please ensure you have a Hole Detail Sheet Active First"
Exit Sub
End If
Dim ODwgViews As DrawingViews
Dim ODwgView As DrawingView
Dim Dviewlabel As Inventor.DrawingViewLabel
Set ODwgViews = oDoc.ActiveSheet.DrawingViews
' Set a reference to the GeneralNotes object
Dim oTextStyles As TextStylesEnumerator
Set oTextStyles = oDoc.StylesManager.TextStyles
Dim oTextStyle As TextStyle
For Each oTextStyle In oTextStyles
If oTextStyle.Name = "Hole Detail Sheet View Label Text" Then
Exit For
End If
Next
Dim oldtext As String
If Not oTextStyle Is Nothing Then
For Each ODwgView In ODwgViews
Set Dviewlabel = ODwgView.Label
oldtext = Dviewlabel.Text
Dviewlabel.TextStyle = oTextStyle
'Dviewlabel.FormattedText = "<StyleOverride FontSize='2'>" & Dviewlabel.Text & " </StyleOverride>"
'Dviewlabel.FormattedText = "<StyleOverride FontSize='1.'>Part no. </StyleOverride><StyleOverride FontSize='1.'><Property Document='model' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property></StyleOverride><Br/>" & _
'"<StyleOverride FontSize='1.'><Property Document='model' PropertySet='Design Tracking Properties' Property='Material' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='20'>MATERIAL</Property></StyleOverride><Br/>" & _
'"<StyleOverride FontSize='1.'>Qty " & PartFileQty & "</StyleOverride>"
Next
End If
End Sub
Solved! Go to Solution.