(Part 2/3) Project 3D part to plane#2002
Open
antonysigma wants to merge 1 commit intoCadQuery:masterfrom
Open
Conversation
antonysigma
commented
Feb 22, 2026
Comment on lines
+56
to
+58
| # Expected DXF output to be identical to SVG output | ||
| exportSVG3rdAngleProjection(drilled, "") | ||
| exportDXF3rdAngleProjection(drilled, "") |
Author
There was a problem hiding this comment.
Help wanted to move this example code to examples/ folder.
antonysigma
commented
Feb 22, 2026
Comment on lines
15
to
19
| cq.exporters.exportDXF( | ||
| visible_edges, | ||
| f"{prefix}{name}.dxf", | ||
| doc_units=6, | ||
| ) |
antonysigma
commented
Feb 22, 2026
Comment on lines
14
to
55
| hlr = HLRBRep_Algo() | ||
| hlr.Add(shape.val().wrapped) | ||
|
|
||
| coordinate_system = gp_Ax2(gp_Pnt(), gp_Dir(*projectionDir)) | ||
|
|
||
| projector = HLRAlgo_Projector(coordinate_system) | ||
|
|
||
| hlr.Projector(projector) | ||
| hlr.Update() | ||
| hlr.Hide() | ||
|
|
||
| hlr_shapes = HLRBRep_HLRToShape(hlr) | ||
|
|
||
| visible = [] | ||
|
|
||
| visible_sharp_edges = hlr_shapes.VCompound() | ||
| if not visible_sharp_edges.IsNull(): | ||
| visible.append(visible_sharp_edges) | ||
|
|
||
| visible_smooth_edges = hlr_shapes.Rg1LineVCompound() | ||
| if not visible_smooth_edges.IsNull(): | ||
| visible.append(visible_smooth_edges) | ||
|
|
||
| visible_contour_edges = hlr_shapes.OutLineVCompound() | ||
| if not visible_contour_edges.IsNull(): | ||
| visible.append(visible_contour_edges) | ||
|
|
||
| hidden = [] | ||
|
|
||
| hidden_sharp_edges = hlr_shapes.HCompound() | ||
| if not hidden_sharp_edges.IsNull(): | ||
| hidden.append(hidden_sharp_edges) | ||
|
|
||
| hidden_contour_edges = hlr_shapes.OutLineHCompound() | ||
| if not hidden_contour_edges.IsNull(): | ||
| hidden.append(hidden_contour_edges) | ||
|
|
||
| # Fix the underlying geometry - otherwise we will get segfaults | ||
| for el in visible: | ||
| BRepLib.BuildCurves3d_s(el, TOLERANCE) | ||
| for el in hidden: | ||
| BRepLib.BuildCurves3d_s(el, TOLERANCE) |
Author
There was a problem hiding this comment.
Help wanted to reduce duplicated code.. This part is 90% similar to the code in exporters/svg.py, so it would be better if we can consolidate it.
Also, should I create a new file occ_impl/projection.py? Or, should I move it to occ_impl/geom.py?
Simulate the API from Build123d `project_to_viewpoint`: Given a 3D vector representing the camera position pointing at the origin `(0,0,0)`, render all visible edges/arcs/splines representing the outline of the 3D part projected to the camera. Also render all hidden edges/arcs/splines. Provide and example script `tests/test_projection.py` where a generic part (A bracket with rounded corners and a countersunk hole) is projected to top view, side view, front view, and orthogonal view, and then exported to DXF 2D drawings. Reference: https://build123d.readthedocs.io/en/latest/tech_drawing_tutorial.html
d35904d to
97a6903
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Simulate the API from Build123d
project_to_viewpoint: Given a 3D vector representing the camera position pointing at the origin(0,0,0), render all visible edges/arcs/splines representing the outline of the 3D part projected to the camera.Also render all hidden edges/arcs/splines.
Provide and example script
tests/test_projection.pywhere a generic part (A bracket with rounded corners and a countersunk hole) is projected to top view, side view, front view, and orthogonal view, and then exported to DXF 2D drawings.Reference: https://build123d.readthedocs.io/en/latest/tech_drawing_tutorial.html
Expected output from
tests/test_projection.py:Follow-up of MR #2001 .
Related to: #122, #1767