pcb_set_rule_properties
Update a named PCB design rule's metadata and constraint values, changing only the fields you specify while leaving all other settings untouched.
Instructions
Update metadata AND constraint values of a named PCB design rule.
Metadata fields always apply. Constraint fields are dispatched by the rule's underlying RuleKind:
Clearance (kind 0), ComponentClearance (kind 24), HoleToHoleClearance (kind 52) and BoardOutlineClearance (kind 63):
gap_mils, orgap_mmwhen the value is metric. An integer mil field cannot express 0.2mm; it lands on 8 mils, which is 0.2032mm. Pass one or the other.Width (kind 2):
min_width_mils/max_width_mils/favored_width_mils(applied to every layer).HoleSize (kind 42):
min_hole_size_mils/max_hole_size_mils.Routing Via:
min_via_size_mils/max_via_size_mils/preferred_via_size_milsand the three*_via_hole_mils. Checked as a set first (minimum <= preferred <= maximum, every diameter larger than its hole) and each read back; the reply carriesvia_sizes_milsandvia_sizes_written. A rule in template mode keeps checking its templates, andvia_notesays so; this cannot switch a rule between modes.
THE GAP WRITE IS READ BACK, not assumed. A rule kind that does
not really carry Gap can accept the assignment and keep its old
value, so the reply carries gap_written, gap_after_mm
and, when it did not take, a note saying the rule still holds
the old number. Kind 63 in particular is included on the
strength of its position in the TRuleKind order rather than a
documented interface, so let gap_written decide whether it
worked rather than the count.
Pass only the parameters you want to change; everything else
stays untouched. Each VERIFIED field write increments
properties_updated in the response, so a refused constraint
no longer inflates it.
NOTE: Priority is NOT writable from this tool. IPCB_Rule.Priority
is a read-only function in the PCB scripting API
(Function Priority : TRulePrecedence), not a property; there
is no SetState_Priority or SetPriority method either.
Assigning to it crashes the DelphiScript engine. To reorder rule
priorities, drag them in Altium's UI (PCB > Rules and Constraints
Editor; rules earlier in a category have higher priority).
Args:
name: Rule name to update.
enabled: Whether DRC enforces the rule.
scope1 / scope2: Rule scope query expressions. A comparison
joined by And/Or/Xor/Not must be bracketed
("IsPad And (HoleSize > 3)") or joined with &&;
an unbracketed one is refused before anything is sent.
comment: Free-form comment.
gap_mils: Clearance gap. Applies to Clearance,
ComponentClearance, and HoleToHoleClearance rules.
min_width_mils / max_width_mils / favored_width_mils:
Width constraint values (applied to every layer).
min_hole_size_mils / max_hole_size_mils: HoleSize
constraint limits.
Returns: Dict with name, rule_kind, and properties_updated count.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| gap_mm | No | ||
| scope1 | No | ||
| scope2 | No | ||
| comment | No | ||
| enabled | No | ||
| gap_mils | No | ||
| max_width_mils | No | ||
| min_width_mils | No | ||
| max_via_hole_mils | No | ||
| max_via_size_mils | No | ||
| min_via_hole_mils | No | ||
| min_via_size_mils | No | ||
| favored_width_mils | No | ||
| max_hole_size_mils | No | ||
| min_hole_size_mils | No | ||
| preferred_via_hole_mils | No | ||
| preferred_via_size_mils | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||