Parameter dependency in iLogic form

<?xml encoding=”UTF-8″>By Adam Nagy

You may want to show the possible parameter values of a part in an iLogic form where the parameters depend on each other, like in case of a Content Center part: if x is 2, then y can ony be 3 or 4, etc

Let’s say this is the table that contains the possible values:

Width Depth Height
1 1 1
1 1 2
1 2 1
1 2 2
2 2 2
2 2 3
2 3 3
2 3 4

We can create multi-value parameters for each parameter to store their possible values: WidthValues, DepthValues, HeightValues

We can now place these parameters on a form and then create a rule that is using those parameters, e.g. “Update”:

' Need this for List(Of Double) which has a Contains function
Imports System.Collections.Generic
'MsgBox(Str(WidthValues) + "; " +
'  Str(DepthValues) + "; " +
'  Str(HeightValues))
' Let's say these are the possible values (pv) for the parameters
' that we got from the Content Center
' Width, Depth, Height
Dim pv = New List(Of Double)
pv.AddRange(New Double(){
1, 1, 1,
1, 1, 2,
1, 2, 1,
1, 2, 2,
2, 2, 2,
2, 2, 3,
2, 3, 3,
2, 3, 4})
' WIDTH --------------------------------------------------------------
' Width is the main param so all its possible values are listed
Dim widths = New List(Of Double)
widths.AddRange(New Double(){1, 2})
MultiValue.List("WidthValues") = widths
' If the current width value is not in the list then use the first one
If Not widths.Contains(WidthValues) Then WidthValues = widths(0)
' DEPTH --------------------------------------------------------------
' Depending on the width value we set the DepthValues
Dim depths = New List(Of Double)
For i As Integer = 0 To pv.Count - 1 Step 3
If pv(i) = WidthValues Then
If Not depths.Contains(pv(i + 1)) Then depths.Add(pv(i + 1))
End If
Next
MultiValue.List("DepthValues") = depths
' If the current depth value is not in the list then use the first one
If Not depths.Contains(DepthValues) Then DepthValues = depths(0)
' HEIGHT -------------------------------------------------------------
' Depending on the width and depth value we set the HeightValues
Dim heights = New List(Of Double)
For i As Integer = 0 To pv.Count - 1 Step 3
If pv(i) = WidthValues And pv(i + 1) = DepthValues Then
If Not heights.Contains(pv(i + 2)) Then heights.Add(pv(i + 2))
End If
Next
MultiValue.List("HeightValues") = heights
' If the current height value is not in the list then use the first one
If Not heights.Contains(HeightValues) Then HeightValues = heights(0)
' Let's change the model based on the values
Width = WidthValues
Depth = DepthValues
Height = HeightValues
InventorVb.DocumentUpdate()

Dependantvalues

Inventor 2015 sample part file: Download ILogicTest


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading