altium monkey v2026.11.26 · gobblerito
On This Page (13)

CLI: Monkey Change Orders (acr mco)

Monkey Change Orders (MCO) are declarative, ordered JSONC automation files that execute typed CAD mutations and exports across Altium projects (.PrjPcb), schematics (.SchDoc), symbol libraries (.SchLib), PCB documents (.PcbDoc), and footprint libraries (.PcbLib) through altium-cruncher.

MCO is both a standalone automation command (acr mco) and the shared execution substrate behind higher-level workflows such as acr vdoc, acr mate, acr prjpcb, acr schdoc, acr schlib, acr pcbdoc, and acr pcblib.

CLI Usage

powershell
# Generate an editable starter MCO JSONC file
acr mco init change_order.mco.jsonc

# List all 38 supported operations (human table or machine-readable JSON/JSONC)
acr mco list
acr mco list --json
acr mco list --output mco-operations.jsonc

# Validate and preview planned outputs without writing files
acr mco run change_order.mco.jsonc --dry-run

# Execute an MCO file and save a structured JSON execution report
acr mco run change_order.mco.jsonc --json-output out/mco-report.json

Subcommands & Flags

SubcommandFlagsDescription
acr mco run <file>--dry-run, --json, --json-output <PATH>, --no-colorExecute an MCO JSONC file, print a colored step summary (or stdout JSON with --json), and optionally save the execution report receipt to --json-output
acr mco init <file>--forceWrite a commented starter MCO JSONC template (--force overwrites an existing file)
acr mco list--json, --output <PATH>, --no-colorDisplay all supported MCO operations grouped by domain, print altium_cruncher.mco.operations.a0 JSON, or write a JSONC catalog file

Envelope Format & Execution Semantics

