Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
ejaL9K8H
1350 Views, 21 Replies

Updating user parameter with ilogic

Hi

 

I am trying to change the user parameter of an Asset model from an Assemply.

I would like my user paramter "ID_Number" to be equal to to the item number from the Bill of Materials.

I have used folowing code, but every time i run it, Inventor freezes and crashses...

What is the problem?

 

Thanks in advance

 

doc = ThisDoc.Document
Dim oAssyDef As AssemblyComponentDefinition = doc.ComponentDefinition
Dim oBOM As BOM = oAssyDef.BOM

oBOM.StructuredViewEnabled = True
Dim oBOMView As BOMView = oBOM.BOMViews.Item("Structured")
' Set the Row Merge Settings
oBOM.SetPartNumberMergeSettings(False)

Dim oBOMRow As BOMRow

For Each oBOMRow In oBOMView.BOMRows
    'Set a reference to the primary ComponentDefinition of the row
    Dim oCompDef As ComponentDefinition
    oCompDef = oBOMRow.ComponentDefinitions.Item(1)
    
    Dim CompFullDocumentName As String = oCompDef.Document.FullDocumentName
    Dim CompFileNameOnly As String
    Dim index As Integer = CompFullDocumentName.LastIndexOf("\")
    
    CompFileNameOnly = CompFullDocumentName.Substring(index + 1)

	ItemNumber = oBOMRow.ItemNumber

 	Parameter(CompFileNameOnly, "ID_Number") = ItemNumber


Next