Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sketch and Workplane improvements #1633

Merged
merged 50 commits into from
Aug 21, 2024
Merged

Sketch and Workplane improvements #1633

merged 50 commits into from
Aug 21, 2024

Conversation

adam-urbanczyk
Copy link
Member

@adam-urbanczyk adam-urbanczyk commented Jul 19, 2024

This should resolve #1614, #1575, #1511, #1519, #1603, #1615 and add special methods to Sketch.

  • val, vals
  • filter, map, apply, invoke
  • DXF export
  • face() accepts Shape
  • bool ops as operators
  • deprecate previous naming convention
  • uniform bool op naming for Shape, Sketch and Workplane
  • add(), subtract() and replace() methods for Sketch
  • extend Workplane._getFaces() to work with selected faces
  • allow 0 spacing in Workplane.rarray
  • add __iter__ to Workplane
  • add export to:
    • Workplane
    • Shape
    • Assembly
    • Sketch
  • extend Sketch.moved
  • make Sketch._selection optional, i.e. no selection and nothing selected are two different states now
  • tests
  • docs

Some notes:

  • Should we add another state to cq.Sketch e.g. selection: Optional[List[SketchVal]]. This way it would be possible to differentiate between selection was not performed/reset and nothing was selected. -> After some experimentation I did go for this change.
  • I removed wires, it seems that they were not needed.

Quite some scope-creep but a lot of quality-of-life improvements.

@adam-urbanczyk adam-urbanczyk marked this pull request as draft July 19, 2024 18:08
Copy link

codecov bot commented Jul 19, 2024

Codecov Report

Attention: Patch coverage is 99.60784% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.21%. Comparing base (8ea37a7) to head (b2f780f).
Report is 9 commits behind head on master.

Files with missing lines Patch % Lines
cadquery/occ_impl/exporters/__init__.py 90.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1633      +/-   ##
==========================================
+ Coverage   94.96%   95.21%   +0.24%     
==========================================
  Files          28       27       -1     
  Lines        6322     6560     +238     
  Branches     1292     1402     +110     
==========================================
+ Hits         6004     6246     +242     
- Misses        192      193       +1     
+ Partials      126      121       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@adam-urbanczyk adam-urbanczyk changed the title Sketch improvements Sketch improvements and some related Workplane improvements Jul 20, 2024
@adam-urbanczyk adam-urbanczyk changed the title Sketch improvements and some related Workplane improvements Sketch and Workplane improvements Jul 20, 2024
@adam-urbanczyk adam-urbanczyk marked this pull request as ready for review July 28, 2024 13:01
@adam-urbanczyk
Copy link
Member Author

adam-urbanczyk commented Jul 28, 2024

Quite some goodies, e.g.

import cadquery as cq

s1 = cq.Sketch().rect(1,1).vertices().fillet(0.2).reset()
s2 = cq.Sketch().rect(0.5,0.5).vertices().fillet(0.1).reset()

s3 = s1 - s2 # sketch bool ops

w = (
     cq.Workplane()
     .placeSketch(s1, s2.moved(z=1)) # better Sketch moved
     .loft()
     .faces('>Z')
     .extrude(1) # direct extruding of faces
     .faces('>Z').workplane()
     .eachpoint(s2.wires().offset(-0.1,mode='r').reset().val()) # val() for Sketch
     .cutThruAll()
)

w.export('out.brep') # unified export method for Workplane, Sketch and Assembly

afbeelding

Copy link
Member

@jmwright jmwright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the work on this @adam-urbanczyk !

Co-authored-by: Jeremy Wright <[email protected]>
Copy link
Member

@lorenzncode lorenzncode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested the new features (at least most of them). It looks great with nice usability improvements too. I found a few doc issues/typos.

cadquery/cq.py Outdated Show resolved Hide resolved
cadquery/cq.py Show resolved Hide resolved
cadquery/sketch.py Show resolved Hide resolved
cadquery/sketch.py Show resolved Hide resolved
cadquery/sketch.py Show resolved Hide resolved
cadquery/sketch.py Outdated Show resolved Hide resolved
cadquery/sketch.py Outdated Show resolved Hide resolved
cadquery/sketch.py Outdated Show resolved Hide resolved
cadquery/assembly.py Show resolved Hide resolved
tests/test_cadquery.py Show resolved Hide resolved
@adam-urbanczyk
Copy link
Member Author

@lorenzncode I think I solved all the issues, could you take another look?

@lorenzncode
Copy link
Member

Thanks @adam-urbanczyk !

@adam-urbanczyk adam-urbanczyk merged commit 6d7d1d6 into master Aug 21, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants