Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic form with dynamic multivalue lists

18 REPLIES 18
Reply
Message 1 of 19
BrandonW9
5027 Views, 18 Replies

iLogic form with dynamic multivalue lists

I'm currently working to make a "Property helper" form for my company, and had pretty much given up on the idea of being able to have my multi value lists change based on the choice in another.

 

But, i just hopped on @Curtis_Waguespack's blog and noticed the post from just yesterday where he was talking abut dynamic value multi value lists!

 

http://inventortrenches.blogspot.com/2017/02/ilogic-dynamic-multivalue-parameter.html

 

The thing is... mine are text parameters.

 

For a simplified example, the first choice would be "product type" where you choose from "tanks"  or "vaults".

 

Next would be a "component type" list...

If you choose "Tanks" the options are "Base", "Top", and "Baffle"

If you choose "Vaults" the options might be "Riser", "Base Slab", and "Top Slab"

 

I tried to look at the code and think through how i would get it to work for my application, and i couldn't work it out. I guess i would need to have different lists like "VaultComponentTypes" and "TankComponentTypes" and set which list to assign when the "Product type" is chosen? Perhaps using a select case or something?

 

It seems like the code would get complicated and convoluted pretty quick like that, and i'm not even exactly sure how i'd do it, especially considering this is a VERY simplified example of what I actually need to do.

 

 

Does anyone have an idea of how i can make this happen without creating a mess?

18 REPLIES 18
Message 2 of 19

My tip is Simple:

 

Use something different than illogic.

Use Vn.net add ins or equal.

 

otherwise it will be a mess. because it is very hard to program in illogic.

 

if you are familiar with I-logic the vb.net add in should not be that complicated for you.

Most people are more afraid than actually needed to change form illogic to add ins.

 

 

 

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Message 3 of 19

I'm actually developing a Vb.net add in on the back burner, but its a bit beyond my skill level and i'm floundering a bit, so I threw this form together this morning as a quick fix to buy myself some time.

 

For the add in, i originally started out with different enumeration lists, but it was getting pretty knarly, so i was attempting to figure out how to use a JSON file to store the values when i got buried with higher priority tasks. I guess ill just re-focus on that when i have time.

Message 4 of 19

For what I read, you are making it too complicated.

simply use vb.net to achieve your needs, not more.

Don't try to do this in illogic is my opinion and experience, it is to complicated to do that.

It seems to be easier to use illogic, but it isn't!

 

If you need assistance I am willing to guide you in the right direction.

 

please let me know if this is needed, also for a later stage of course

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Message 5 of 19

Hi,

Did you spot this blog I wrote a while back? It shows another example of setting a multivalue list, slightly different from Curtis's example.

 

https://www.cadlinecommunity.co.uk/hc/en-us/articles/202020381-Inventor-2014-iLogic-Set-Parameter-Mu...

 

Does it help?

 

My personal opinion is that iLogic is a pretty valid option for what you are trying to achieve.

Luke 

 

 

Message 6 of 19

Without vb.net this is all possible without tricks and workarounds. But an opinion is an opinion.

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Message 7 of 19

Thanks for your advice. I've just built up the ilogic form enough to help me populate properties during this test run, and i will continue to pursue the VB.net add in for the final product.

 

I'm always in need of, and appreciative of help. I am not a programmer, but im doing my best to get my mind around it.

 

Right now i have this much done on the add in... You click the button, a window pops up with the first 3 (of many) property choices. The options in the second one change based on the choice in the first, and the third changes based on the choices in the second:

 

Test-Add in.png

 

As I said, im using public enum lists right now to set the values:

 

enum.png

 

The what seems to me to be a complicated select case mess:

 

select case.png

 

Then the XAML:

 

xaml.png

 

If anyone knows a better way to do what im trying to do, I'd be stoked! 

Message 8 of 19

Hi @BrandonW9,

 

The example at the link you posted was a bit more complicated as it was using a number value to filter down the list, and so it had to evaluate the number in order to know where to start the lists.

 

Your case shouldn't need to be that dynamic, as you simply want to build the known list inside the rule, so the lists are more static, but just need to change depending on the selection.

 

So I think this example will do what you're wanting to do. See the attached Inventor 2017 file for a working form as well, etc. And post back if I've missed the point, and there is indeed a more dynamic aspect to your needs here.

 

Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

