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

Examples Showcase / pcbdoc_add_free_3d_extruded

Add a free extruded 3D body to a PcbDoc

Create a PcbDoc and add a board-level generic extruded 3D body from a polygon projection.

pcbdoc3dpcbdoc3dcomponent-bodyextrudedgeneration

Open an existing blank PcbDoc and add a free board-level extruded 3D body. This is the generic Altium 3D Body workflow where a 2D outline is extruded between a standoff height and an overall height.

What It Shows

  1. AltiumPcbDoc.add_extruded_3d_body(...)
  2. Supplying a polygon projection in mils
  3. Setting standoff height, overall height, side, color, and opacity
  4. Saving the modified board through pcbdoc.save(...)

Run

From the repository root:

powershell
uv run python examples\pcbdoc_add_free_3d_extruded\pcbdoc_add_free_3d_extruded.py

Output

text
examples/pcbdoc_add_free_3d_extruded/output/pcbdoc_add_free_3d_extruded.PcbDoc

Source Code

examples/pcbdoc_add_free_3d_extruded/pcbdoc_add_free_3d_extruded.py
from pathlib import Path

from altium_monkey import AltiumPcbDoc, PcbBodyProjection, PcbLayer

SAMPLE_DIR = Path(__file__).resolve().parent
EXAMPLES_ROOT = SAMPLE_DIR.parent
INPUT_PCBDOC = EXAMPLES_ROOT / "assets" / "pcbdoc" / "blank.PcbDoc"
OUTPUT_PATH = SAMPLE_DIR / "output" / "pcbdoc_add_free_3d_extruded.PcbDoc"


def build_pcbdoc(output_path: Path = OUTPUT_PATH) -> Path:
    output_path.parent.mkdir(parents=True, exist_ok=True)

    pcbdoc = AltiumPcbDoc.from_file(INPUT_PCBDOC)

    pcbdoc.add_extruded_3d_body(
        outline_points_mils=[
            (2900.0, 2300.0),
            (4700.0, 2300.0),
            (4900.0, 2800.0),
            (4700.0, 3300.0),
            (2900.0, 3300.0),
            (2700.0, 2800.0),
        ],
        layer=PcbLayer.MECHANICAL_1,
        overall_height_mils=180.0,
        standoff_height_mils=20.0,
        side=PcbBodyProjection.TOP,
        name="FREE_EXTRUDED_HEX",
        body_color_3d=0xC07030,
        opacity=0.85,
    )

    pcbdoc.save(output_path)
    return output_path


def main() -> None:
    output_path = build_pcbdoc()
    print(f"Wrote {output_path}")


if __name__ == "__main__":
    main()
altium-monkey v2026.11.26 · gobblerito·Docs updated 2026.11.29 17:55 UTC (0665053)