(Part 2/3) Project 3D part to plane#2002
Conversation
97a6903 to
d975b18
Compare
|
OK, let's get this going. @antonysigma could you run our version of black in the codebase? |
d975b18 to
8de8187
Compare
Done running |
|
Still failing on black, did you use our version of the tool? |
8de8187 to
c646aee
Compare
My apologies. I mixed up |
|
OK, next step to make the CI green is to fix mypy errors. Are you up to it @antonysigma ? |
I can help resolve new |
|
There are no mypy issues on HEAD according to our CI. So I assume that everything is on your side. No need to do anything with appveyor,, you can run mypy locally and simply fix all the errors. If this sounds too complicated, we can probably help. |
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
c646aee to
4552668
Compare
antonysigma
left a comment
There was a problem hiding this comment.
Hi @adam-urbanczyk ,
Yes, I need help resolving mypy errors, especially those exists before this PR.
Please refer to the inline comments for the out-of-scope errors.
-Antony
…/cadquery into antonysigma-project-to-viewpoint
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2002 +/- ##
=======================================
Coverage 95.70% 95.70%
=======================================
Files 30 30
Lines 9447 9479 +32
Branches 1406 1410 +4
=======================================
+ Hits 9041 9072 +31
- Misses 252 253 +1
Partials 154 154 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…/cadquery into antonysigma-project-to-viewpoint
|
Thank you for doing the dirty laundry for me. It is certainly a daunting process for me to understand the legacy DXF code in the repo, not to mention patching it. I appreciate the effort. |
…ct-to-viewpoint # Conflicts: # tests/test_free_functions.py
|
@antonysigma This results in the same result as your DXF screenshot from the description above: exporters.exportDXFProjection(drilled, "ortho.dxf", (1, 1, 1))Now you also have the option to specify "up" direction. exporters.exportDXFProjection(drilled, "ortho_zup.dxf", (1, 1, 1), up=(0, 0, 1))
|
|
Example generating a PNG screenshot with cadquery.vis: from cadquery import Workplane
from cadquery.func import hlr
from cadquery.vis import show, style
# Based on examples/Ex102_DXF_with_HLR.py.
width = 10
depth = 10
height = 10
hole_dia = 3.0
baseplate = Workplane("XY").box(width, depth, height).edges("|Z").fillet(2.0)
drilled = baseplate.faces(">Z").workplane().cskHole(hole_dia, hole_dia * 2, 82.0)
# Create an isometric orthographic projection with world +Z pointing upward.
hlr_result = hlr(drilled.val(), (1, -1, 1), up=(0, 0, 1))
show(
style(hlr_result.visible, edgecolor="black", markersize=0),
style(hlr_result.hidden, edgecolor="gray", linewidth=1, markersize=0,),
interact=False,
screenshot="img.png",
width=800,
height=800,
roll=0,
elevation=0,
trihedron=False,
gradient=False,
bgcolor=(1, 1, 1), # (this is also default color)
) |
|
@lorenzncode Thanks for refactoring the projection APIs. I haven't run the new example code on my computer yet, but I looks good to me at first glance. Feel free to merge it. There is also Part 3/3 of the 2D projection feature: orthogonal projections and titlecard generation for 2D CAD drawings. I will rebase my branch to this PR later to make use of the modified APIs, before submitting the part 3 PR for code review. |
|
@lorenzncode LGTM, shall we merge? |
|
Yes, ready to merge. |
|
@lorenzncode @jmwright @adam-urbanczyk I just submitted the draft PR, showcasing the final integration to the technical drawing feature. That should represent almost all of my use-cases for the API Question: how do I configure Github PR webpage to "rebase" to this PR? Or, make this PR the dependency? |
|
Not sure what you mean. Just merge master to your branch and it should be fine. |

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