- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
How to set by iLogic or VB : "allow custom values" for all user multivalue parameters? (when creating them or later)
Solved! Go to Solution.
How to set by iLogic or VB : "allow custom values" for all user multivalue parameters? (when creating them or later)
Solved! Go to Solution.
Hello Marcin,
The parameter has an attribute
UserParameters.item(1).attributeSets.item("com.autodesk.inventor.parameterAttributes").item("AllowCustomValue").value = 0/1
this should help you, I hope
Hello
Thank's but it seems that it works, but only if i first manually set "allow custom value",
without setting at beginning i got failure (i quess that item AllowCustomValue not exist !)
then by this code i can only change seeting from 0 or 1
UserParameters.item(1).attributeSets.item("com.autodesk.inventor.parameterAttributes").item("AllowCustomValue").value = 0/1
as soon as you make a multi value parameter, the attribute will also be created for that parameter.
value = 0 : check is off
value = 1 : check is on
when a parameter is not a multi value parameter the attribute does not exist
could You please look my file? inv. 2020.2
i disagree with You, attribute is not created, but true is that it should be created ![]()
Hello Marcin,
apperently the attribute is not created if you make the multyvalue by code....
so I altered your iLogic code a little so that the attribute is created.
the condition still is there that it should be a multi value!
try it, and let me know
Great job, thank's a lot !
One line must be added, if not, it worked only after manualy open list of parameters
pcd.Parameters.UserParameters.Item("param_N").AttributeSets.Add("com.autodesk.inventor.ParameterAttributes")
Dear Marcin,
exactly the functionality described here would help me a lot. Unfortunately, I am not getting the rule to run smoothly. I guess it has to do with the fact that I am creating the MultiValueList Parameters with an ilogic rule and therefore the AttributeSet does not seem to be created with it. Is it possible to post the complete rule text here again. That would be great. Thanks a los.
Best regards Ben
Sub Main Add_Parameters End Sub Sub Add_Parameters Dim doc As PartDocument doc = ThisDoc.Document Dim pcd As PartComponentDefinition pcd = doc.ComponentDefinition If ThisApplication.ActiveDocumentType = kPartDocumentObject Then MultiValue.UpdateAfterChange = True MultiValue.SetValueOptions(True) 'example to only setmulivalue j = 10 For i = 1 To j : Try : If Parameter("k_flange_N" & i) <> -100 Then : End If : Catch : doc.ComponentDefinition.Parameters.UserParameters.AddByExpression("k_flange_N" & i, 1, "mm") : End Try : Next For i = 1 To j : MultiValue.SetList("k_flange_N" & i, -1, 0, 1) : Next 'example to setmulivalue and allow custom value j = 20 index_no = 2 For i = 1 To j : Try : If Parameter("set_N" & i) <> -100 Then : End If : Catch : doc.ComponentDefinition.Parameters.UserParameters.AddByExpression("set_N" & i, 0, "mm") : End Try : Next For i = 1 To j MultiValue.SetList("set_N" & i, -2, -1, 0, 1) Set_Attributes_To_Mulitivalue("set_N" & i) 'set default index value Dim oParam1 As UserParameter oParam1 = ThisDoc.Document.componentdefinition.parameters.item("set_N" & i) oParam1.ExpressionList.SetExpressionList(oParam1.ExpressionList.GetExpressionList(), True, index_no) Next RuleParametersOutput() InventorVb.DocumentUpdate() End If End Sub Function Set_Attributes_To_Mulitivalue(PARAM_NAME As String) Dim doc As PartDocument doc = ThisDoc.Document Dim pcd As PartComponentDefinition pcd = doc.ComponentDefinition Try Dim paramAttribSet As AttributeSet pcd.Parameters.UserParameters.Item(PARAM_NAME).AttributeSets.Add("com.autodesk.inventor.ParameterAttributes") paramAttribSet = pcd.Parameters.UserParameters.Item(PARAM_NAME).AttributeSets.Item("com.autodesk.inventor.ParameterAttributes") Try paramAttribSet.Add("AllowCustomValue", ValueTypeEnum.kIntegerType, 0) Catch ex As Exception End Try paramAttribSet.Item("AllowCustomValue").Value = 1 Catch End Try End Function
Thanks a lot
! Exactly what I was looking for. Works great!