On This Page (4)
Examples Showcase / pcbdoc_create_rigid_flex_split_lines
Create a Rigid-Flex 1.0 split-line PcbDoc
Recreate a fixture-derived Rigid-Flex 1.0 PcbDoc with split-line board regions, write PcbDoc/.stackup/.stackupx outputs, and verify region/bend topology after PcbDoc readback.
Create a fixture-backed Rigid-Flex 1.0 PcbDoc that uses split-line board regions.
This sample writes a recreated AD-style Rigid-Flex 1.0 PcbDoc with one rigid substack, one flex substack, two flex board regions, one rigid board region, split-line evidence, coverlay polygons, and bend lines. 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 the older Rigid-Flex 1.0 flow - Assigning split-line board regions to rigid and flex substacks
- Writing native stack data through
PcbDocBuilder.set_layer_stack_document(...) - Replaying coverlay polygon and region evidence into a generated PcbDoc
- Re-reading the generated PcbDoc through
AltiumPcbDoc - Verifying regions, bends, split-line topology, native geometry, and exact stackup exports
Run
From the repository root:
uv run python examples\pcbdoc_create_rigid_flex_split_lines\pcbdoc_create_rigid_flex_split_lines.pyOutput
examples/pcbdoc_create_rigid_flex_split_lines/output/pcbdoc_create_rigid_flex_split_lines.PcbDoc
examples/pcbdoc_create_rigid_flex_split_lines/output/pcbdoc_create_rigid_flex_split_lines.stackup
examples/pcbdoc_create_rigid_flex_split_lines/output/pcbdoc_create_rigid_flex_split_lines.stackupx
examples/pcbdoc_create_rigid_flex_split_lines/output/rigid_flex_split_lines_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_split_lines"
OUTPUT_DIR = SAMPLE_DIR / "output"
OUTPUT_PCBDOC = OUTPUT_DIR / "pcbdoc_create_rigid_flex_split_lines.PcbDoc"
OUTPUT_STACKUP = OUTPUT_DIR / "pcbdoc_create_rigid_flex_split_lines.stackup"
OUTPUT_STACKUPX = OUTPUT_DIR / "pcbdoc_create_rigid_flex_split_lines.stackupx"
OUTPUT_MANIFEST = OUTPUT_DIR / "rigid_flex_split_lines_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(f"Branches: {len(readback['branches'])}")
print(
"Bend radii: "
+ ", ".join(
str(radius)
for region in readback["regions"]
for radius in region["bend_radii_mils"]
)
)
if __name__ == "__main__":
main()