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

Method _findType

cadquery/cq.py:695–719  ·  view source on GitHub ↗
(self, types, searchStack=True, searchParents=True)

Source from the content-addressed store, hash-verified

693 return rv
694
695 def _findType(self, types, searchStack=True, searchParents=True):
696
697 if searchStack:
698 rv = []
699 for obj in self.objects:
700 if isinstance(obj, types):
701 rv.append(obj)
702 # unpack compounds in a special way when looking for Solids
703 elif isinstance(obj, Compound) and types == (Solid,):
704 for T in types:
705 # _entities(...) needed due to weird behavior with shelled object unpacking
706 rv.extend(T(el) for el in obj._entities(T.__name__))
707 # otherwise unpack compounds normally
708 elif isinstance(obj, Compound):
709 rv.extend(el for el in obj if isinstance(el, type))
710
711 if rv and types == (Solid,):
712 return Compound.makeCompound(rv)
713 elif rv:
714 return rv[0]
715
716 if searchParents and self.parent is not None:
717 return self.parent._findType(types, searchStack=True, searchParents=True)
718
719 return None
720
721 def findSolid(
722 self, searchStack: bool = True, searchParents: bool = True

Callers 4

findSolidMethod · 0.95
_fuseWithBaseMethod · 0.95
_cutFromBaseMethod · 0.95
unionMethod · 0.95

Calls 5

TFunction · 0.85
appendMethod · 0.80
extendMethod · 0.80
_entitiesMethod · 0.80
makeCompoundMethod · 0.80

Tested by

no test coverage detected