Locking User Defined Parameters

Locking User Defined Parameters

tschaeferZNBXX
Advisor Advisor
1,552 Views
8 Replies
Message 1 of 9

Locking User Defined Parameters

tschaeferZNBXX
Advisor
Advisor

Does anyone know if there is a way to lock the user defined parameters in a model?  I am trying to ensure that users cannot change any of these when using what I will call a start model which has some iLogic and rules in place.  I worry that some users may see the parameter and try to delete or modify them which will then mess up our iLogic and Forms.

Parameters.PNG

Thomas "Matt" Schaefer
Engineering Tooling and Vault Manager for Material Handling Systems MHS


*AU Speaker 2018*
* AU Speaker 2017 *
==========================================================
Please use the "Accept as Solution" and "Give Kudos" functions as appropriate to further enhance the value of these forums.
0 Likes
1,553 Views
8 Replies
Replies (8)
Message 2 of 9

LukeDavenport
Collaborator
Collaborator
Why not just use the start part as a template. That's the easiest way probably
0 Likes
Message 3 of 9

tschaeferZNBXX
Advisor
Advisor

Here is what we currently have.  They are set as templates but the ability to change the parameters still exists.

 

This is what a user will use to start their model.

 

START.PNG

Thomas "Matt" Schaefer
Engineering Tooling and Vault Manager for Material Handling Systems MHS


*AU Speaker 2018*
* AU Speaker 2017 *
==========================================================
Please use the "Accept as Solution" and "Give Kudos" functions as appropriate to further enhance the value of these forums.
0 Likes
Message 4 of 9

LukeDavenport
Collaborator
Collaborator

 

 

Option 1) Set the parameter to the required static value on document open/save/at the start of existing rule?

Option 2) Set Parameter.DisabledActionTypes Property to kAllActions? (Although I don't think this stops modification of the value unfortunately).

 

0 Likes
Message 5 of 9

tschaeferZNBXX
Advisor
Advisor
Not sure I fully understand the first option. Do you have any screen shoots to show this?
Thomas "Matt" Schaefer
Engineering Tooling and Vault Manager for Material Handling Systems MHS


*AU Speaker 2018*
* AU Speaker 2017 *
==========================================================
Please use the "Accept as Solution" and "Give Kudos" functions as appropriate to further enhance the value of these forums.
0 Likes
Message 6 of 9

DRoam
Mentor
Mentor

For the OP or anyone else looking to do this:

 

  • To block deleting a parameter, use Parameter.Param("ParameterName").DisabledActionTypes = ActionTypeEnum.kDeleteAction.
  • To block editing a parameter's value, convert it to a Reference Parameter using: Parameter.Param("ParameterName").ConvertToReferenceParameter. (Keep in mind that in order to modify the parameter's value after that, you have to convert it back to a User Parameter first, using Parameter.Param("ParameterName").ConvertToUserParameter, change the value, and then convert it back to a Reference Parameter).
  • To block renaming a parameter, please vote for the following idea: iLogic/API: Prevent renaming of certain Parameters.
Message 7 of 9

Anonymous
Not applicable

Yes this is almost what I am looking for,too. But if I use Parameter.Param("ParameterName").ConvertToReferenceParameter it works fine and convert the parameter as expected. Then if a value change then I got this message "Public member 'ConvertToReferenceParameter' on type 'ReferenceParameter' not found." So I suppose that you can not use this command when the parameter is already that kind of parameter (Reference). Is any way to check it before I use the command for example something like this:

 

IF UserParameters("Parameter1").exist= True Then Parameter.Param("ParameterName").ConvertToReferenceParameter 

End if

0 Likes
Message 8 of 9

WCrihfield
Mentor
Mentor

Hi @Anonymous.  It looks like you need a way to check if the specific named parameter is already a reference parameter before attempting to convert it into a reference parameter.  Here is something you can use for this task:

 

Dim oPDoc As AssemblyDocument = ThisDoc.Document
oParams = oPDoc.ComponentDefinition.Parameters
Dim oParam As Inventor.Parameter
Try
	oParam = oParams.Item("Parameter1")
Catch oEx As Exception
	MsgBox("Parameter not found." & vbCrLf & oEx.Message, , "")
End Try
If IsNothing(oParam) Then Exit Sub
If oParam.ParameterType <> ParameterTypeEnum.kReferenceParameter Then
	Try
		oParam.ConvertToReferenceParameter
	Catch oEx As Exception
		MsgBox("Failed to convert to Reference." & vbCrLf &
		oEx.Message & vbCrLf & oEx.StackTrace & vbCrLf & oEx.Source, , "")
	End Try
End If

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 9 of 9

Anonymous
Not applicable

Thanks for your response. It seems a little bit more complicated than expected. I tried this instead: 

 

Parameter.Param("ParameterName").ConvertToModelParameter 

 

if  A>B Then 

Parameter.Param("ParameterName").ConvertToReferenceParameter 

else if 

Parameter.Param("ParameterName").ConvertToUserParameter 

end if 

 

So now it can be converted in any case. It works when I manually run the rule but it crashes when i change a parameter (i don t know why yet). I have to "Save & Run" the rule manually to work.

0 Likes