Message 1 of 2
Write BOM QTY to part files, but skipping Library files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So, my lack of iLogic knowledge is fully apparent with this one.
We are currently using this code to write all the quantities to part level in a Custom iProperty, including how many pieces are not in a subassembly.
However, know I would like to edit this so it skips all the non-editable parts, thinking about Library parts and later parts that are set to Released in Vault.
Can anyone help me?
Thanks in advance!
doc = ThisDoc.Document
Dim oAssyDef As AssemblyComponentDefinition = doc.ComponentDefinition
Dim oBOM As BOM = oAssyDef.BOM
oBOM.PartsOnlyViewEnabled = True
Dim oBOMView As BOMView = oBOM.BOMViews.Item("Structured")
Dim oBOMRow As BOMRow
question = MessageBox.Show("Write Assemblyname and Quantities to Parts", "Actum-Services",MessageBoxButtons.YesNo,MessageBoxIcon.Question)
If question = vbYes Then
Dim oBOMView3 As BOMView = oBOM.BOMViews.Item("Parts Only")
Dim oBOMRow3 As BOMRow
For Each oBOMRow3 In oBOMView3.BOMRows
'Set a reference to the primary ComponentDefinition of the row
Dim oCompDef As ComponentDefinition
oCompDef = oBOMRow3.ComponentDefinitions.Item(1)
Dim CompFullDocumentName As String = oCompDef.Document.FullDocumentName
Dim CompFileNameOnly As String
Dim index As Integer = CompFullDocumentName.LastIndexOf("\")
CompFileNameOnly = CompFullDocumentName.Substring(index+1)
Dim Qty As String
Qty = oBOMRow3.TotalQuantity
iProperties.Value(CompFileNameOnly, "Custom", "LoosePieces") = 0
Next
For Each oBOMRow In oBOMView.BOMRows
'Set a reference to the primary ComponentDefinition of the row
Dim oCompDef As ComponentDefinition
oCompDef = oBOMRow.ComponentDefinitions.Item(1)
Dim CompFullDocumentName As String = oCompDef.Document.FullDocumentName
Dim CompFileNameOnly As String
Dim index As Integer = CompFullDocumentName.LastIndexOf("\")
CompFileNameOnly = CompFullDocumentName.Substring(index+1)
Dim Qty As String
Qty = oBOMRow.TotalQuantity
iProperties.Value(CompFileNameOnly, "Custom", "LoosePieces") = Qty
iProperties.Value(CompFileNameOnly, "Custom", "PCS") = Qty
iProperties.Value(CompFileNameOnly, "Custom", "Assemblyname") = ThisDoc.FileName(False)
Next
Dim oBOMView2 As BOMView = oBOM.BOMViews.Item("Parts Only")
Dim oBOMRow2 As BOMRow
For Each oBOMRow2 In oBOMView2.BOMRows
'Set a reference to the primary ComponentDefinition of the row
Dim oCompDef As ComponentDefinition
oCompDef = oBOMRow2.ComponentDefinitions.Item(1)
Dim CompFullDocumentName As String = oCompDef.Document.FullDocumentName
Dim CompFileNameOnly As String
Dim index As Integer = CompFullDocumentName.LastIndexOf("\")
CompFileNameOnly = CompFullDocumentName.Substring(index+1)
Dim AllPieces As String
AllPieces = oBOMRow2.TotalQuantity
iProperties.Value(CompFileNameOnly, "Custom", "PCS") = AllPieces
iProperties.Value(CompFileNameOnly, "Custom", "Assemblyname") = ThisDoc.FileName(False)
Next
End If