Combines the provided object with the base solid, if one can be found. :param obj: The object to be combined with the context solid :param mode: The mode to combine with the base solid (True, False, "cut", "a" or "s") :return: a new object that represents the result
(
self: T,
obj: Union[Shape, Iterable[Shape]],
mode: CombineMode = True,
clean: bool = False,
)
| 3208 | return self._combineWithBase(r, combine, clean) |
| 3209 | |
| 3210 | def _combineWithBase( |
| 3211 | self: T, |
| 3212 | obj: Union[Shape, Iterable[Shape]], |
| 3213 | mode: CombineMode = True, |
| 3214 | clean: bool = False, |
| 3215 | ) -> T: |
| 3216 | """ |
| 3217 | Combines the provided object with the base solid, if one can be found. |
| 3218 | |
| 3219 | :param obj: The object to be combined with the context solid |
| 3220 | :param mode: The mode to combine with the base solid (True, False, "cut", "a" or "s") |
| 3221 | :return: a new object that represents the result of combining the base object with obj, |
| 3222 | or obj if one could not be found |
| 3223 | """ |
| 3224 | |
| 3225 | if mode: |
| 3226 | # since we are going to do something convert the iterable if needed |
| 3227 | if not isinstance(obj, Shape): |
| 3228 | obj = Compound.makeCompound(obj) |
| 3229 | |
| 3230 | # dispatch on the mode |
| 3231 | if mode in ("cut", "s"): |
| 3232 | newS = self._cutFromBase(obj) |
| 3233 | elif mode in (True, "a"): |
| 3234 | newS = self._fuseWithBase(obj) |
| 3235 | |
| 3236 | else: |
| 3237 | # do not combine branch |
| 3238 | newS = self.newObject(obj if not isinstance(obj, Shape) else [obj]) |
| 3239 | |
| 3240 | if clean: |
| 3241 | # NB: not calling self.clean() to not pollute the parents |
| 3242 | newS.objects = [ |
| 3243 | obj.clean() if isinstance(obj, Shape) else obj for obj in newS.objects |
| 3244 | ] |
| 3245 | |
| 3246 | return newS |
| 3247 | |
| 3248 | def _fuseWithBase(self: T, obj: Shape) -> T: |
| 3249 | """ |