11-25-2024
08:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
11-25-2024
08:37 AM
Hi @WCrihfield
Thanks again for your help with this code. I want to make couple of minor revision. Currently the code populates the label under all the views, is there way to just have it visible under the main base view? And also I would like to add a condition which checks if the 'ITEM' is between 200 & 299 and add an additional line that says "SHIPPED LOOSE"
Example:
'This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheets As Sheets = oDrawDoc.Sheets
Dim oSheet As Inventor.Sheet = oDrawDoc.ActiveSheet
Dim oViews As DrawingViews = oSheet.DrawingViews
Dim oView As DrawingView
For Each oView In oViews
'Get the full filename Of the view model
Dim oModelFileName As String
oModelFileName = oView.ReferencedDocumentDescriptor.ReferencedDocument.FullFileName
'MessageBox.Show("view model name" & oModelFileName, "Title")
Dim oPartList As PartsList = Nothing
'try and get the parts list form the table of this sheet
Try
oPartList = oSheet.PartsLists.Item(1)
Catch 'on error try and search all sheets for first found parts list
'iterate trough each sheet
For Each oSht As Sheet In oSheets
If oSht.PartsLists.Count > 0 Then
oPartList = oSht.PartsLists.Item(1)
Exit For
End If
Next
'MessageBox.Show("parts list found on: " & i, "Title")
End Try
If oPartList Is Nothing Then Return '<<< or show message about it >>>
' Iterate through the contents of the parts list.
For Each oRow As PartsListRow In oPartList.PartsListRows
'get filename of model in row
Dim oRowFileName As String
Try 'and get the full file name of the PL item
oRowFileName = oRow.ReferencedFiles.Item(1).FullFileName
Catch 'on error go To Next item
Continue For
End Try
'compare the filenames
'Performs a text comparison, based on a case-insensitive text sort order
'If strings equal returns 0
If StrComp(oModelFileName, oRowFileName, CompareMethod.Text) = 0 Then
'Get the value of Item from the Parts List
'Row name needs to be case sensitive or use 1 for first 2 for second etc.
oCell = oRow.Item("Item") 'Row name needs to be case sensitive or use 1 for first 2 for second etc.
'get the value of text in cell
Dim oItemValue As String = oCell.Value
oQty = oRow.Item("QTY")
'get the value of text in cell
Dim oQtyValue As String = oQty.Value
'Show the view label
oView.ShowLabel = True
'format the text first line
If oView.ViewType = 10501 Then
oItem = "<StyleOverride Underline='True' FontSize='0.35'> ITEM" & " ''" & oItemValue & "''" & " DETAIL" & " </StyleOverride>"
'format the text second line
oPartNumber = "<Br/><StyleOverride Underline='False' FontSize='0.25'><Property Document='model' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property></StyleOverride>"
'format the text second line
oDescription = "<Br/><StyleOverride Underline='False' FontSize='0.25'><Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>DESCRIPTION</Property></StyleOverride>"
'format the text second line
'oDXF = "<Br/><StyleOverride Underline='False' FontSize='0.25'>DXF FILE:<Property Document='model' PropertySet='Design Tracking Properties' Property='Stock Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>STOCK NUMBER</Property></StyleOverride>"
'add to the view label
oQty_txt = "<Br/><StyleOverride Underline='False' FontSize='0.25'> REQUIRED QUANTITY</StyleOverride>"
'Add the text line
oQty_value = "<StyleOverride Underline='False' Bold = 'True' FontSize='0.25'> ''" & oQtyValue & "'' </StyleOverride>"
'Add the Quantity value
End If
'add to the view label
oView.Label.FormattedText = oItem & oPartNumber & oDescription & oDXF & oQty_txt & oQty_value
End If
Next
Next