'set list and default
If Type = "Tanks" Then
	'set list
	MultiValue.SetList("Options", "Base", "Top", "Baffle")
	'set default value
	Parameter("Options") = "Base"
ElseIf Type = "Vaults" Then	
	'set list
	MultiValue.SetList("Options", "Riser", "Base Slab", "Top Slab")
	'set default value
	Parameter("Options") = "Riser"
End If

 

Message 9 of 19

@LukeDavenport

 

oops, it looks like your post covered this very well... I think you posted while I was typing.

Message 10 of 19

Ah! gotcha... and if I had more than two "types" I could use a select case rather than if/then/else correct?

 

Also, thanks a ton for your quick reply. You and your blog have helped me a ton already and don't even know it.

Message 11 of 19

Hi @BrandonW9,

 

Yep, you could use an If/Then or a Select Case, generally when the list gets really long a Select Case is more speedy, but for a list of four it might not be noticeable.

 

p.s. I accidentaly accepted a solution in this thread (I got click happy) so sorry if that generated an email notice, etc and caused confusion, I corrected it immediately, so it might have been hard to tell what happened.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Select Case Type

Case "Tanks"

	'set list
	MultiValue.SetList("Options", "Base", "Top", "Baffle")
	'set default value
	Parameter("Options") = "Base"
	
Case "Vaults"

	'set list
	MultiValue.SetList("Options", "Riser", "Base Slab", "Top Slab")
	'set default value
	Parameter("Options") = "Riser"
	
Case "Fruits"
	'set list
	MultiValue.SetList("Options", "Apples", "Oranges", "Grapes")
	'set default value
	Parameter("Options") = "Apples"
	
Case "Critters"
	'set list
	MultiValue.SetList("Options", "Puppies", "Kittens", "Goldfish")
	'set default value
	Parameter("Options") = "Puppies"
	
End Select
If Type = "Tanks" Then

	'set list
	MultiValue.SetList("Options", "Base", "Top", "Baffle")
	'set default value
	Parameter("Options") = "Base"
	
Else If Type = "Vaults" Then

	'set list
	MultiValue.SetList("Options", "Riser", "Base Slab", "Top Slab")
	'set default value
	Parameter("Options") = "Riser"

Else If Type = "Fruits" Then

	'set list
	MultiValue.SetList("Options", "Apples", "Oranges", "Grapes")
	'set default value
	Parameter("Options") = "Apples"
	
Else If Type = "Critters" Then
	'set list
	MultiValue.SetList("Options", "Puppies", "Kittens", "Goldfish")
	'set default value
	Parameter("Options") = "Puppies"
	
End If

 

Message 12 of 19

I pretty much never use iLogic anymore but I think I disagree with you that switching over to using VB.Net is a 'simple' solution for people who save never used an IDE.

 

Unless you are passionate about wanting to learn how to program, I wouldn't leave the safety of iLogic.

 

Some reasons being...

 

1. Visual Studio is not free to use (legally) for everyone.

2. Some engineers might not be able to install new software without administrative privileges.

3. If peoples 'Document' folders are kept on a shared drive, some company systems might not allow .exe and .dll files to be created due to security reasons.

4. There is no quick and easy way to trigger VB.Net methods/form to run inside Inventor.

5. References to the Inventor interlop might need updating when Inventor is updated to a new version.

6. I have been tinkering with VB for years but I still don't know what Interlop means.

7. Learning how to use VS and/or carry out the myFirstPlugIn tutorial is a few hours work.

8. Things which are easy in iLogic like editing iProps/parameters is easy in iLogic but not in VB (you have to remember "Design Tracking Properties", "Inventor User Defined Properties").

9. People who aren't great with computers/programming will just never figure it out without assistance.

10. You need to remember to divide by 10 when writing parameters to get them in to millimetres.

11. iLogic rules are saved in simple text files that are easy to duplicate and share.  If somebody wants to take some of my VB code a tweak it, they will need to download Visual Studio.

12. Last but not least... Inventor locks .dll files when it uses them so I have to restart Inventor to be able to build a Class Library project.

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
Message 13 of 19

My comment to this:

But I think this is not meant to be in this topic!!

 

I pretty much never use iLogic anymore but I think I disagree with you that switching over to using VB.Net is a 'simple' solution for people who save never used an IDE.

 