An MCO file is standard JSONC (line comments //, block comments /* ... */, and trailing commas are supported) using schema "altium_cruncher.mco.a0":

jsonc
{
  "schema": "altium_cruncher.mco.a0",
  "operations": [
    {
      "id": "step_1",
      "op": "mco.message",
      "message": "Human-readable log label for this step",
      "args": {
        "text": "Starting change order"
      }
      // Optional control-flow jump target on failure:
      // "on_fail": "fallback_step_id"
    }
  ]
}

Key execution guarantees:

Complete Operation Reference (38 Operations)

All 38 built-in MCO operations are grouped into four domains below. Run acr mco list --json at any time to inspect the exact live metadata.

File & Control (3 Operations)

OperationRequired ArgsKey Optional ArgsSummary & Outputs
file.copysource, destinationoverwrite (false)Copy one file into the workflow output tree. Outputs source, destination.
mco.message (alias message)—textEmit a human-readable status message in the execution log and receipt.
mco.fail (alias fail)—messageFail intentionally (useful with on_fail error-handling branches).

Project & Variants (10 Operations)

OperationRequired ArgsKey Optional ArgsSummary & Outputs
project.createfilename, project_name, overwriteCreate an empty .PrjPcb file. Outputs project.
project.add_documentfile, documentunique_idAppend a document entry to a .PrjPcb file (idempotent if already listed). Outputs project, document.
project.add_parameterfile, name, value—Set one project-level parameter on a .PrjPcb. Outputs project, name.
project.add_variantfile, nameunique_id, allow_fabrication, currentAdd one assembly variant to a .PrjPcb. Outputs project, name.
project.list_variantsfile—List project variants, admitted DNP rows, and parameter changes. Outputs structured variant summary.
project.clone_variantfile, source_name, nameunique_id, allow_fabrication, currentClone an existing project variant (including DNP rows and parameter overrides) under a new name.
project.rename_variantfile, name, new_name—Rename an existing project variant in place.
project.delete_variantfile, name—Delete one project variant from a .PrjPcb.
project.add_variant_dnpfile, variant, designatorunique_id, alternate_partMark one component designator Not Fitted (DNP) in a project variant.
project.toggle_variant_dnpfile, variant, designatorunique_id, alternate_partToggle one designator between fitted and Not Fitted in a project variant. Outputs dnp state.

Schematic & Symbol Libraries (8 Operations)

OperationRequired ArgsKey Optional ArgsSummary & Outputs
schdoc.createfiletemplate, sheet_style ("D"), apply_template_visual_sheet_settings, custom_sheet_mils, overwriteCreate an empty .SchDoc (optionally applying a .SchDot template or custom size). Outputs schematic.
schdoc.add_componentfile, library, symbol, designator, position_milsoutput_file, overwrite, unique_id, design_item_id, footprint_model, footprint_library, parameters, orientation, mirrored, part_id, display_mode, designator_style, comment_style, footprint_descriptionInsert a schematic component from a .SchLib with optional parameters and footprint links.
schdoc.add_wirefile, points_milsoutput_file, overwriteAdd a multi-vertex schematic wire (points_mils array of [x, y] mil points).
schdoc.add_net_labelfile, text, location_milsoutput_file, overwrite, orientation, justification ("BOTTOM_LEFT")Add a schematic net label at location_mils.
schdoc.add_power_portfile, text, location_milsoutput_file, overwrite, style ("BAR"), orientation, show_net_name (true)Add a schematic power port symbol at location_mils.
schdoc.rename_source_fieldsfile, editsoutput_file, overwritePreflight exact scalar Name/Text edits (object_kind, object_uid, owner_uid, field, old_value, new_value) and atomically rename the selected source fields.
schlib.createfileoverwriteCreate an empty .SchLib symbol library. Outputs library.
schlib.add_symbolfile, namedescriptionAdd one empty schematic symbol to a .SchLib. Outputs library, symbol.

PCB & Footprint Libraries (17 Operations)

OperationRequired ArgsKey Optional ArgsSummary & Outputs
pcbdoc.createfilelayer_stack_template, rigid_stack, stackupx_file, board_outline_mils, board_origin_mils, sheet_frame_mils, mechanical_layer_profile, mechanical_layers, mechanical_layer_pairs, mechanical_layer_kinds, overwriteCreate an empty .PcbDoc with board outline, origin, layer stack, and mechanical layer setup. Outputs board.
pcbdoc.add_componentfile, library, footprint, designator, position_milsoutput_file, overwrite, layer ("TOP"), rotation_degrees, pad_nets, component_parameters, comment_text, comment_visible, source_unique_id, source_hierarchical_path, source_component_library, source_lib_reference, source_description, source_footprint_library, source_designator, channel_offsetInsert a PCB component from a .PcbLib with pad net assignments and source links.
pcbdoc.add_padfile, designator, position_mils, width_mils, height_milsoutput_file, overwrite, shape, corner_radius_percent, rotation_degrees, hole_size_mils, plated, layer, net, solder_mask_expansion_mils, paste_mask_expansion_mils, tenting_top, tenting_bottom, solder_mask_expansion_mode, paste_mask_expansion_modeAdd a free SMT, through-hole, or NPTH PCB pad.
pcbdoc.add_viafile, position_mils, diameter_mils, hole_size_milsoutput_file, overwrite, layer_start, layer_end, netAdd a PCB via spanning layer_start to layer_end.
pcbdoc.add_trackfile, start_mils, end_mils, width_milsoutput_file, overwrite, layer ("TOP"), netAdd a routed or mechanical PCB track segment.
pcbdoc.add_arcfile, center_mils, radius_mils, start_angle_degrees, end_angle_degrees, width_milsoutput_file, overwrite, layer ("TOP"), netAdd a PCB circular arc or full circle.
pcbdoc.add_fillfile, corner1_mils, corner2_milsoutput_file, overwrite, rotation_degrees, layer, netAdd a rectangular PCB fill primitive.
pcbdoc.add_regionfile, outline_points_milsoutput_file, overwrite, layer, hole_points_mils, is_keepout, keepout_restrictions, net, is_board_cutoutAdd a polygonal copper, mechanical, keepout, or board-cutout PCB region.
pcbdoc.add_textfile, text, position_mils, height_milsoutput_file, overwrite, layer, font_kind, font_name, bold, italic, rotation_degrees, stroke_width_mils, is_comment, is_designator, is_mirrored, is_inverted, is_frame, text_justification, barcode_kind, barcode_render_mode, barcode_full_size_mils, barcode_margin_mils, barcode_min_width_mils, barcode_show_text, barcode_invertedAdd stroke text, TrueType text, or 1D/2D PCB barcodes (Code 39, Code 128, QR Code, Data Matrix).
pcbdoc.add_embedded_3d_modelfile, model_fileoutput_file, overwrite, model_name, name, layer ("MECHANICAL_13"), side ("TOP"), location_mils, rotation_x_degrees, rotation_y_degrees, rotation_z_degrees, z_mm, z_mils, bounds_mils, projection_outline_mils, overall_height_mils, opacityEmbed a STEP 3D model into a .PcbDoc and place a board-level 3D body.
pcbdoc.arrange_designatorsfileoutput_file, overwrite, designators, placement, offset_mils, height_mils, layer, stroke_width_mils, width_factor, bold, italic, font_name, font_kindReposition and style generated PCB component designator text.
pcbdoc.create_user_unionfile, nameoutput_file, overwrite, membersCreate a named Altium User Union over PCB objects.
pcbdoc.bake_virtual_layers (alias pcbdoc.bake-virtual-layers)input, layer_mapoutput, project, variant, virtual_layers, clear_existing (true), clear_only (false), remove_cleared_layers (true), set_layer_names (true), set_layer_pairs (true), cutouts_union_name ("Virtual_Cutouts"), union_designators_with_component (true), designator_mode ("strokes" | "native_text")Compute FabView virtual layers and bake them onto Altium mechanical layers of a .PcbDoc (preserving component ownership and User Unions), or clear & hide emptied layers with clear_only: true. Outputs per-layer counts (tracks, arcs, regions, texts, cleared), total_written, total_cleared, unions_created, layers_removed, warnings.
pcbdoc.export_layer_stepfile, output_filelayer, board_name, highlights, overwriteExport a 3D PCB layer alignment STEP model via the pure-Python Micro-STEP AP242/AP214 engine alongside its companion manifest.
pcblib.createfileoverwriteInitialize a new .PcbLib footprint library. Outputs library.
pcblib.add_footprintfile, nameoutput_file, overwrite, height, description, item_guid, revision_guid, parameters, primitive_parametersAdd one empty footprint container to a .PcbLib.
pcblib.bake_virtual_layers (alias pcblib.bake-virtual-layers)input, layer_mapoutput, footprints, virtual_layers, clear_existing (true), clear_only (false), remove_cleared_layers (true), set_layer_names (true), set_layer_pairs (true), designator_mode ("strokes" | "native_text")Compute virtual layers (ASSEMBLY_OUTLINES_TOP, PIN1_TOP, PAD_LABELS_TOP, etc.) and bake them onto mechanical layers of .PcbLib footprints (with shared STEP HLR cache), or clear & hide emptied layers with clear_only: true. Outputs per-layer counts, layers_removed, and footprints_processed.

Practical MCO Recipes

1. Assembly Variant Cloning & DNP Update

Clone a baseline variant, mark prototype debug parts as Not Fitted, update a project revision parameter, and inspect the resulting variant summary:

jsonc
{
  "schema": "altium_cruncher.mco.a0",
  "operations": [
    {
      "id": "clone_prod",
      "op": "project.clone_variant",
      "message": "Create Production variant from Prototype",
      "args": {
        "file": "sensor_board.PrjPcb",
        "source_name": "Prototype",
        "name": "Production",
        "allow_fabrication": true,
        "current": true
      }
    },
    {
      "id": "dnp_debug_hdr",
      "op": "project.add_variant_dnp",
      "message": "Mark debug header J7 Not Fitted in Production",
      "args": {
        "file": "sensor_board.PrjPcb",
        "variant": "Production",
        "designator": "J7"
      }
    },
    {
      "id": "set_rev",
      "op": "project.add_parameter",
      "message": "Record release revision parameter",
      "args": {
        "file": "sensor_board.PrjPcb",
        "name": "ReleaseVariant",
        "value": "Production"
      }
    },
    {
      "id": "verify_variants",
      "op": "project.list_variants",
      "message": "Emit updated variant inventory in the execution report",
      "args": {
        "file": "sensor_board.PrjPcb"
      }
    }
  ]
}

2. Bake Virtual Fabrication Layers Onto Safe Mechanical Layers

Bake cutouts, Pin 1 markers, diode glyphs, 3D STEP HLR assembly outlines, fitted assembly designators, and pad labels onto MECHANICAL35..44 (safely above Altium's MECHANICAL1..32 footprint layers) into a separate output .PcbDoc:

jsonc
{
  "schema": "altium_cruncher.mco.a0",
  "operations": [
    {
      "id": "bake_board",
      "op": "pcbdoc.bake_virtual_layers",
      "message": "Bake virtual fab and assembly layers onto M35..M44",
      "args": {
        "input": "sensor_board.PcbDoc",
        "output": "out/sensor_board_with_vdoc.PcbDoc",
        "project": "sensor_board.PrjPcb",
        "layer_map": {
          "CUTOUTS": "MECHANICAL35",
          "PIN1_TOP": "MECHANICAL36",
          "PIN1_BOTTOM": "MECHANICAL37",
          "DIODES_TOP": "MECHANICAL38",
          "DIODES_BOTTOM": "MECHANICAL39",
          "ASSEMBLY_OUTLINES_TOP": "MECHANICAL40",
          "ASSEMBLY_OUTLINES_BOTTOM": "MECHANICAL41",
          "ASSEMBLY_DESIGNATORS_TOP": "MECHANICAL42",
          "ASSEMBLY_DESIGNATORS_BOTTOM": "MECHANICAL43",
          "PAD_LABELS_TOP": "MECHANICAL44"
        },
        "virtual_layers": {
          "font_mode": "stroke",
          "stroke_font": "sans_serif",
          "pin1": {
            "style": "dot",
            "exclude_two_pin_prefixes": ["X", "Y"]
          },
          "pad_labels": {
            "knockout": false
          }
        },
        "clear_existing": true,
        "set_layer_names": true,
        "set_layer_pairs": true,
        "designator_mode": "strokes"
      }
    }
  ]
}

Tip: For interactive day-to-day baking with automatic vdoc.jsonc management, sibling fab.jsonc inheritance, .bak backups, and occupied-layer collision protection, see acr vdoc.

3. Programmatic Board Creation & Micro-STEP Alignment Export

Synthesize a fresh 2-layer test coupon .PcbDoc, add pads, routing, and a silkscreen label, then export a colored AP242 Micro-STEP layer alignment model:

jsonc
{
  "schema": "altium_cruncher.mco.a0",
  "operations": [
    {
      "id": "create_board",
      "op": "pcbdoc.create",
      "message": "Create 2000 x 1200 mil test fixture coupon",
      "args": {
        "file": "out/fixture_coupon.PcbDoc",
        "board_outline_mils": {
          "left": 0,
          "bottom": 0,
          "right": 2000,
          "top": 1200
        },
        "overwrite": true
      }
    },
    {
      "id": "add_tp1",
      "op": "pcbdoc.add_pad",
      "message": "Add plated mounting/probe pad TP1",
      "args": {
        "file": "out/fixture_coupon.PcbDoc",
        "designator": "1",
        "position_mils": [400, 600],
        "width_mils": 80,
        "height_mils": 80,
        "hole_size_mils": 40,
        "plated": true,
        "layer": "MULTI_LAYER",
        "net": "SIG_A"
      }
    },
    {
      "id": "add_tp2",
      "op": "pcbdoc.add_pad",
      "message": "Add plated mounting/probe pad TP2",
      "args": {
        "file": "out/fixture_coupon.PcbDoc",
        "designator": "2",
        "position_mils": [1600, 600],
        "width_mils": 80,
        "height_mils": 80,
        "hole_size_mils": 40,
        "plated": true,
        "layer": "MULTI_LAYER",
        "net": "SIG_A"
      }
    },
    {
      "id": "route_bottom",
      "op": "pcbdoc.add_track",
      "message": "Route SIG_A on Bottom copper",
      "args": {
        "file": "out/fixture_coupon.PcbDoc",
        "start_mils": [400, 600],
        "end_mils": [1600, 600],
        "width_mils": 20,
        "layer": "BOTTOM",
        "net": "SIG_A"
      }
    },
    {
      "id": "export_step",
      "op": "pcbdoc.export_layer_step",
      "message": "Export Bottom copper alignment STEP via Micro-STEP",
      "args": {
        "file": "out/fixture_coupon.PcbDoc",
        "output_file": "out/fixture_coupon_bottom.step",
        "layer": "BOTTOM",
        "board_name": "fixture_coupon",
        "overwrite": true
      }
    }
  ]
}
altium-monkey v2026.11.26 · gobblerito·Docs updated 2026.11.29 17:55 UTC (0665053)