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

Creating User Parameter with a Rule

Anonymous

Creating User Parameter with a Rule

Anonymous
Not applicable

Is there a way to automatically create one or more Parameters with a rule so that when i create a new part or assembly I automatically always have a set of parameters.

0 Likes
Reply
Accepted solutions (1)
966 Views
6 Replies
Replies (6)

mcgyvr
Consultant
Consultant

@Anonymous wrote:

Is there a way to automatically create one or more Parameters with a rule so that when i create a new part or assembly I automatically always have a set of parameters.


Sure.. 

You could also just add those parameters to your template files so they are always there upon starting a new file from those templates.  No coding required for that. 

 

Here is help on how to create new custom templates (you can also just modify the existing ones)

https://knowledge.autodesk.com/support/inventor/learn-explore/caas/CloudHelp/cloudhelp/2020/ENU/Inventor-Help/files/GUID-598A0524-BEF9-4F48-8650-69372D5E7CFE-htm.html

 

 

Here is some help on creating user parameters via ilogic 

https://help.autodesk.com/view/INVNTOR/2020/ENU/?guid=GUID-DB91F7F6-842C-4849-A856-1003F8B7C576

 

Let us know if you need additional help and be specific

 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269

Anonymous
Not applicable

I can't change the templates that's above my pay grade :slightly_smiling_face: 

0 Likes

mcgyvr
Consultant
Consultant

@Anonymous wrote:

I can't change the templates that's above my pay grade :slightly_smiling_face: 


um... ok..

How much experience do you have with ilogic? 

Can you be specific about what parameters you would like to create?

Do you need us to write this rule for you or will the link I posted above be sufficient?

 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes

Anonymous
Not applicable

I'm quite new with iLogics I've played around with it a bit, My programming skils are not that great so if you'd like to help that would be great :). I just like to creat a few Parameters like Length, Width, Height etc. and then I'd lik to add these Parameters to a global form which auromatically pops up when creating a new document that last part i've done now only the creation of the parameters

0 Likes

J-Camper
Advisor
Advisor
Accepted solution

I put together a little sample of how you can add different types of User Parameters:

'Access User parameters of the active document
Dim oMyParameters As UserParameters = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters 
'Create list of Parameter names of type: number
Dim numParams As New List(Of String) 
numParams.AddRange({"Height", "Length", "Thickness"})
'Create list of Parameter names of type: text
Dim textParams As New List(Of String) 
textParams.AddRange({"Name", "Side", "Orientation"})
'Create list of Parameter names of type: True/False
Dim booleanParams As New List(Of String) 
booleanParams.AddRange({"Two_Side_Machining", "Buyout"})
'Testing and Creation of User Parameters of type: number
For Each item In numParams
	Try 'Check if User Parameter exists
		Param = oMyParameters.Item(item)
	Catch 'Parameter doesn't exist as a User Parameter
		Try 'attempt to create new parameter
			oMyParameters.AddByExpression(item, 0, UnitsTypeEnum.kInchLengthUnits) '(Name, Value, Unit Type)
		Catch 'Parameter exists but not as a User Parameter
			MessageBox.Show("The Parameter: " & item & " exists as a parameter, but is not a user parameter.", "Creation Failure")
		End Try
	End Try
Next
'Testing and Creation of User Parameters of type: text
For Each item In textParams
	Try 'Check if User Parameter exists
		Param = oMyParameters.Item(item)
	Catch 'Parameter doesn't exist as a User Parameter
		Try 'attempt to create new parameter
			oMyParameters.AddByValue(item, "filler", UnitsTypeEnum.kTextUnits) '(Name, Value, Unit Type)
		Catch 'Parameter exists but not as a User Parameter
			MessageBox.Show("The Parameter: " & item & " exists as a parameter, but is not a user parameter.", "Creation Failure")
		End Try
	End Try
Next
'Testing and Creation of User Parameters of type: True/False
For Each item In booleanParams
	Try 'Check if User Parameter exists
		Param = oMyParameters.Item(item)
	Catch 'Parameter doesn't exist as a User Parameter
		Try 'attempt to create new parameter
			oMyParameters.AddByValue(item, True, UnitsTypeEnum.kBooleanUnits) '(Name, Value, Unit Type)
		Catch 'Parameter exists but not as a User Parameter
			MessageBox.Show("The Parameter: " & item & " exists as a parameter, but is not a user parameter.", "Creation Failure")
		End Try
	End Try
Next

 I tried to add enough comments to help you understand what is happening so you can modify as needed.  Let me know if you have any questions.

Anonymous
Not applicable

Thank you very much this will do for what I want. 

0 Likes