Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi! I have this code, largely from here https://forums.autodesk.com/t5/inventor-forum/structured-bom-total-quantity-of-loose-components/m-p/... I write an iProperty QTY / Project in each Referenced Document of the Assembly with the total part quantity. This I then use in the Parts List on a drawing.
My issue is with "Part Number Row Merge" in a BOM. Does someone have a suggestion regarding this?
Can this setting be read with iLogic? In this case if the row is merged to read both quantities, add them and write this total for both, so as to be correct?
Thank you!
Sub Main () oDoc = ThisApplication.ActiveDocument If oDoc.DocumentType <> kAssemblyDocumentObject Then MessageBox.Show("This rule can only be run in an Assembly file - exiting rule...", "Error") Return End If oTotalQTY End Sub Sub oTotalQTY oCompDef = ThisDoc.Document.ComponentDefinition openDoc = ThisDoc.Document customPropertyName = "QTY / Project" For Each docFile In openDoc.AllReferencedDocuments FNamePos = InStrRev(docFile.FullFileName, "\", -1) docFName = Mid(docFile.FullFileName, FNamePos + 1, Len(docFile.FullFileName) - FNamePos) If docFile.IsModifiable = True Then assemblyDoc = openDoc assemblyDef = assemblyDoc.ComponentDefinition partQty = assemblyDef.Occurrences.AllReferencedOccurrences(docFile) Try If partQty.Count <> iProperties.Value(docFName, "Custom", customPropertyName) Then iProperties.Value(docFName, "Custom", customPropertyName) = partQty.Count End If Catch iProperties.Value(docFName, "Custom", customPropertyName) = partQty.Count End Try End If Next MessageBox.Show("Completed Successfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1) End Sub
Solved! Go to Solution.