MCPcopy
hub / github.com/CadQuery/cadquery / _combineWithBase

Method _combineWithBase

cadquery/cq.py:3210–3246  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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 """

Callers 9

eachMethod · 0.95
eachpointMethod · 0.95
twistExtrudeMethod · 0.95
extrudeMethod · 0.95
revolveMethod · 0.95
sweepMethod · 0.95
loftMethod · 0.95
textMethod · 0.95
test_combineWithBaseMethod · 0.80

Calls 5

_cutFromBaseMethod · 0.95
_fuseWithBaseMethod · 0.95
newObjectMethod · 0.95
makeCompoundMethod · 0.80
cleanMethod · 0.45

Tested by 1

test_combineWithBaseMethod · 0.64