Loop through all user parameters in order to model change and save all variations (.iam)

Loop through all user parameters in order to model change and save all variations (.iam)

parth_moradiya
Contributor Contributor
159 Views
3 Replies
Message 1 of 4

Loop through all user parameters in order to model change and save all variations (.iam)

parth_moradiya
Contributor
Contributor

Hi All,

 

I have got the model with four different user parameters. And model is changing with different parameters in ilogic form. 

 

Is there any way like I can loop through all user parameters one by one and resulting model change one by one and save that varied model to particular path and also export BOM for that particular variation and then jump to next variation and do the same?

 

So with that code I can just run the rule and save all my variations and BOMs in excel ready to use. Is it possible?

 

My user parameters are:

Lock: Digital, Pad

Material: Brass, Steel

Length: 10,20,30,40

Form: 1,2,3,4

 

Thanks.

0 Likes
160 Views
3 Replies
Replies (3)
Message 2 of 4

daltonNYAW9
Advocate
Advocate

try this:

Class ThisRule
	Dim filename As String = "C:\temp\BOM "
	Dim LockParam As Inventor.Parameter
	Dim MaterialParam As Inventor.Parameter
	Dim LengthParam As Inventor.Parameter
	Dim FormParam As Inventor.Parameter
	Sub Main
		LockParam = Parameter.Param("Lock")
		MaterialParam = Parameter.Param("Material")
		LengthParam = Parameter.Param("Length")
		FormParam = Parameter.Param("Form")

		For Each value1 In LockParam.ExpressionList
			LengthParam.Expression = value1
			ExportNew()
			For Each value2 In MaterialParam.ExpressionList
				MaterialParam.Expression = value2
				ExportNew()
				For Each value3 In LengthParam.ExpressionList
					LengthParam.Expression = value3
					ExportNew()
					For Each value4 In FormParam.ExpressionList
						FormParam.Expression = value4
						ExportNew()
					Next
				Next
			Next
		Next
	End Sub

	Sub ExportNew()
		ThisDoc.Document.Update
		newfilename = filename & LockParam.Expression & "," & MaterialParam.Expression & "," & LengthParam.Expression & "," & FormParam.Value
		newfilename = newfilename.Replace("""", "")
		ThisDoc.Document.SaveAs(newfilename & ".iam", True)
		ThisBOM.Export("Parts Only", newfilename & ".xlsx", kMicrosoftExcelFormat)
	End Sub
End Class
0 Likes
Message 3 of 4

parth_moradiya
Contributor
Contributor

Hi,

 

This code do export the .iam file and bom but all the file has same bom and same model like model isn't changing?

 

Thanks.

0 Likes
Message 4 of 4

daltonNYAW9
Advocate
Advocate

Hmm not sure. I tried it w/ a patterned component and it updated the pattern and all the parameters in the new model. If your model has parameter-driven code you might need to run that in between each parameter change w/ 'iLogicVb.RunRule("ruleName")'

0 Likes