@@ -3015,7 +3015,7 @@ def extrude(
3015
3015
3016
3016
# If subtractive mode is requested, use cutBlind
3017
3017
if combine in ("cut" , "s" ):
3018
- return self .cutBlind (until , clean , taper )
3018
+ return self .cutBlind (until , clean , both , taper )
3019
3019
3020
3020
# Handle `until` multiple values
3021
3021
elif until in ("next" , "last" ) and combine in (True , "a" ):
@@ -3143,7 +3143,7 @@ def sweep(
3143
3143
from warnings import warn
3144
3144
3145
3145
warn (
3146
- "sweepAlongWires keyword argument is is deprecated and will "
3146
+ "sweepAlongWires keyword argument is deprecated and will "
3147
3147
"be removed in the next version; use multisection instead" ,
3148
3148
DeprecationWarning ,
3149
3149
)
@@ -3426,6 +3426,7 @@ def cutBlind(
3426
3426
self : T ,
3427
3427
until : Union [float , Literal ["next" , "last" ], Face ],
3428
3428
clean : bool = True ,
3429
+ both : bool = False ,
3429
3430
taper : Optional [float ] = None ,
3430
3431
) -> T :
3431
3432
"""
@@ -3442,6 +3443,7 @@ def cutBlind(
3442
3443
normal. "last" cuts to the last face. If an object of type Face is passed, then the cut
3443
3444
will extend until this face.
3444
3445
:param clean: call :meth:`clean` afterwards to have a clean shape
3446
+ :param both: cut in both directions symmetrically
3445
3447
:param taper: angle for optional tapered extrusion
3446
3448
:raises ValueError: if there is no solid to subtract from in the chain
3447
3449
:return: a CQ object with the resulting object selected
@@ -3450,19 +3452,43 @@ def cutBlind(
3450
3452
"""
3451
3453
# Handling of `until` passed values
3452
3454
s : Union [Compound , Solid , Shape ]
3455
+ if isinstance (both , float ) and taper == None :
3456
+ # Because inserting a new paramater "both" in front of "taper",
3457
+ # existing code calling this function with position arguments will
3458
+ # pass the taper argument (float) to the "both" argument. This
3459
+ # warning is to catch that.
3460
+ from warnings import warn
3461
+
3462
+ warn (
3463
+ "cutBlind added a new keyword argument `both=True`. "
3464
+ "The signature is changed from "
3465
+ "(until, clean, taper) -> (until, clean, both, taper)" ,
3466
+ DeprecationWarning ,
3467
+ )
3468
+
3469
+ # assign 3rd argument value to taper
3470
+ taper = both
3471
+ both = False
3472
+
3453
3473
if isinstance (until , str ) and until in ("next" , "last" ):
3454
3474
if until == "next" :
3455
3475
faceIndex = 0
3456
3476
elif until == "last" :
3457
3477
faceIndex = - 1
3458
3478
3459
- s = self ._extrude (None , taper = taper , upToFace = faceIndex , additive = False )
3479
+ s = self ._extrude (
3480
+ None , both = both , taper = taper , upToFace = faceIndex , additive = False
3481
+ )
3460
3482
3461
3483
elif isinstance (until , Face ):
3462
- s = self ._extrude (None , taper = taper , upToFace = until , additive = False )
3484
+ s = self ._extrude (
3485
+ None , both = both , taper = taper , upToFace = until , additive = False
3486
+ )
3463
3487
3464
3488
elif isinstance (until , (int , float )):
3465
- toCut = self ._extrude (until , taper = taper , upToFace = None , additive = False )
3489
+ toCut = self ._extrude (
3490
+ until , both = both , taper = taper , upToFace = None , additive = False
3491
+ )
3466
3492
solidRef = self .findSolid ()
3467
3493
s = solidRef .cut (toCut )
3468
3494
else :
@@ -3610,8 +3636,6 @@ def getFacesList(face, eDir, direction, both=False):
3610
3636
direction = "AlongAxis" if additive else "Opposite"
3611
3637
taper = 0.0 if taper is None else taper
3612
3638
3613
- toFuse = []
3614
-
3615
3639
if upToFace is not None :
3616
3640
res = self .findSolid ()
3617
3641
for face in faces :
@@ -3644,17 +3668,20 @@ def getFacesList(face, eDir, direction, both=False):
3644
3668
upToFace = limitFace2 ,
3645
3669
additive = additive ,
3646
3670
)
3647
-
3648
3671
else :
3672
+ toFuse = []
3649
3673
for face in faces :
3650
- res = Solid .extrudeLinear (face , eDir , taper = taper )
3651
- toFuse .append (res )
3674
+ s1 = Solid .extrudeLinear (face , eDir , taper = taper )
3652
3675
3653
3676
if both :
3654
- res = Solid .extrudeLinear (face , eDir .multiply (- 1.0 ), taper = taper )
3655
- toFuse .append (res )
3677
+ s2 = Solid .extrudeLinear (face , eDir .multiply (- 1.0 ), taper = taper )
3678
+ toFuse .append (s1 .fuse (s2 , glue = True ))
3679
+ else :
3680
+ toFuse .append (s1 )
3681
+
3682
+ res = Compound .makeCompound (toFuse )
3656
3683
3657
- return res if upToFace is not None else Compound . makeCompound ( toFuse )
3684
+ return res
3658
3685
3659
3686
def _revolve (
3660
3687
self , angleDegrees : float , axisStart : VectorLike , axisEnd : VectorLike
0 commit comments