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.
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
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
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