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 (Data panel).

The Parameters window

Item What it does
Search Shows only the parameters that have the text in their name.
User parameters only Hides the parameters of the features.
Show unused Also shows the feature parameters that the options of the feature do not use, for example the head size of a simple hole. It is off by default.
Add Adds a user parameter. Select the unit of the new parameter first.
Remove Removes the selected parameter.

The table has the columns Name, Expression, Value, Unit, Kind and Comment. An expression that is not a plain number shows an fx badge.

Add a user parameter

  1. Select Tools > Parameters.
  2. Select the unit of the new parameter.
  3. Click Add.
  4. Type a name and an expression.
  5. Use the name in a feature value or in other expressions.

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:

Unit Meaning
mm, cm, m Millimeters, centimeters, meters
in Inches
mil Thousandths of an inch
um or µm Micrometers
deg Degrees

The case of the letters is not important: MM and mm are the same. 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 (Atn is the same as Atan), Atan2
Trigonometry in degrees SinD, CosD, TanD, AsinD, AcosD, AtanD, Atan2D
Angle conversion Radians, Degrees
Rounding Round, Ceiling (or Ceil), Floor, Int, Fix
Other Sqrt, Abs, Min, Max, Exp, Log, Log10, Sign
Constant PI

Notes:

In a parameter expression, Meridian knows when a value is an angle. Thus Sin, Cos and Tan of an angle parameter use its degrees. A plain number uses radians. In a rule, these functions always use radians. Refer to Angles in rules.

References

Rules for expressions

Meridian Rules

A rule is a short program that changes parameters and properties. The language is similar to Visual Basic. The rules are saved in the document.

Write and run a rule

  1. Select Tools > Rules (Rules panel).
  2. Click Add to make a new rule. Type a Rule name.
  3. Type the rule in the editor.
  4. Click Check to find syntax errors.
  5. Click Save Rules to keep the rules in the document.
  6. Click Run.

To run the selected rule without the Rules window, select Tools > Run Rule. To delete a rule, select it and click Remove.

When you click Run in the Rules window, the status shows "The rule ran. The model is updated." If there are warnings, the status also shows "The log shows N warnings." The log shows all of the warnings.

When you use Tools > Run Rule and there are warnings, a message shows "Rule1 ran with N warnings." and up to 3 of the warnings. To see all of the warnings, run the rule in the Rules window.

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. Dim name As Double is also accepted. A Dim needs a type or a start value.
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

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

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

If the part does not regenerate after the rule, the command lists the features with errors, does not save, and stops with exit code 1. Refer to Command line.

An AI agent can run a rule with the MCP tool run_rule. Refer to MCP server for AI agents.