- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello.
I have a code that allows you to create and delete a parameter.
But the problem is that when creating a parameter using code, it is created not as a multi-valued parameter, but as a single parameter. At the same time, the program does not issue any errors.
If I understand correctly, the logic of the ArrayList code is broken.
Please help me solve this problem.
Thank you.
'MultiValue.SetList("Capacity_Type", "Container CIP solutions", "Pressure_damping_capacity") 'Capacity_Type = "Container CIP solutions" Dim oParams As Parameters Dim oAssemblyDoc As AssemblyDocument = ThisDoc.Document Dim oAssemblyCompDef As AssemblyComponentDefinition = oAssemblyDoc.ComponentDefinition Dim oComp As AssemblyComponentDefinition = oAssemblyDoc.ComponentDefinition oParams = oAssemblyCompDef.Parameters Dim oUPs As UserParameters = oComp.Parameters.UserParameters Dim oUP As UserParameter Dim ParamName As String = "Diameter_of_the_intake_pipe" Dim List As New ArrayList List.Add("80") List.Add("100") List.Add("125") List.Add("150") If Capacity_Type = "Container CIP solutions" Then Try Test = oUPs.Item(ParamName).Value Catch oUP = oUPs.AddByExpression(ParamName, List.Item(3), UnitsTypeEnum.kMillimeterLengthUnits) Parameter("Container CIP:1", "Diameter_of_the_intake_pipe") = Parameter(ParamName) End Try ElseIf Capacity_Type = "Pressure_damping_capacity" Then Try oUP = oUPs.Item(ParamName) oUP.Delete Catch End Try Parameter("Container CIP:1", "Diameter_of_the_intake_pipe") = False End If
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This is short code snippet to create new UserParamter with multi values
Dim partDef As PartComponentDefinition = ThisDoc.Document.ComponentDefinition
'Add new parameter as multi-value
Dim paramName As String = "TestParam"
Dim expressions As String() = {"1 mm", "2 mm", "3 mm" }
Dim newParam = partDef.Parameters.UserParameters.AddByExpression(paramName, "0", UnitsTypeEnum.kMillimeterLengthUnits)
newParam.ExpressionList.SetExpressionList(expressions, True, -1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey there.
Looking at your code it looks likes in your try you are verifying "Diameter_of_the_intake_pipe" user parameter exists. If it doesn't (catch) then you want to create a new multivalue list user parameter.
In the AddByExpression method I believe you are just passing a single item in the list "List.Item(3)"
This is the pattern I took:
Try
Dim userParameter As UserParameter
userParameter = userParameters.Item("STD_YES")
Catch
Dim UserParameter As UserParameter = userParameters.AddByValue("STD_YES", "No", "String")
MultiValue.SetList("STD_YES", "Yes")
UserParameter.IsKey = True
End TryHope this helps,
Chris