my code don't work!!! Item(i) not found.
my code don't work!!! Item(i) not found. Imports Inventor Imports Inventor.ObjectTypeEnum Imports System Imports System.IO Imports System.Type Imports System.Activator Imports System.Math Imports System.Runtime.InteropServices Public Sub Export() Dim oBom As BOM = oAsmDoc.ComponentDefinition.BOM oBom.PartsOnlyViewEnabled = True oBom.SetPartNumberMergeSettings(True) Dim oBomView As BOMView = oBom.BOMViews.Item("Parts Number") Dim oBomRows As BOMRowsEnumerator = oBomView.BOMRows Dim oCompDef As ComponentDefinitionsEnumerator Dim i As Integer, j As Integer For i = 1 To oBomView.BOMRows.Count oCompDef = oBomRows.Item(i).ComponentDefinition.Item(1) .... Next i End Sub ...
please help me
error in
oCompDef = oBomRows.Item(2).ComponentDefinition.Item(1)
inventor stop, and error:
MissingMemberException
ComponentDefinition" for type "BOMRow" not found
Dim oBomView As BOMView = oBom.BOMViews.Item("Parts Number")
I think the end of this line should be "Part Number" not Parts
next i get
oParName = oCompDef.Document.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value oPar = oCompDef.Parameters
for all parts
Imports Inventor Imports Inventor.ObjectTypeEnum Imports System Imports System.IO Imports System.Type Imports System.Activator Imports System.Math Imports System.Runtime.InteropServices Public Sub Test() Dim oBom As BOM = oAsmDoc.ComponentDefinition.BOM oBom.PartsOnlyViewEnabled = True oBom.SetPartNumberMergeSettings(True) Dim oBomView As BOMView = oBom.BOMViews.Item("Parts Number") Dim oBomRows As BOMRowsEnumerator = oBomView.BOMRows Dim oCompDef As ComponentDefinitionsEnumerator Dim ParName() As String = {"d_M", "d_A", "d_B", "d_C", "d_D", "d_E", "d_F", "d_G", "d_L", "d_N", "d_S"} Dim i As Integer, j As Integer For i = 1 To oBomView.BOMRows.Count oCompDef = oBomRows.Item(i).ComponentDefinition.Item(1) For j = 0 To UBound(ParName) Msbbox (oBomRows.Item(j).ItemQuantity) Next Next End Sub
Imports Inventor Imports Inventor.ObjectTypeEnum Imports System Imports System.IO Imports System.Type Imports System.Activator Imports System.Math Imports System.Runtime.InteropServices Public Sub Test() Dim oBom As BOM = oAsmDoc.ComponentDefinition.BOM oBom.PartsOnlyViewEnabled = True oBom.SetPartNumberMergeSettings(True) Dim oBomView As BOMView = oBom.BOMViews.Item("Parts Number") Dim oBomRows As BOMRowsEnumerator = oBomView.BOMRows Dim oCompDef As ComponentDefinitionsEnumerator Dim ParName() As String = {"d_M", "d_A", "d_B", "d_C", "d_D", "d_E", "d_F", "d_G", "d_L", "d_N", "d_S"} Dim i As Integer, j As Integer For i = 1 To oBomView.BOMRows.Count oParName = iProperties.Value("Project", "Part Number") oCompDef = oBomRows.Item(i).ComponentDefinition.Item(1) For j = 0 To UBound(ParName) Msbbox (oBomRows.Item(j).ItemQuantity) Next Next End Sub
Did I understand correctly?
DimoDocAsAssemblyDocument
oDoc=ThisDoc.Document
DimoBOMAsBOM
oBOM=oDoc.ComponentDefinition.BOM
DimoBOMViewAsBOMView
oBOMView=oBOM.BOMViews.item("Parts Only")
DimiAsLong
Fori=1TooBOMView.BOMRows.count
DimoRowAsBOMRow
oRow=oBOMView.BOMRows.item(i)
DimoCompDefAsComponentDefinition
oCompDef=oRow.ComponentDefinitions.item(1)
DimoPropSetAsPropertySet
oPropSet=oCompDef.Document.PropertySets.Item("Design Tracking Properties")
oUPropSet=oCompDef.Document.PropertySets.Item("User Defined Properties")
MessageBox.Show("#: "&oRow.ItemNumber_
&" Quantity: "&oRow.ItemQuantity_
&" Part: "&oPropSet.Item("Part Number").Value)
Next
RuleParametersOutput()
InventorVb.DocumentUpdate()