- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Yup! Looks pretty good. Your helper function there still needs completing.
Here's a couple links to help.
'Mass iProperty.
http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-ABA1FF89-A0EB-4D21-AC49-5A69D321410C
'Note: You likely need to do a mass * total quantity, so here is a link to get total quantity from BOM:
http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-D475FABC-33CE-4F0D-B15C-C92805BB23A7
'Also, dictionaries have a .Contains method (make sure you switch the samples to vb).
Below is the code cleaned up with comments removed of the stuff that's done so it's easier to read. Comments should be "why", and not a "how/what" for every line. The code tells you that in the language. It's redundant and messy to have it in 2 languages.
Sub Main
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
Dim oBOM As BOM
oBOM = oDoc.ComponentDefinition.BOM
Dim oBOMView As BOMView
oBOMView = oBOM.BOMViews.item("Parts Only")
Dim Materials As Object
Materials = CreateObject("Scripting.Dictionary")
Call BOMweightIteration(oBOMView.BOMRows, Materials)
For Each item In Materials
msg = "Materials: " & item & " Area: " & Materials(item) & Iif(msg <> "",vbCrLf & msg,"")
Next
MsgBox(msg)
End Sub
Private Sub BOMweightIteration(oBOMRows As BOMRowsEnumerator, Materials As Object, Optional SubQty As Integer = 1)
On Error Resume Next
Dim i As Long
For i = 1 To oBOMRows.count
Dim oRow As BOMRow
oRow = oBOMRows.item(i)
Dim oCompDef As ComponentDefinition
oCompDef = oRow.ComponentDefinitions.item(1)
'grab Materialss name from comp def
'Change this if statement to a check to see if the part Materialss exists in the dictionary
'If it does
'add the weight of the line to the weight of the Materialss in the library
'if it doesn't
'add the weight and Materialss name of the line to the dictionary
'remove face stuff as it's irrelevant
End If
Next
End Sub
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization
iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread
Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects
Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help
Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type