Skip to content

Commit

Permalink
Added fix for tapered extrusions depending on version of CadQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelgale committed Aug 19, 2024
1 parent c64ace7 commit fe83218
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
- v.0.5.1 - Update to fix setup.py issues
- v.0.5.4 - Added new helper functions in cq_helpers. Added new object arrangers i cq_layout. New Makefile
- v.0.5.6 - Added basic drafted solid builders (cq_basic.py). Solids can be hollow with different combinations of wall/floor/roof thicknesses. Added inverse_fillet and inverse_chamfer helpers
- v.0.5.8 - Added automatic compensation for height of tapered extrusions depending on CadQuery version
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ r = r.inverse_fillet("<Z", 1.0)
- v.0.5.3 - Updated with new helpers and updated setup.py
- v.0.5.4 - Added new helper functions in cq_helpers. Added new object arrangers i cq_layout. New Makefile
- v.0.5.6 - Added basic drafted solid builders (cq_basic.py). Solids can be hollow with different combinations of wall/floor/roof thicknesses. Added inverse_fillet and inverse_chamfer helpers
- v.0.5.8 - Added automatic compensation for height of tapered extrusions depending on CadQuery version
## Authors
Expand Down
2 changes: 1 addition & 1 deletion cqkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# fmt: off
__project__ = 'cqkit'
__version__ = '0.5.7'
__version__ = '0.5.8'
# fmt: on

VERSION = __project__ + "-" + __version__
Expand Down
12 changes: 11 additions & 1 deletion cqkit/cq_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,24 @@

from cqkit.cq_selectors import HasCoordinateSelector, SharedVerticesWithObjectSelector

# Special test to see which version of CadQuery is installed and
# therefore if any compensation is required for extruded zlen
# CQ versions < 2.4.0 typically require zlen correction, i.e.
# scaling the vertical extrusion extent by 1/cos(taper)
ZLEN_OK = False
_r = cq.Workplane("XY").rect(2, 2).extrude(1, taper=45)
_bb = _r.vals()[0].BoundingBox()
if abs(_bb.zlen - 1.0) < 1e-3:
ZLEN_OK = True


def multi_extrude(obj, levels, face=">Z"):
"""Extrudes successive layers of a base solid from a reference face.
Each extrusion layer is specified either as a fixed dimension offset or
a tuple of offset and taper angle."""
for level in levels:
if isinstance(level, (tuple, list)):
cl = level[0] / cos(radians(level[1]))
cl = level[0] if ZLEN_OK else level[0] / cos(radians(level[1]))
obj = obj.faces(face).wires().toPending().extrude(cl, taper=level[1])
else:
obj = obj.faces(face).wires().toPending().extrude(level)
Expand Down

0 comments on commit fe83218

Please sign in to comment.