CadQuery / cadquery

A python parametric CAD scripting framework based on OCCT
https://cadquery.readthedocs.io
Other
2.93k stars 276 forks source link

Add shape and workplane support to the Workplane.eachpoint() function. Issue #1395 #1578

Closed dov closed 1 month ago

dov commented 2 months ago

This PR solves issue #1395 and adds the ability to use the Workplane.eachpoint() function with a Shape and a Workplane.

Here are is an example for using a wire to do a cutThru():

wire = Wire.makeCircle(1, (0, 0, 0), (0, 0, 1))
result = (
    Workplane("XY")
    .box(10, 10, 1)
    .faces(">Z")
    .rect(7, 7, forConstruction=True)
    .vertices()
    .eachpoint(wire)
    .cutThruAll()
)

And here is an example for using another workplane, adding a sphere to the center of each face:

box = Workplane().box(2, 2, 2)
sph = Workplane().sphere(1.0)
# Place the sphere in the center of each box face
r = box.faces().eachpoint(sph, combine=True)
adam-urbanczyk commented 1 month ago

@dov could you run black?

DovXjet commented 1 month ago

@adam-urbanczyk Ok. I just did. It isn't trivial since the rest of the files are not compliant.

(However, I just found "darken", which makes it easy).

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.86%. Comparing base (995d139) to head (8664c8e). Report is 1 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1578 +/- ## ======================================= Coverage 94.85% 94.86% ======================================= Files 28 28 Lines 6216 6226 +10 Branches 1251 1261 +10 ======================================= + Hits 5896 5906 +10 Misses 193 193 Partials 127 127 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

jmwright commented 1 month ago

@dov The following command should show just what is needed to fix your changes.

black --diff --check .
jmwright commented 1 month ago

Thanks @dov