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

Method testUnions

tests/test_cadquery.py:2810–2841  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2808 self.saveModel(s)
2809
2810 def testUnions(self):
2811 # duplicates a memory problem of some kind reported when combining lots of objects
2812 s = Workplane("XY").rect(0.5, 0.5).extrude(5.0)
2813 o = []
2814 beginTime = time.time()
2815 for i in range(15):
2816 t = Workplane("XY").center(10.0 * i, 0).rect(0.5, 0.5).extrude(5.0)
2817 o.append(t)
2818
2819 # union stuff
2820 for oo in o:
2821 s = s.union(oo)
2822 print("Total time %0.3f" % (time.time() - beginTime))
2823
2824 # Test unioning a Solid object
2825 s = Workplane(Plane.XY())
2826 currentS = s.rect(2.0, 2.0).extrude(0.5)
2827 toUnion = s.rect(1.0, 1.0).extrude(1.0)
2828
2829 resS = currentS.union(toUnion)
2830
2831 self.assertEqual(11, resS.faces().size())
2832
2833 with self.assertRaises(ValueError):
2834 resS.union(toUnion.faces().val())
2835
2836 # Test syntactic sugar [__add__ method]
2837 sugar1 = currentS | toUnion
2838 sugar2 = currentS + toUnion
2839
2840 self.assertEqual(resS.faces().size(), sugar1.faces().size())
2841 self.assertEqual(resS.faces().size(), sugar2.faces().size())
2842
2843 def testCombine(self):
2844 s = Workplane(Plane.XY())

Callers

nothing calls this directly

Calls 10

rectMethod · 0.95
unionMethod · 0.95
WorkplaneClass · 0.85
extrudeMethod · 0.80
centerMethod · 0.80
appendMethod · 0.80
XYMethod · 0.80
sizeMethod · 0.45
facesMethod · 0.45
valMethod · 0.45

Tested by

no test coverage detected