Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey guys.
This should be an easy one for you in the know...
Simply trying to determine if a drawing view is an assembly or part.
This code is skipping something because it always uses the first solution in the IF statement.
See red code...
'iterate through a IDW and add "Part Number, Total Part Qty" to the base view labels Dim oDoc As DrawingDocument = ThisDoc.Document Dim oModel = ThisDoc.ModelDocument Dim oSheets As Sheets = oDoc.Sheets Dim oSheet As Sheet Dim oViews As DrawingViews Dim oView As DrawingView For Each oSheet In oSheets oViews = oSheet.DrawingViews For Each oView In oViews 'oView.ViewType = DrawingViewTypeEnum.kDetailDrawingViewType _ 'oView.ViewType = DrawingViewTypeEnum.kSectionDrawingViewType If oView.ViewType = DrawingViewTypeEnum.kStandardDrawingViewType Then 'if viel label is hidden, unhide oView.ShowLabel = True Try 'get the property ID for these custom iProperties from the model referenced by the view o_iPropID_1 = oModel.PropertySets.Item("User Defined Properties").Item("TotalPartQty").PropId o_iPropID_2 = oModel.PropertySets.Item("User Defined Properties").Item("My_iProp_2").PropId Catch 'here you could add a message that one or more of the custom iProperties were not found End Try Try 'format the custom iproperty string and add the property ID oPartQty = "<Property Document='model' PropertySet='User Defined Properties' " _ & "Property='TotalPartQty' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _ & o_iPropID_1 & "'>TotalPartQty</Property>" ''format the custom iproperty string and add the property ID 'oString2 = "<Property Document='model' PropertySet='User Defined Properties' " _ '& "Property='My_iProp_2' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _ '& o_iPropID_2 & "'>My_iProp_2</Property>" 'format the built in iproperty string and add the property ID oPartNumber = "<StyleOverride Bold='false' Underline='false'><Property Document='model' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property></StyleOverride>" 'oStockNumber = "<Br/><StyleOverride Bold='false' Underline='false'><Property Document='model' PropertySet='Design Tracking Properties' Property='Stock Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>STOCK NUMBER</Property></StyleOverride>" 'oStringScale = "<StyleOverride FontSize='0.2'> FLAT VIEW (<DrawingViewScale/>)</StyleOverride>" 'oPartNumber = "<Br/><StyleOverride Underline='False' FontSize='0.2'>PART ID: <Property Document='model' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property></StyleOverride>" 'oStringProfile = "<Br/><StyleOverride FontSize='0.2'>PROFILE: <Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>DESCRIPTION</Property></StyleOverride>" oStringMaterial = "<StyleOverride Underline='False'><Property Document='model' PropertySet='Design Tracking Properties' Property='Material' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='20'>PART NUMBER</Property></StyleOverride>" 'oStringAuth = "<Br/><StyleOverride Underline='False' FontSize='0.2'>QTY: <Property Document='model' PropertySet='Design Tracking Properties' Property='Authority' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>AUTHORITY</Property></StyleOverride>" 'add the custom iproperties to the view label 'oView.Label.FormattedText = "<DrawingViewName/><Br/>" & oString1 & oString2 'Here Is a list Of all Of the the DocumentType enumerators available In the API: 'kUnknownDocumentObject 'kPartDocumentObject 'kAssemblyDocumentObject 'kDrawingDocumentObject 'kPresentationDocumentObject 'kDesignElementDocumentObject 'kForeignModelDocumentObject 'kSATFileDocumentObject 'kNoDocument 'DETERMINE MODEL TYPE 'If oModel.DocumentType = kPartDocumentObject Then oView.Label.FormattedText = oPartNumber & "<Br/>" & oStringMaterial & "<Br/>" & oPartQty & " RQD " 'Else 'oView.Label.FormattedText = oPartNumber & "<Br/>" & oPartQty & " RQD " 'End If Catch 'do nothing if error End Try End If Next Next
Solved! Go to Solution.