On This Page (4)
Examples Showcase / pcbdoc_create_rigid_flex_impedance_backdrill
Create a rigid-flex impedance/backdrill PcbDoc
Recreate a fixture-derived nested rigid-flex PcbDoc with impedance profiles, transmission lines, via spans, and backdrill layer pairs, then verify PcbDoc readback.
Create a fixture-backed nested rigid-flex PcbDoc with impedance profiles and backdrill/via-span metadata.
This sample uses a neutral public spec derived from an AD-authored nested rigid-flex fixture. It writes a recreated PcbDoc with seven substacks, three branches, three bend lines, split-plane polygons, mechanical region evidence, impedance profiles, transmission-line rows, and multiple layer-pair/via-span definitions including backdrill spans. It also emits exact AD-exported .stackup and .stackupx reference files, then reads the PcbDoc back with AltiumLayerStackDocument and verifies the authored topology.
What It Shows
- Building an
AltiumLayerStackDocumentfor nested advanced rigid-flex - Preserving impedance and transmission-line data in native PcbDoc stack data
- Preserving layer-pair/via-span and backdrill metadata
- Writing native stack data through
PcbDocBuilder.set_layer_stack_document(...) - Replaying split-plane polygons, regions, and mechanical split-line evidence
- Verifying branch topology, bends, impedance data, layer pairs, native geometry, and exact stackup exports
Run
From the repository root:
uv run python examples\pcbdoc_create_rigid_flex_impedance_backdrill\pcbdoc_create_rigid_flex_impedance_backdrill.pyOutput
examples/pcbdoc_create_rigid_flex_impedance_backdrill/output/pcbdoc_create_rigid_flex_impedance_backdrill.PcbDoc
examples/pcbdoc_create_rigid_flex_impedance_backdrill/output/pcbdoc_create_rigid_flex_impedance_backdrill.stackup
examples/pcbdoc_create_rigid_flex_impedance_backdrill/output/pcbdoc_create_rigid_flex_impedance_backdrill.stackupx
examples/pcbdoc_create_rigid_flex_impedance_backdrill/output/rigid_flex_impedance_backdrill_manifest.jsonSource Code
from __future__ import annotations
import json
from pathlib import Path
import sys
SAMPLE_DIR = Path(__file__).resolve().parent
EXAMPLES_ROOT = SAMPLE_DIR.parent
sys.path.insert(0, str(EXAMPLES_ROOT))
from _helpers._pcbdoc_rigid_flex_authoring import ( # noqa: E402
add_recreation_primitives,
build_recreation_document,
recreation_board_outline_mils,
recreation_reference_stackup_path,
recreation_reference_stackupx_path,
write_case_outputs,
)
SPEC_NAME = "rigid_flex_impedance_backdrill"
OUTPUT_DIR = SAMPLE_DIR / "output"
OUTPUT_PCBDOC = OUTPUT_DIR / "pcbdoc_create_rigid_flex_impedance_backdrill.PcbDoc"
OUTPUT_STACKUP = OUTPUT_DIR / "pcbdoc_create_rigid_flex_impedance_backdrill.stackup"
OUTPUT_STACKUPX = OUTPUT_DIR / "pcbdoc_create_rigid_flex_impedance_backdrill.stackupx"
OUTPUT_MANIFEST = OUTPUT_DIR / "rigid_flex_impedance_backdrill_manifest.json"
def build_outputs() -> tuple[Path, Path, Path, Path]:
outputs = write_case_outputs(
build_recreation_document(SPEC_NAME),
pcbdoc_path=OUTPUT_PCBDOC,
stackup_path=OUTPUT_STACKUP,
stackupx_path=OUTPUT_STACKUPX,
manifest_path=OUTPUT_MANIFEST,
board_outline_mils=recreation_board_outline_mils(SPEC_NAME),
examples_root=EXAMPLES_ROOT,
add_primitives=lambda builder: add_recreation_primitives(builder, SPEC_NAME),
reference_stackup_path=recreation_reference_stackup_path(SPEC_NAME),
reference_stackupx_path=recreation_reference_stackupx_path(SPEC_NAME),
)
return (
outputs.pcbdoc_path,
outputs.stackup_path,
outputs.stackupx_path,
outputs.manifest_path,
)
def main() -> None:
pcbdoc_path, stackup_path, stackupx_path, manifest_path = build_outputs()
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
readback = manifest["pcbdoc_readback"]
print(f"Wrote {pcbdoc_path}")
print(f"Wrote {stackup_path}")
print(f"Wrote {stackupx_path}")
print(f"Wrote {manifest_path}")
print(f"Semantic match: {manifest['semantic_match']}")
print(f"Mode: {readback['rigid_flex_mode']}")
print(f"Substacks: {len(readback['substacks'])}")
print(f"Board regions: {len(readback['regions'])}")
print("Branches: " + ", ".join(branch["name"] for branch in readback["branches"]))
if __name__ == "__main__":
main()