Change multi-value test parameters through API

Change multi-value test parameters through API

shrey9GP3F
Enthusiast Enthusiast
515 Views
2 Replies
Message 1 of 3

Change multi-value test parameters through API

shrey9GP3F
Enthusiast
Enthusiast

Hello,

 

In my assembly model, I have the following parameter,

MultiValue.SetList("Unit_Type", "Double Door", "Single Door-Left", "Single Door-Right")

 

I want to change the values using API, I am using this code but it throws the error,

 

ThisApplication.ActiveDocument.ComponentDefinition.Parameters.Item("Unit_Type").Expression = "Double Door"
0 Likes
516 Views
2 Replies
Replies (2)
Message 2 of 3

Curtis_Waguespack
Consultant
Consultant

Hi @shrey9GP3F 

 

I think you want to use SetExpressionList, I don't have an example handy, but if  you search this forum you might find one.

 

I did a quick search and found on at this link, there are probably others:

Solved: Transfer ipt´s parameters - Autodesk Community - Inventor

 

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

 

ExpressionList Object

Description

The ExpressionList provides access to a list of possible expressions that can be used for the associated parameter.

Methods

Name Description
ClearAll Method that removes all items from the list.
GetExpressionList Rreturns an array of Strings that represents the list of expressions used in the list.
SetExpressionList Method that sets the list of expressions for the parameter this expression list is associated with. The current value of the associated parameter will be modifed to match one of the values in the list. The CurrentValueIndex argument allows you control over which value from the list is used.

Properties

Name Description
Application Returns the top-level parent application object. When used the context of Inventor, an Application object is returned. When used in the context of Apprentice, an ApprenticeServer object is returned.
Count Property that specifies the number of expressions in the list.
Item Property that gets the specified expression in the list.
Parent Property that returns the parent Parameter object.
Type Returns an ObjectTypeEnum indicating this object's type.

EESignature

Message 3 of 3

shrey9GP3F
Enthusiast
Enthusiast

Hi @Curtis_Waguespack ,

 

Thanks for the reply.

 

Based on that information, I created the code below.

Public Sub changeParams(assemDoc As AssemblyDocument, ParamName As String, ParamValue As String)


        Try
            assemDoc.ComponentDefinition.Parameters.Item(ParamName).Expression = ParamValue
        Catch

            Dim oParamets As Parameter = assemDoc.ComponentDefinition.Parameters.Item(ParamName)

            Dim MyArrayList(oParamets.ExpressionList.Count - 1) As String
            MyArrayList = oParamets.ExpressionList.GetExpressionList()

            Dim indexVal As Int32 = Array.FindIndex(MyArrayList, Function(s) s.Contains(ParamValue))

            oParamets.ExpressionList.SetExpressionList(MyArrayList, True, indexVal)
            MsgBox(ParamName & ParamValue & indexVal & MyArrayList(indexVal))
        End Try

    End Sub

 

I don't know if this is the optimal way. I'd like to have your opinion.

 

Thanks

0 Likes