Unless you are passionate about wanting to learn how to program, I wouldn't leave the safety of iLogic.

 

Some reasons being...

 

1. Visual Studio is not free to use (legally) for everyone.
This is actually an advantage. Not everyone should be able to program into documents.

2. Some engineers might not be able to install new software without administrative privileges.
This is actually an advantage. So not everyone can do that. Without any knowledge of the API this should be prevented.

3. If peoples 'Document' folders are kept on a shared drive, some company systems might not allow .exe and .dll files to be created due to security reasons.

Add in files are stored locally.

4. There is no quick and easy way to trigger VB.Net methods/form to run inside Inventor.
Of course you have. Use then the Events.

5. References to the Inventor interlop might need updating when Inventor is updated to a new version.

Not necessarily.

6. I have been tinkering with VB for years but I still don't know what Interlop means.

7. Learning how to use VS and/or carry out the myFirstPlugIn tutorial is a few hours work.
To do it correctly without bugging in future this is the same for I-logic.

8. Things which are easy in iLogic like editing iProps/parameters is easy in iLogic but not in VB (you have to remember "Design Tracking Properties", "Inventor User Defined Properties").

It seems to be easier in i-logic but you need become familiar with it. If the createria of the code length is seen as if it is easier than this is not true to my opinion.

9. People who aren't great with computers/programming will just never figure it out without assistance.

To do it correctly without bugging in future this is the same for I-logic.

10. You need to remember to divide by 10 when writing parameters to get them in to millimetres.

Not necessarily.

11. iLogic rules are saved in simple text files that are easy to duplicate and share.  If somebody wants to take some of my VB code a tweak it, they will need to download Visual Studio.

Not necessarily. it can be done without but you are right that it is a little more difficult.

12. Last but not least... Inventor locks .dll files when it uses them so I have to restart Inventor to be able to build a Class Library project.

Yes you are right

 

So I think not everyone must be able to program into documents. it they are programming completely externally than I see no problem.

But I logic always need to kind of coding in the document to run external files.

 

I have been struggling with this while files are stored into vault pro and many files with I-logic and vba made huge problems.

 

I logic has no good exceptionhandling.

I logic uses documentevents and this is tricky working together with a released state!!! 

 

 

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Message 14 of 19

Thanks for the input guys. I think that for this particular project, the VB.net add in is probably a better tool for the job, but I've already ran into almost all the problems mentioned. There is definitely a big barrier to entry, but i'll just keep learning and working on it.

Message 15 of 19
smilinger
in reply to: BrandonW9

Try use xml:

 

In your xml file:

<?xml version="1.0" encoding="utf-8"?>
<Property>
    <PartClass Name="Precast" ProvideCode="Make">
        <TechClass Name="Box Culvert">
            <ComponentType>Base Section</ComponentType>
            <ComponentType>Top Section</ComponentType>
            <ComponentType>Top Slab</ComponentType>
            <ComponentType>Layout Assembly</ComponentType>
            <ComponentType>End Wall</ComponentType>
        </TechClass>
        <TechClass Name="Pad" />
        <TechClass Name="Pipe" />
        <TechClass Name="Round" />
        <TechClass Name="Specialty" />
        <TechClass Name="Tank">
            <ComponentType>Base Section</ComponentType>
            <ComponentType>Baffle Section</ComponentType>
            <ComponentType>Top Section</ComponentType>
            <ComponentType>Top Slab</ComponentType>
            <ComponentType>Stock Assembly</ComponentType>
            <ComponentType>Accessory Package</ComponentType>
            <ComponentType>Sales Part</ComponentType>
            <ComponentType>Top Level Assy</ComponentType>
        </TechClass>
    </PartClass>
    <!-- add more values here -->
</Property>

