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

Function imprint

cadquery/occ_impl/assembly.py:858–889  ·  view source on GitHub ↗

Imprint all the solids and construct a dictionary mapping imprinted solids to names from the input assy.

(assy: AssemblyProtocol)

Source from the content-addressed store, hash-verified

856
857
858def imprint(assy: AssemblyProtocol) -> Tuple[Shape, Dict[Shape, Tuple[str, ...]]]:
859 """
860 Imprint all the solids and construct a dictionary mapping imprinted solids to names from the input assy.
861 """
862
863 # make the id map
864 id_map = {}
865
866 for obj, name, loc, _ in assy:
867 for s in obj.moved(loc).Solids():
868 id_map[s] = name
869
870 # connect topologically
871 bldr = BOPAlgo_MakeConnected()
872 bldr.SetRunParallel(True)
873 bldr.SetUseOBB(True)
874
875 for obj in id_map:
876 bldr.AddArgument(obj.wrapped)
877
878 bldr.Perform()
879 res = Shape(bldr.Shape())
880
881 # make the connected solid -> id map
882 origins: Dict[Shape, Tuple[str, ...]] = {}
883
884 for s in res.Solids():
885 ids = tuple(id_map[Solid(el)] for el in bldr.GetOrigins(s.wrapped))
886 # if GetOrigins yields nothing, solid was not modified
887 origins[s] = ids if ids else (id_map[s],)
888
889 return res, origins

Callers

nothing calls this directly

Calls 4

SolidsMethod · 0.95
ShapeClass · 0.85
SolidClass · 0.85
movedMethod · 0.45

Tested by

no test coverage detected