I too was needing a solution for validated, dynamic lists for fastener selection.
The first list, bolt material, was the intended first selection.
The second list, bolt diameter, would be based on material.
The third list, bolt length, would be based on diameter.
Etc.
Material > Diameter > Length

The challenge was that after selecting the material, an invalid value may remain in the diameter or length lists.
I needed to update the lists after a change in selection. I developed this code to update the lists, validate the current value, and update the value if necessary.
For example:
316SS : 5/8"-11 bolt lengths include: 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 3.0, 4.5, 5.0, 6.0
ZINC : 1/4"-20 bolt lengths include: 0.5, 0.75, 1.0
If the current diameter = 1/4" and length = 0.5", and then the user selects 5/8" diameter, the code will update the bolt length multivalue list and change the value if the current length is not on the list.
The lock nut types are also based on material and bolt diameter.
I have included a sample part with a rule and form for you to explore. I hope you find it helpful.
'Manage the Multivalue Parameters
Sub Main()
' Initialize lock and washer types
MultiValue.SetList("Lock_Nut_Type", "CTR LK", "FLEX-LOC", "NYLOCK")
'Lock_Nut_Type = "NYLOCK"
MultiValue.SetList("Washer_Type", "FLAT", "LOCK")
'Washer_Type = "LOCK"
' Set the multivalue parameters
SetMVP
' Update document
InventorVb.DocumentUpdate()
End Sub
'--- Set the Multi-Value Parameters ---
Sub SetMVP()
' Set and validate the bolt material list
SetBoltMaterial({"316SS", "ZINC" })
' Set diameter and lock nut lists based on bolt material
Select Case Bolt_Material
Case "316SS"
' Set bolt diameters for stainless
SetBoltDiameter({"0.250""-20", "0.313""-18", "0.375""-16", "0.500""-13", "0.625""-11"})
' Set length and lock nut lists based on bolt diameter
Select Case Bolt_Diameter
Case "0.250""-20"
SetBoltLength({"0.500""", "0.750""", "1.000""", "1.250""", "1.500""", "2.000""", "2.500""" })
SetLockNutType({"NYLOCK"})
Case "0.313""-18"
SetBoltLength({"0.750""", "1.000""", "1.250""", "1.500""", "1.750""", "2.000""", "2.500"""})
SetLockNutType({"NYLOCK"})
Case "0.375""-16"
SetBoltLength({"0.500""", "0.750""", "1.000""", "1.250""", "1.500""", "1.750""", "2.000""", "2.250""", "2.500""", "2.750""", "3.000""", "3.500""", "4.000""", "6.000"""})
SetLockNutType({"NYLOCK", "FLEX-LOC", "CTR LK"})
Case "0.500""-13"
SetBoltLength({"0.750""", "1.000""", "1.250""", "1.500""", "1.750""", "2.000""", "2.250""", "2.500""", "2.750""", "3.000""", "3.500""", "3.750""", "4.500"""})
SetLockNutType({"NYLOCK", "FLEX-LOC", "CTR LK"})
Case "0.625""-11"
SetBoltLength({"1.250""", "1.500""", "1.750""", "2.000""", "2.250""", "2.500""", "3.000""", "4.500""", "5.000""", "6.000"""})
SetLockNutType({"NYLOCK", "FLEX-LOC", "CTR LK"})
End Select
'set lock nut type
Case "ZINC"
' Set bolt diameters for zinc-plated carbon
SetBoltDiameter({"0.250""-20", "0.375""-16", "0.500""-13", "0.625""-11"})
' Set length and lock nut lists based on bolt diameter
Select Case Bolt_Diameter
Case "0.250""-20"
SetBoltLength({"0.500""", "0.750""", "1.000"""})
SetLockNutType({"NYLOCK"})
Case "0.375""-16"
SetBoltLength({"0.750""", "1.000""", "1.250""", "1.500""", "1.750""", "2.000""", "2.250""", "2.500""", "3.000"""})
SetLockNutType({"NYLOCK", "FLEX-LOC", "CTR LK"})
Case "0.500""-13"
SetBoltLength({"0.750""", "1.000""", "1.250""", "1.500""", "1.750""", "2.000""", "2.250""", "2.500""", "2.750""", "3.000"""})
SetLockNutType({"NYLOCK", "FLEX-LOC", "CTR LK"})
Case "0.625""-11"
SetBoltLength({"1.500""", "1.750""", "2.000""", "2.250""", "2.500""", "2.750""", "3.000""", "3.500""", "4.000""", "4.500"""})
SetLockNutType({"NYLOCK", "FLEX-LOC", "CTR LK"})
End Select
End Select
End Sub
' function to set bolt material
' Input = string array of materials
' Output = nothing
Private Function SetBoltMaterial(ByRef aryBoltMaterial)
' Set multivalue parameter to the string array
MultiValue.List("Bolt_Material") = aryBoltMaterial
' Check if current multivalue parameter is in the string array
index = Array.IndexOf(aryBoltMaterial, Parameter("Bolt_Material"))
If index = -1 Then
' Set bolt material to most commonly used material
Parameter("Bolt_Material") = aryBoltMaterial(1)
Bolt_Material = Parameter("Bolt_Material")
MsgBox("Invalid or no bolt material selected. Setting default to " & Parameter("Bolt_Material") & ".",,"ALERT")
End If
End Function
' function to set bolt diameter
' Input = string array of diameters
' Output = nothing
Private Function SetBoltDiameter(ByRef aryBoltDiameter)
' Set multivalue parameter to the string array
MultiValue.List("Bolt_Diameter") = aryBoltDiameter
' Check if current multivalue parameter is in the string array
index = Array.IndexOf(aryBoltDiameter, Parameter("Bolt_Diameter"))
If index = -1 Then
' Set bolt diameter to first item in array and then warn user
Parameter("Bolt_Diameter") = aryBoltDiameter(0)
Bolt_Diameter = Parameter("Bolt_Diameter")
MsgBox("Invalid or no bolt diameter selected. Setting default to " & Parameter("Bolt_Diameter") & ".",,"ALERT")
End If
End Function
' function to set bolt length
' Input = string array of lengths
' Output = nothing
Private Function SetBoltLength(ByRef aryBoltLength)
' Set multivalue parameter to the string array
MultiValue.List("Bolt_Length") = aryBoltLength
' Check if current multivalue parameter is in the string array
index = Array.IndexOf(aryBoltLength, Parameter("Bolt_Length"))
If index = -1 Then
' Set bolt length to first item in array and then warn user
Parameter("Bolt_Length") = aryBoltLength(0)
Bolt_Length = Parameter("Bolt_Length")
MsgBox("Invalid or no bolt length selected. Setting default to " & Parameter("Bolt_Length") & ".",,"ALERT")
End If
End Function
' function to set lock nuts
' Input = string array of lock nut types
' Output = nothing
Private Function SetLockNutType(ByRef aryLockNutType)
' Set multivalue parameter to the string array
MultiValue.List("Lock_Nut_Type") = aryLockNutType
' Check if current multivalue parameter is in the string array
index = Array.IndexOf(aryLockNutType, Parameter("Lock_Nut_Type"))
If index = -1 Then
' Set lock nut type to first item in array and then warn user
Parameter("Lock_Nut_Type") = aryLockNutType(0)
Lock_Nut_Type = Parameter("Lock_Nut_Type")
MsgBox("Invalid or no lock nut selected. Setting default to " & Parameter("Lock_Nut_Type") & ".",,"ALERT")
End If
End Function
I suspect the individual functions could be optimized into a single function with more arguments passing. Any suggestions would be welcome.
I have been very successful with this code when it comes to Text-type multivalue lists. I have been struggling to get this to work with numeric multivalue lists. I suspect a parameter type issue is the cause. I would welcome any insight to adapt the Function to test numeric arrays and lists.
Again, I hope this is helpful for those requiring verified or validated, dynamic multivalue lists.
Regards,
Jerry
-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional