Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem About Defining User Parameter Type As Square Meter

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
438 Views, 4 Replies

Problem About Defining User Parameter Type As Square Meter

Hi,

 

I have a problem about defining user parameter type as square meter. I know i can change it from unit settings but i need to add this as a rule.

 

After "UnitsTypeEnum." there is no selection for square meter.

 

 

 

oUserParams.AddByValue("MyParameter","MyValue", UnitsTypeEnum.)

Other question is what i need to do to work this rule both part and assembly ? Changing "PartDocument" with "Document" is not working.

 

Here is the simple code.

			Dim oParams As Parameters
			Dim oPartDoc As PartDocument = ThisDoc.Document
			Dim oPartCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
			oParams = oPartCompDef.Parameters

			Dim oUserParams As UserParameters = oParams.UserParameters

			Try
			  p = Parameter("MyParameter")
			Catch
			  oUserParams.AddByValue("MyParameter","MyValue", UnitsTypeEnum.)
			End Try

 

 

4 REPLIES 4
Message 2 of 5
Sergio.D.Suárez
in reply to: Anonymous

Hi, try to execute the following rule in part or assembly file.
you must remove the string "Part" in the document definition, and in the component definition.
In the end I have placed some common units for your created parameter.

 

Dim ParamValue As Double = 6
Dim ParamName = "MyParameter"

Dim oDoc As Document = ThisDoc.Document
Dim oCD As ComponentDefinition = oDoc.ComponentDefinition
Dim oParams As Parameters = oCD.Parameters
Dim oUserParams As UserParameters = oParams.UserParameters

Try
	oParams(ParamName).Expression = ParamValue
Catch
	oUserParams.AddByExpression(ParamName, ParamValue, 11270)
	'oUserParams.AddByValue(ParamName,6,11270)
End Try
Parameter.UpdateAfterChange = True
iLogicVb.UpdateWhenDone = True


'kCentimeterLengthUnits 11268 Centimeter Length. 
'kMeterLengthUnits 11270 Meter Length. 
'kMillimeterLengthUnits 11269 Millimeter Length. 

 I hope this helps with your problem. Cheers!


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 3 of 5
Anonymous
in reply to: Sergio.D.Suárez

Hi Sergio,

 

Thank you for your help. It helps me to run the rule for both part and assy documents. However m^2 problem is continue. After i find a solution for that, i will accept your solution as well.

Message 4 of 5
Anonymous
in reply to: Anonymous

Well, solution was easy. Just add "m^2".

 

oUserParams.AddByExpression(ParamName, ParamValue, "m^2")

 

Message 5 of 5
Sergio.D.Suárez
in reply to: Anonymous

Excuse me I had not noticed the unit. Try the following rule. Cheers

 

Dim ParamValue As Double = 6
Dim ParamName = "MyParameter"
Dim oUnits As String = "m^2"

Dim oDoc As Document = ThisDoc.Document
Dim oCD As ComponentDefinition = oDoc.ComponentDefinition
Dim oParams As Parameters = oCD.Parameters
Dim oUserParams As UserParameters = oParams.UserParameters

Try
	oParams(ParamName).Units = oUnits
	oParams(ParamName).Expression = ParamValue
Catch
	oUserParams.AddByExpression(ParamName, ParamValue, 11270)
	oParams(ParamName).Units = oUnits
	oParams(ParamName).Expression = ParamValue
End Try
Parameter.UpdateAfterChange = True
iLogicVb.UpdateWhenDone = True

 


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report