Unions all of the items on the stack of toUnion with the current solid. If there is no current solid, the items in toUnion are unioned together. :param toUnion: a solid object, or a Workplane object having a solid :param clean: call :meth:`clean` afterwards to have
(
self: T,
toUnion: Optional[Union["Workplane", Solid, Compound]] = None,
clean: bool = True,
glue: bool = False,
tol: Optional[float] = None,
)
| 3304 | return self.newObject([s]) |
| 3305 | |
| 3306 | def union( |
| 3307 | self: T, |
| 3308 | toUnion: Optional[Union["Workplane", Solid, Compound]] = None, |
| 3309 | clean: bool = True, |
| 3310 | glue: bool = False, |
| 3311 | tol: Optional[float] = None, |
| 3312 | ) -> T: |
| 3313 | """ |
| 3314 | Unions all of the items on the stack of toUnion with the current solid. |
| 3315 | If there is no current solid, the items in toUnion are unioned together. |
| 3316 | |
| 3317 | :param toUnion: a solid object, or a Workplane object having a solid |
| 3318 | :param clean: call :meth:`clean` afterwards to have a clean shape (default True) |
| 3319 | :param glue: use a faster gluing mode for non-overlapping shapes (default False) |
| 3320 | :param tol: tolerance value for fuzzy bool operation mode (default None) |
| 3321 | :raises: ValueError if there is no solid to add to in the chain |
| 3322 | :return: a Workplane object with the resulting object selected |
| 3323 | """ |
| 3324 | |
| 3325 | # first collect all of the items together |
| 3326 | newS: List[Shape] |
| 3327 | if isinstance(toUnion, Workplane): |
| 3328 | newS = cast(List[Shape], toUnion.solids().vals()) |
| 3329 | if len(newS) < 1: |
| 3330 | raise ValueError( |
| 3331 | "Workplane object must have at least one solid on the stack to union!" |
| 3332 | ) |
| 3333 | self._mergeTags(toUnion) |
| 3334 | elif isinstance(toUnion, (Solid, Compound)): |
| 3335 | newS = [toUnion] |
| 3336 | elif toUnion is None: |
| 3337 | newS = [] |
| 3338 | else: |
| 3339 | raise ValueError("Cannot union type '{}'".format(type(toUnion))) |
| 3340 | |
| 3341 | # now combine with existing solid, if there is one |
| 3342 | # look for parents to cut from |
| 3343 | solidRef = self._findType((Solid,), searchStack=True, searchParents=True) |
| 3344 | if solidRef is not None: |
| 3345 | r = solidRef.fuse(*newS, glue=glue, tol=tol) |
| 3346 | elif len(newS) > 1: |
| 3347 | r = newS.pop(0).fuse(*newS, glue=glue, tol=tol) |
| 3348 | else: |
| 3349 | r = newS[0] |
| 3350 | |
| 3351 | if clean: |
| 3352 | r = r.clean() |
| 3353 | |
| 3354 | return self.newObject([r]) |
| 3355 | |
| 3356 | @deprecate() |
| 3357 | def __or__(self: T, other: Union["Workplane", Solid, Compound]) -> T: |