Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help Item(i) not found

19 REPLIES 19
Reply
Message 1 of 20
cheitu
884 Views, 19 Replies

Help Item(i) not found

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

19 REPLIES 19
Message 2 of 20
tsreagan
in reply to: cheitu

Get rid of the i after next.

 

T.S.

 

Message 3 of 20
cheitu
in reply to: tsreagan

error in

 

oCompDef = oBomRows.Item(2).ComponentDefinition.Item(1)

 

inventor stop, and error:

 

MissingMemberException 

ComponentDefinition" for type "BOMRow" not found

Message 4 of 20
tsreagan
in reply to: cheitu

What are you trying to accomplish with this code?

Message 5 of 20
tsreagan
in reply to: tsreagan

Dim oBomView As BOMView = oBom.BOMViews.Item("Parts Number")

I think the end of this line should be "Part Number" not Parts
Message 6 of 20
cheitu
in reply to: tsreagan

next i get

           

 

oParName = oCompDef.Document.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value
oPar = oCompDef.Parameters

 

 

for all parts

Message 7 of 20
cheitu
in reply to: tsreagan

Yes, I have already corrected

Message 8 of 20
tsreagan
in reply to: cheitu

if you want the iprop for part number try this instead.

 

 

oParName = iProperties.Value("Project", "Part Number")

Message 9 of 20
cheitu
in reply to: cheitu

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

 

Message 10 of 20
tsreagan
in reply to: cheitu

oParName = iProperties.Value("Project", "Part Number")

 

 

The above may not work in the context of your rule.

Message 11 of 20
tsreagan
in reply to: tsreagan

Are you just trying to cycle through you BOM listing part name and quantity?

Message 12 of 20
cheitu
in reply to: tsreagan

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?

Message 13 of 20
cheitu
in reply to: tsreagan

Yes
Message 14 of 20
cheitu
in reply to: tsreagan

Are you just trying to cycle through you BOM listing part name and quantity? - YES

Message 15 of 20
tsreagan
in reply to: cheitu

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()
Message 16 of 20
tsreagan
in reply to: tsreagan

I hate it when pasting removes the spaces.

 

 

Message 17 of 20
tsreagan
in reply to: tsreagan

Here without missing spaces

Message 18 of 20
tsreagan
in reply to: tsreagan

You will not need this line

 

oUPropSet=oCompDef.Document.PropertySets.Item("User Defined Properties")
Message 19 of 20
cheitu
in reply to: tsreagan

do not work. I work in Visual Studio

Message 20 of 20
tsreagan
in reply to: cheitu

I dunno what that is, a VBA editor of some sort.

 

 

T.S.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report