pc2cad_profile.extract_profile_sketches helper bypassed by the default step export path #35

Closed
opened 2026-06-20 20:07:25 +00:00 by Mark · 0 comments
Owner

pc2cad_profile.py::extract_profile_sketches not invoked from the CLI workflow for organic / real-scan inputs

What

pc2cad_profile.py is the build123d helper that turns detected
profile features (profile_extrude / profile_revolve primitives)
into build123d.Sketch records, with arc-vs-line decomposition,
sagitta-based consistency checks, and axisymmetry heuristics
(see _polygon_to_edges, _arc_is_consistent, _is_axisymmetric,
_build_sketch_from_edges, and extract_profile_sketches).

The CLI (pc2cad_cli.py::_export_build123d, line 445) invokes
this helper when --out-format build123d is selected, but only
for the build123d export path. For the default step export
and for the analytic / freeform hybrid path on real scans, the
helper is bypassed. The freeform Poisson mesh and the analytic
primitives are exported without ever running the build123d
profile extraction.

The user-facing impact: even on samples that have profile
features (a planar polygon with a depth, a revolve profile),
the export never goes through the build123d helper that knows
how to build a clean Sketch from the polygon's edge list.
The default step export path is the one that needs the
helper the most (it's the path that should produce real CAD),
but it's the one that skips it.

The user noted on 2026-06-20: "at some point you stopped using
the helper and that is tedious." The helper exists, is fully
implemented, and is being skipped.

Reproduction

cd ~/Projects/pc2cad
# Default step export bypasses the helper
./.venv/bin/python pc2cad_cli.py samples/sample_plane_cyl.ply \
  --out /tmp/test.step --out-format step
# build123d export uses the helper
./.venv/bin/python pc2cad_cli.py samples/sample_plane_cyl.ply \
  --out /tmp/test_b123d.step --out-format build123d
diff /tmp/test.step /tmp/test_b123d.step
# (or: see the report sections — build123d path includes
#  profile_sketches[], step path doesn't)

Expected

The build123d helper should be the primary export path for
profile_extrude / profile_revolve primitives, regardless of the
output format. The step and brep exporters should consume
ProfileSketch records (or equivalent) rather than raw
Primitive lists.

Actual

The helper is wired only into the build123d export format. The
default step path goes through the FreeCAD / OCP path that
currently produces placeholders (see pc2cad#23). The build123d
path works for profile_extrude primitives but is bypassed
entirely for organic / freeform samples.

Suggested fix (not for me to implement)

  • Re-wire export_step (and the other analytic export paths)
    to call extract_profile_sketches first and use the resulting
    ProfileSketch records as the primary input.
  • For samples that have no profile_extrude / profile_revolve
    primitives (the freeform-only case), fall back to the
    Poisson-mesh path (or the analytic fallback, once the strategy
    bugs above are addressed).
  • pc2cad#22 (build123d export path, the helper's intended use)
  • pc2cad#23 (FreeCAD → OCP port; once the port is done, the
    build123d helper can be the primary path)
  • The "stopped using the helper" observation from 2026-06-20
# `pc2cad_profile.py::extract_profile_sketches` not invoked from the CLI workflow for organic / real-scan inputs ## What `pc2cad_profile.py` is the build123d helper that turns detected profile features (profile_extrude / profile_revolve primitives) into `build123d.Sketch` records, with arc-vs-line decomposition, sagitta-based consistency checks, and axisymmetry heuristics (see `_polygon_to_edges`, `_arc_is_consistent`, `_is_axisymmetric`, `_build_sketch_from_edges`, and `extract_profile_sketches`). The CLI (`pc2cad_cli.py::_export_build123d`, line 445) invokes this helper when `--out-format build123d` is selected, but only for the `build123d` export path. For the default `step` export and for the analytic / freeform hybrid path on real scans, the helper is bypassed. The freeform Poisson mesh and the analytic primitives are exported without ever running the build123d profile extraction. The user-facing impact: even on samples that *have* profile features (a planar polygon with a depth, a revolve profile), the export never goes through the build123d helper that knows how to build a clean `Sketch` from the polygon's edge list. The default `step` export path is the one that needs the helper the most (it's the path that should produce real CAD), but it's the one that skips it. The user noted on 2026-06-20: "at some point you stopped using the helper and that is tedious." The helper exists, is fully implemented, and is being skipped. ## Reproduction ```bash cd ~/Projects/pc2cad # Default step export bypasses the helper ./.venv/bin/python pc2cad_cli.py samples/sample_plane_cyl.ply \ --out /tmp/test.step --out-format step # build123d export uses the helper ./.venv/bin/python pc2cad_cli.py samples/sample_plane_cyl.ply \ --out /tmp/test_b123d.step --out-format build123d diff /tmp/test.step /tmp/test_b123d.step # (or: see the report sections — build123d path includes # profile_sketches[], step path doesn't) ``` ## Expected The build123d helper should be the *primary* export path for profile_extrude / profile_revolve primitives, regardless of the output format. The `step` and `brep` exporters should consume `ProfileSketch` records (or equivalent) rather than raw `Primitive` lists. ## Actual The helper is wired only into the `build123d` export format. The default `step` path goes through the FreeCAD / OCP path that currently produces placeholders (see pc2cad#23). The build123d path works for `profile_extrude` primitives but is bypassed entirely for organic / freeform samples. ## Suggested fix (not for me to implement) - Re-wire `export_step` (and the other analytic export paths) to call `extract_profile_sketches` first and use the resulting `ProfileSketch` records as the primary input. - For samples that have no `profile_extrude` / `profile_revolve` primitives (the freeform-only case), fall back to the Poisson-mesh path (or the analytic fallback, once the strategy bugs above are addressed). ## Related - pc2cad#22 (build123d export path, the helper's intended use) - pc2cad#23 (FreeCAD → OCP port; once the port is done, the build123d helper can be the primary path) - The "stopped using the helper" observation from 2026-06-20
Mark 2026-06-21 19:08:12 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Mark/pc2cad#35
No description provided.