diff --git a/src/occwl/compound.py b/src/occwl/compound.py index 844c6f7..cffc902 100644 --- a/src/occwl/compound.py +++ b/src/occwl/compound.py @@ -1,5 +1,7 @@ from OCC.Core.TopoDS import TopoDS_Compound -from OCC.Extend.DataExchange import read_step_file, list_of_shapes_to_compound +from OCC.Extend.DataExchange import read_step_file +from OCC.Core.BRep import BRep_Builder + from OCC.Core.BRepTools import BRepTools_ShapeSet from OCC.Core.STEPControl import STEPControl_Reader from OCC.Core.TopAbs import ( @@ -19,6 +21,17 @@ from occwl.base import BottomUpFaceIterator, BottomUpEdgeIterator, BoundingBoxMi ShellContainerMixin from occwl.shape import Shape +def list_of_shapes_to_compound(shapes): + """ + Combine a list of TopoDS_Shapes into a single TopoDS_Compound. + Returns (compound, True) if successful. + """ + builder = BRep_Builder() + compound = TopoDS_Compound() + builder.MakeCompound(compound) + for s in shapes: + builder.Add(compound, s) + return compound, True class Compound(Shape, BottomUpFaceIterator, BoundingBoxMixin, BottomUpEdgeIterator, EdgeContainerMixin, FaceContainerMixin, SolidContainerMixin, ShellContainerMixin, SurfacePropertiesMixin,