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
Solved! Go to Solution.
Solved by Sergio.D.Suárez. Go to Solution.
Solved by Sergio.D.Suárez. Go to Solution.
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!
Sergio Daniel Suarez
Mechanical Designer
| Upwork Profile | LinkedIn
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.
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
Sergio Daniel Suarez
Mechanical Designer
| Upwork Profile | LinkedIn
Can't find what you're looking for? Ask the community or share your knowledge.