In your xaml:

    <Window.Resources>
        <XmlDataProvider x:Key="Properties" Source="Property.xml" XPath="Property"/>
    </Window.Resources>
    <Grid DataContext="{StaticResource Properties}">
        <ComboBox x:Name="IFSPartClass" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="120" DisplayMemberPath="@Name" SelectedValuePath="@Name"
                  ItemsSource="{Binding XPath=PartClass}" IsSynchronizedWithCurrentItem="True" />
        <ComboBox x:Name="IFSTechClass" HorizontalAlignment="Left" Margin="184,10,0,0" VerticalAlignment="Top" Width="120" DisplayMemberPath="@Name" SelectedValuePath="@Name"
                  DataContext="{Binding ElementName=IFSPartClass,Path=SelectedItem}" ItemsSource="{Binding XPath=TechClass}" IsSynchronizedWithCurrentItem="True"/>
        <ComboBox x:Name="ComponentType" HorizontalAlignment="Left" Margin="365,10,0,0" VerticalAlignment="Top" Width="120" 
                  DataContext="{Binding ElementName=IFSTechClass,Path=SelectedItem}" ItemsSource="{Binding XPath=ComponentType}" IsSynchronizedWithCurrentItem="True"/>
        <Button x:Name="OKButton" Content="Button" HorizontalAlignment="Left" Margin="304,228,0,0" VerticalAlignment="Top" Width="75" Click="OKButton_Click" />
        <Button x:Name="CancelButton" Content="Button" HorizontalAlignment="Left" Margin="304,228,0,0" VerticalAlignment="Top" Width="75" Click="CancelButton_Click" />
    </Grid>

And the click handler:

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            if (IFSPartClass.SelectedItem is XmlElement partClass)
            {
                UpdateCustomiProperty(AssemblyDoc, "IFS Part Class", IFSPartClass.SelectedValue);
                UpdateCustomiProperty(AssemblyDoc, "IFS Provide Code", partClass.Attributes["ProvideCode"].Value);
                if (IFSTechClass.SelectedItem != null)
                {
                    UpdateCustomiProperty(AssemblyDoc, "IFS Tech Class", IFSTechClass.SelectedValue);
                    if (ComponentType.SelectedItem != null)
                    {
                        UpdateCustomiProperty(AssemblyDoc, "Component Type", ComponentType.SelectedValue);
                    }
                }
            }
        }

Much simpler.

Message 16 of 19
BrandonW9
in reply to: smilinger

Thank you @smilinger! super helpful. I like that method. I'll try to switch over to that when i get a chance to work on it again.

Message 17 of 19

Hello Curtis,

i try to expand your code, but i get an fault. The parameter Options did not change to the selected one. Is it at all the right way to do it like i did or is there a better way?

Thanks in advance for your help.

If Type1 = "Tanks" Then

	'set list
	MultiValue.SetList("Options", "Base", "Top", "Baffle")
	'set default value
	Parameter("Options") = "Base"
	
Else If Type1 = "Vaults" Then

	'set list
	MultiValue.SetList("Options", "Riser", "Base Slab", "Top Slab")
	'set default value
	Parameter("Options") = "Riser"

Else If Type1 = "Fruits" Then

	'set list
	MultiValue.SetList("Options", "Apples", "Oranges", "Grapes")
	'set default value
	Parameter("Options") = "Apples"
	
Else If Type1 = "Critters" Then
	'set list
	MultiValue.SetList("Options", "Puppies", "Kittens", "Goldfish")
	'set default value
	Parameter("Options") = "Puppies"
	
End If



'------------------------

If Options = "Base" Then

'	'set list
	MultiValue.SetList("Next", "Base_rot", "Base_blau", "Base_grün")
	'set default value
	Parameter("Next") = "Base_rot"
	
Else If Options = "Top" Then

'	'set list
	MultiValue.SetList("Next", "Top_gelb", "Top_orange", "Top_schwarz")
	'set default value
	Parameter("Next") = "Top_gelb"

Else If Options = "Baffle" Then

'	'set list
	MultiValue.SetList("Next", "Baffle_gelb", "Baffle_orange", "Baffle_schwarz")
	'set default value
	Parameter("Next") = "Baffle_gelb"

End If


Message 18 of 19
meck
in reply to: BrandonW9

If I am reading the post correctly you are trying to populate a multivalue parameter based on a users input using iLogic?

 

If so, what I do is embed a spreadsheet where the columns have the information to be placed into the multivalue parameter. From there you can use the standard excel snippets to read the proper column and change the multivalue parameter.

 

If this is not what you are trying to do... well just ignore this post. LOL.

Mike Eck
Master Drafter/ CAD Programmer
Using Inventor 2018
Message 19 of 19
JBerns
in reply to: meck

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

 

Select Hardware 2020-01-29_9-37-49.png


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 Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report