pcb_get_mech_layer_names
Lists all enabled mechanical layers on a PCB and optionally counts the primitives on each, helping you identify spare layers and verify board geometry usage.
Instructions
Every enabled mechanical layer on the board, and what is on it.
WHAT IS ON THE LAYER IS THE PART YOU CANNOT GET ELSEWHERE. A
PcbLib header carries USEDBYPRIMS; a PcbDoc does not, so on a
board there is no way to ask which mechanical layers the
geometry occupies. This counts, because moving kinds around on a
board you cannot inspect is how an assembly drawing gets
orphaned. primitive_count of 0 is a layer that is genuinely
spare; -1 means the count was not attempted or failed.
ENABLED, NOT DISPLAYED. This used to list only layers the view
happened to be showing, so a layer carrying the whole fab
drawing was missing from the answer whenever it was toggled off.
Display is a view setting and is reported separately as
displayed.
Each entry carries its kind, which is what the layer is FOR
rather than what it is called. Read it before setting one: a
kind belongs to a single layer, so assigning it moves it, and a
PAIRED kind is held by the layer pair. kind_id of -1 means
this Altium build has no mechanical layer kinds.
Args: count_primitives: Count what sits on each layer. The board is walked once per enabled layer, so pass False when only the names are wanted.
Returns:
Dict with mechanical_layers (each: layer, number, name,
enabled, displayed, kind, kind_id, primitive_count),
count, occupied_count, counted_primitives and
scanned_to, the layer number the scan stopped at.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count_primitives | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||