iLogic to Set BOM Structure in .ipt & .iam

iLogic to Set BOM Structure in .ipt & .iam

arkelec
Collaborator Collaborator
1,593 Views
4 Replies
Message 1 of 5

iLogic to Set BOM Structure in .ipt & .iam

arkelec
Collaborator
Collaborator

I've been looking at this thread [ https://forums.autodesk.com/t5/inventor-customization/document-settings-with-rule-form/m-p/4332439#M... ], with a view to creating exactly the same function, but I can't get it to work at all.

 

The adding of a multi-value user parameter is ok.  The bit that is foxing me is the code to read the value set by that user parameter & them to apply it to the document (part & assembly).

 

Looking at an external iLogic for a part (.ipt), this is the code that is supposed to read the user parameter value (named "xBOM_Structure"):

' Get part component definition
Dim oPartCompDef As PartComponentDefinition = ThisDoc.Document.ComponentDefinition

Select Case xBOM_Structure
Case "Normal"
	oPartCompDef.BOMStructure = "51970"
Case "Phantom"
	oPartCompDef.BOMStructure = "51971"
Case "Reference"
	oPartCompDef.BOMStructure = "51972"
Case "Purchased"
	oPartCompDef.BOMStructure = "51973"
Case "Inseparable"
	oPartCompDef.BOMStructure = "51974"
End Select

 

I notice on the original thread referenced above, there were some further, unresolved issues.  Does this suggest that I wan't to do can't actually be done?

 

0 Likes
Accepted solutions (1)
1,594 Views
4 Replies
Replies (4)
Message 2 of 5

lah29-bertrand
Advocate
Advocate
Dim oDoc As Document = ThisApplication.ActiveDocument
oBOMStruct = oDoc.ComponentDefinition.BOMStructure
Dim oStrucText As String
Select Case oBOMStruct

	Case 51970
		oStrucText = "Normal"
	Case 51974
		oStrucText = "Indivisible"
	Case 51973
		oStrucText = "Acheté"
	Case 51971
		oStrucText = "Fantôme"
	Case 51972
		oStrucText = "Référence"

End Select


'MessageBox.Show(oStrucText, "Title")


Dim MyArrayList As New ArrayList
MyArrayList.Add("Normal")
MyArrayList.Add("Indivisible")
MyArrayList.Add("Acheté")
MyArrayList.Add("Fantôme")
MyArrayList.Add("Référence")
Question = InputListBox("Choisir une Nouvelle Stucture", MyArrayList, d0,"STRUCTURE BOM", "Actuelle: "+oStrucText)

'kDefaultBOMStructure 51969 The default structure type.
'kInseparableBOMStructure 51974 The inseparable structure type.
'kNormalBOMStructure 51970 The normal structure type.
'kPhantomBOMStructure 51971 The phantom structure type.
'kPurchasedBOMStructure 51973 The purchased structure type.
'kReferenceBOMStructure 51972 The reference structure type.
'kVariesBOMStructure 51975 The structure type varies amongst references.


Select Case Question

	Case "Normal"
		ThisDoc.Document.ComponentDefinition.BOMStructure = 51970
	Case "Indivisible"
		ThisDoc.Document.ComponentDefinition.BOMStructure = 51974
	Case "Acheté"
		ThisDoc.Document.ComponentDefinition.BOMStructure = 51973
	Case "Fantôme"
		ThisDoc.Document.ComponentDefinition.BOMStructure = 51971
	Case "Référence"
		ThisDoc.Document.ComponentDefinition.BOMStructure = 51972


End Select
Message 3 of 5

lah29-bertrand
Advocate
Advocate

In english 🙂

 

 

 

 

 

Dim oDoc As Document = ThisApplication.ActiveDocument
oBOMStruct = oDoc.ComponentDefinition.BOMStructure
Dim oStrucText As String
Select Case oBOMStruct

Case 51970
oStrucText = "Normal"
Case 51974
oStrucText = "Inseparable"
Case 51973
oStrucText = "Purchased"
Case 51971
oStrucText = "Phantom"
Case 51972
oStrucText = "Reference "

End Select


'MessageBox.Show(oStrucText, "Title")


Dim MyArrayList As New ArrayList
MyArrayList.Add("Normal")
MyArrayList.Add("Inseparable")
MyArrayList.Add("Purchased")
MyArrayList.Add("Phantom")
MyArrayList.Add("Reference")
Question = InputListBox("Chose new Stucture", MyArrayList, d0,"STRUCTURE BOM", "Current: "+oStrucText)

'kDefaultBOMStructure 51969 The default structure type.
'kInseparableBOMStructure 51974 The inseparable structure type.
'kNormalBOMStructure 51970 The normal structure type.
'kPhantomBOMStructure 51971 The phantom structure type.
'kPurchasedBOMStructure 51973 The purchased structure type.
'kReferenceBOMStructure 51972 The reference structure type.
'kVariesBOMStructure 51975 The structure type varies amongst references.


Select Case Question

Case "Normal"
ThisDoc.Document.ComponentDefinition.BOMStructure = 51970
Case "Inseparable"
ThisDoc.Document.ComponentDefinition.BOMStructure = 51974
Case "Purchased"
ThisDoc.Document.ComponentDefinition.BOMStructure = 51973
Case "Phantom"
ThisDoc.Document.ComponentDefinition.BOMStructure = 51971
Case "Reference"
ThisDoc.Document.ComponentDefinition.BOMStructure = 51972


End Select

Message 4 of 5

JhoelForshav
Mentor
Mentor
Accepted solution

@arkelec 

In order to get it to work as an external rule, try referencing the parameter as below:

Dim oPartCompDef As PartComponentDefinition = ThisDoc.Document.ComponentDefinition
Select Case Parameter("xBOM_Structure")
Case "Normal"
	oPartCompDef.BOMStructure = "51970"
Case "Phantom"
	oPartCompDef.BOMStructure = "51971"
Case "Reference"
	oPartCompDef.BOMStructure = "51972"
Case "Purchased"
	oPartCompDef.BOMStructure = "51973"
Case "Inseparable"
	oPartCompDef.BOMStructure = "51974"
	
End Select

 

Message 5 of 5

arkelec
Collaborator
Collaborator

Great, many thank.

0 Likes