06-21-2021
04:05 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
06-21-2021
04:05 PM
Thank you as well for posting so quickly. I like your style but for whatever reason, the code errors with the following message.
Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.Sheet'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{206B59AE-22A6-11D4-B7A8-0060B0F159EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
Here is the code I am using.
Sub Main sFont = "Arial" sFSize1 = 0.3 'font size in cm sFSize2 = 0.3175 'font size in cm String1 = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "' Underline='False'> PN: </StyleOverride><StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "' Underline='False'><Property Document='model' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='43'>PART NUMBER</Property></StyleOverride><StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "'> - </StyleOverride>" String3 = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "'>SCALE: </StyleOverride><StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "'><DrawingViewScale/></StyleOverride>" String2 = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "' Underline='False'><Property Document='model' PropertySet='Design Tracking Properties' Property='Authority' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='43'>AUTHORITY</Property></StyleOverride><StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "'> REQ'D </StyleOverride>" String4 = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "'><Property Document='model' PropertySet='Design Tracking Properties' Property='Material' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='20'>MATERIAL</Property></StyleOverride><StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "'> - </StyleOverride><StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "'><Property Document='model' PropertySet='User Defined Properties' Property='G_H' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='7'>G_H</Property></StyleOverride><StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "'> THK</StyleOverride>" Dim oDoc As DrawingDocument: oDoc = ThisDoc.Document oModel = ThisDoc.ModelDocument Dim oSheets As Sheets Dim oSheet As Sheet=oDoc.Sheets Dim oViews As DrawingViews Dim oView As DrawingView If MsgBox("All Sheets [Yes] Or ActiveSheet [No]?", vbYesNo + vbQuestion,"") = vbYes Then For Each oSheet In oSheets oViews = oSheet.DrawingViews UpdateLabels(oViews) Next Else oSheet = oDoc.ActiveSheet oViews = oSheet.DrawingViews UpdateLabels(oViews) End If End Sub Sub UpdateLabels(oVws As DrawingViews) For Each oView In oVws If oView.ViewType = 10501 Then oView.ShowLabel = True oView.Label.FormattedText = String1 & String2 & "<Br/>" & String4 &"<Br/>" & String3 End If Next End Sub