Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Add Item to Multi-Value-List of a Userparameter (IV2012 API)

4 REPLIES 4
Reply
Message 1 of 5
abrink100
654 Views, 4 Replies

Add Item to Multi-Value-List of a Userparameter (IV2012 API)

IV2012 API with VB:

 

Hello,

how can i add an item to a Multi-Value-List of an axisting UserParameter in Inventor2012 (Accessing API with Visual Basic) ?

 

My idea is for example:

 

uParams.Item(i).ExpressionList.AddItem(As String)

 

The problem is, that such a function "AddItem" doesn't exist.

 

Can anybody help me ?

 

Thank You very much.

 

4 REPLIES 4
Message 2 of 5
jddickson
in reply to: abrink100

Here is an example I use for some of my stuff. I hope this helps. This will also add the parameter to the part if it’s not in there.

 

 

Imports  Inventor.UnitsTypeEnum


Dim oPartDoc As Document
oPartDoc = ThisDoc.Document

If oPartDoc.DocumentType = kPartDocumentObject Then

    Dim oPartCompDef As PartComponentDefinition
        oPartCompDef = oPartDoc.ComponentDefinition
        
Dim oParams As Parameters
        oParams=oPartCompDef.Parameters
                
        Dim oUserParams As UserParameters
        oUserParams=oParams.UserParameters       
        
        Dim oAwesomeParameter As Parameter                     
                    Try
            otester = oUserParams.Item("PK_Ship_Loose")
            Catch
oInsulationType=oUserParams.AddByValue("PK_Ship_Loose", "No", kTextUnits) 
MultiValue.SetList("PK_Ship_Loose", "Yes", "No")
            End Try
            End If

Parameter.Param("PK_Ship_Loose").ExposedAsProperty = False
Parameter.Param("PK_Ship_Loose").IsKey = False
Message 3 of 5
abrink100
in reply to: jddickson

Hello jddickson,

 

in this example you only create a Userparameter if it doesn't exist and prepare a Multi-Value-List.

 

What I need, is to add an Item to an allready existing parameter and an allready existing Multi-Value-List with the "text" unit and with content.

 

For eample i have a Parameter called: PARAM1 and three values in the Multi-Value-List: Text1, Text2, Text3.

 

Now a need to add one Item (value), taht for example could be the text: Text4.

 

Can you tell me how ?

 

Thanks

Message 4 of 5
jddickson
in reply to: abrink100

There is probably an easier way to do it but you could delete the parameter first using an “IF Statement”.  Then you could use the code I sent you before adding anything new to the Mulit-Value-List. I know there has to be a better way but I know this should do everything you need.  I taught myself how to do this stuff so my know how is limited. The code below could be used to delete the parameter.

 

I hope this helps in some way.

 

 

Dim param As Parameter 
param = oDoc.ComponentDefinition.Parameters.Item("PARAM1") 
param.Delete
Message 5 of 5
abrink100
in reply to: jddickson

I also told myself. You don't need to delete the parameter to put something new into the list. You only have to clear the Expressionlist and assign a new one.

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

Post to forums  

Autodesk Design & Make Report