Parameters and rules
Parameters
Each feature value in Meridian is a named parameter. For example, the distance of the first extrude is Extrude1_Distance. You can also add user parameters.
To see and change the parameters, select Tools > Parameters.
Expressions
A parameter value can be a number or an expression.
| Example | Result |
|---|---|
25 |
25 in the document unit. In a millimeter document, this is 25 mm. In an inch document, this is 25 in. |
2 in |
2 inches (50.8 mm). |
120/2 |
Meridian keeps the value 60 mm. |
Thickness * 2 |
Two times the parameter Thickness. |
Sqrt(Width ^ 2 + Height ^ 2) |
The diagonal of a rectangle. |
Units
You can write these units after a number: mm, cm, m, in and deg. A number without a unit uses the unit of the document. Angles are in degrees.
Operators
| Operator | Meaning |
|---|---|
+ - * / |
Add, subtract, multiply, divide |
\ |
Integer division (Meridian rounds both values, divides, and removes the fraction) |
^ |
Power |
Mod |
Remainder |
Functions
| Group | Functions |
|---|---|
| Trigonometry | Sin, Cos, Tan, Asin, Acos, Atan |
| Trigonometry in degrees | SinD, CosD, TanD, AsinD, AcosD, AtanD |
| Angle conversion | Radians, Degrees |
| Rounding | Round, Ceiling, Floor, Int, Fix |
| Other | Sqrt, Abs, Min, Max, Exp, Log, Sign |
| Constant | PI |
In a parameter expression, Meridian knows when a value is an angle. Thus Sin, Cos and Tan of an angle parameter use its degrees. In a rule, these functions use radians. Refer to Angles in rules.
References
- Use a parameter by its name, for example
Width. You can also writeParam("Width")orParameters("Width"). - Use a document property with
Property("name")orProperties("name").
Rules for expressions
- A parameter expression must give a number. Text and True/False values are not permitted.
- The result must have the correct kind of unit. If you enter an area for a length, Meridian shows "The expression gives an area. Enter a length."
- A count, for example the count of a pattern, must be a whole number from 1 to 2500.
Meridian Rules
A rule is a short program that changes parameters and properties. The language is similar to Visual Basic.
To write and run rules, select Tools > Rules. To run the selected rule, select Tools > Run Rule.
Example
' Comments start with ' or //
Extrude1_Distance = 35
Param("BoltPattern1_Count") = Round(Extrude1_Distance / 5)
Properties("Revision Number") = "R1"
Dim ratio = 0.5
If Extrude1_Distance >= 30 And Properties("Material") <> "Aluminum" Then
EdgeFillet1_Radius = 4
ElseIf Extrude1_Distance < 10 Then
EdgeFillet1_Radius = 1
Else
EdgeFillet1_Radius = 2
End If
Statements
| Statement | What it does |
|---|---|
Name = value |
Sets a parameter. |
Param("name") = value |
Sets a parameter. Parameters("name") is the same. |
Properties("name") = "text" |
Sets a document property. Property("name") is the same. |
Dim name = value |
Makes a variable that only the rule uses. |
If ... Then ... ElseIf ... Else ... End If |
Runs lines only when a condition is true. A short If can be on one line. |
More operators in rules
- Text:
&joins two texts.CStrchanges a number to text.CDblchanges text to a number. - Comparison:
=,<>,<,>,<=,>=. - Logic:
Not,And,Or,Xor,AndAlso,OrElse. TrueandFalse.- More functions:
Atan2,Atan2DandLog10.
Angles in rules
In a rule, Sin, Cos and Tan use radians. The unit deg does not change a value to radians. Thus Sin(30 deg) is the sine of 30 radians. For degrees, use SinD, CosD and TanD. For example, SinD(30) is 0.5. You can also use Radians(x) and Degrees(x).
How a rule runs
- A rule runs as one change. One Undo removes all of the changes of the rule.
- If an error occurs, the rule stops. Meridian shows the line of the error and removes all of the changes that the rule made.
- Errors include syntax errors, unknown names, wrong types, division by zero, and values that the model does not accept.
Run a rule from the command line
meridian rule part.mpart myrule.txt --save
meridian rule part.mpart -e "Extrude1_Distance = 40" --out part-40.mpart
Refer to Command line.