- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
There are quite a few posts similar to this topic, but I can't seem to adapt these to my specific problem so i'm hoping for some help.
I have an assembly which is configured using iLogic from parameters and options in a spreadsheet. The configuration is done by suppressing and un-suppressing various parts and changing parameters. This is all working well.
Once all is said and done, I want to get the Parts Only BOM QTY value for each "active" part in the model and write that value to one of the in-built iProperties ("summary", "comments" or the like). For all "non-active" parts (either suppressed or phantom structure etc), i want to set the same iProperty value to 0. That way, I can use that property later on the drawing view to indicate whether that part is needed or not. There is a downstream reason for this in the CAM software, however crazy it sounds.
Please note I only need to do this for parts (can ignore all sub-assemblies) and the Parts Only BOM view is accurate for each configuration.
Any chance someone can help with a method of firstly setting an iProperty value all parts (active and in-active) to 0 and then for active items, getting the BOM Parts Only QTY and setting it to that value? I have the method for cycling through only active parts where i'm setting other iProperty values and that's working well. I just don't know how to combine the BOM functions and this into a workable solution.
Cheers,
Andrew.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hoping that below iLogic code may help to update iProperties of "Parts Only" BOMView.
Sub Main()
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
Dim oDef As AssemblyComponentDefinition
oDef = oDoc.ComponentDefinition
Dim oBOMView As BOMView
oBOMView = oDef.BOM.BOMViews.Item("Parts Only")
Dim oBOMRow As BOMRow
For Each oBOMRow In oBOMView.BOMRows
Dim oReferDoc As Document
oReferDoc = oBOMRow.ComponentDefinitions.Item(1).Document
If oReferDoc.DocumentType = kPartDocumentObject Then
Dim occ As ComponentOccurrence
For Each occ In oDef.Occurrences
If occ.ReferencedDocumentDescriptor.ReferencedDocument Is oReferDoc Then
If occ.Suppressed = False Then
iProperties.Value(occ.Name, "Project", "Part Number") = "XYZ"
End If
End If
Next
End If
Next
End Sub
For further investigation, please provide sample assembly file to test. Also, make sure that files are non confidential.
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This should do what you want.
Sub Main()
Dim oDoc as AssemblyDocument = ThisApplication.ActiveDocument
Dim oBom as BOM = oDoc.ComponentDefinition.BOM
oBOM.PartsOnlyViewEnabled = True
Dim oBOMView as BOMView = oBOM.BOMViews.Item("Parts Only")
'assigned in loop
Dim oRow as BOMRow
Dim oCompDef as ComponentDefinition
Dim oPropSet as PropertySet
Dim pQty as Inventor.Property
Dim oBOMDoc as Document
For Each oRow In oBOMView.BOMRows 'i=1 To oBOMView.BOMRows.Count
'oRow = oBOMView.BOMRows.Item(i)
oCompDef = oRow.ComponentDefinitions.Item("1")
oBOMDoc = oCompDef.Document
oPropSet = oBOMDoc.PropertySets.Item("Inventor User Defined Properties")
Try
pQty = oPropSet.Item("Assy Qty")
Catch
oPropSet.Add("Custom", "Assy Qty")
pQty = oPropSet.Item("Assy Qty")
End Try
pQty.Value = oRow.TotalQuantity
Next
End Sub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks for your help guys, but i actually found another method that someone had posted for a similar scenario that is working well for me using 'count'.
For Each aDoc In oDoc.AllReferencedDocuments 'Check if referenced document is a Part file. If aDoc.DocumentType = kPartDocumentObject Then FNamePos = InStrRev(aDoc.FullFileName, "\", - 1) docFName = Mid(aDoc.FullFileName, FNamePos + 1, Len(aDoc.FullFileName) - FNamePos) iProperties.Value(docFName, "Project", "Project") = ORDER_NUMBER iProperties.Value(docFName, "Summary", "Company") = PROJECT quantityValue = oADO.AllReferencedOccurrences(aDoc).Count iProperties.Value(docFName, "Summary", "Comments") = quantityValue End If Next
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Glad you found a solution that works for you. However, you should be aware that this code will count all occurrences, even ones that are marked phantom or reference. If there is ever the possibility of using reference parts, you should use the BOM functions shown in my example, or filter them out in your loop.