Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

how to allow custom values

marcin_bargiel
Advocate

how to allow custom values

marcin_bargiel
Advocate
Advocate

How to set by iLogic or VB :  "allow custom values" for all user multivalue parameters? (when creating them or later)

Vote for REPLACE VARIES !
REPLACE VARIES
0 Likes
Reply
Accepted solutions (1)
1,012 Views
10 Replies
Replies (10)

HermJan.Otterman
Advisor
Advisor

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

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes

marcin_bargiel
Advocate
Advocate

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

 

 

Vote for REPLACE VARIES !
REPLACE VARIES
0 Likes

HermJan.Otterman
Advisor
Advisor

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

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes

marcin_bargiel
Advocate
Advocate

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 :slightly_smiling_face:

 

Vote for REPLACE VARIES !
REPLACE VARIES
0 Likes

HermJan.Otterman
Advisor
Advisor
Accepted solution

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

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


marcin_bargiel
Advocate
Advocate

Great job, thank's a lot !

Vote for REPLACE VARIES !
REPLACE VARIES
0 Likes

marcin_bargiel
Advocate
Advocate

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")
		

 

Vote for REPLACE VARIES !
REPLACE VARIES
0 Likes

b.vonklass
Participant
Participant

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

0 Likes

marcin_bargiel
Advocate
Advocate
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
Vote for REPLACE VARIES !
REPLACE VARIES
0 Likes

b.vonklass
Participant
Participant

Thanks a lot :grinning_face:! Exactly what I was looking for. Works great!

0 Likes