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

Method testOffset2D

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

Source from the content-addressed store, hash-verified

4804 self.assertTupleAlmostEquals(c.toTuple(), (1, 1, 0), 6)
4805
4806 def testOffset2D(self):
4807
4808 w1 = Workplane().rect(1, 1).offset2D(0.5, "arc")
4809 self.assertEqual(w1.edges().size(), 8)
4810
4811 w2 = Workplane().rect(1, 1).offset2D(0.5, "tangent")
4812 self.assertEqual(w2.edges().size(), 4)
4813
4814 w3 = Workplane().rect(1, 1).offset2D(0.5, "intersection")
4815 self.assertEqual(w3.edges().size(), 4)
4816
4817 w4 = Workplane().pushPoints([(0, 0), (0, 5)]).rect(1, 1).offset2D(-0.5)
4818 self.assertEqual(w4.wires().size(), 0)
4819
4820 w5 = Workplane().pushPoints([(0, 0), (0, 5)]).rect(1, 1).offset2D(-0.25)
4821 self.assertEqual(w5.wires().size(), 2)
4822
4823 r = 20
4824 s = 7
4825 t = 1.5
4826
4827 points = [
4828 (0, t / 2),
4829 (r / 2 - 1.5 * t, r / 2 - t),
4830 (s / 2, r / 2 - t),
4831 (s / 2, r / 2),
4832 (r / 2, r / 2),
4833 (r / 2, s / 2),
4834 (r / 2 - t, s / 2),
4835 (r / 2 - t, r / 2 - 1.5 * t),
4836 (t / 2, 0),
4837 ]
4838
4839 s = (
4840 Workplane("XY")
4841 .polyline(points)
4842 .mirrorX()
4843 .mirrorY()
4844 .offset2D(-0.9)
4845 .extrude(1)
4846 )
4847 self.assertEqual(s.solids().size(), 4)
4848
4849 # test forConstruction
4850 # forConstruction=True should place results in objects, not ctx.pendingWires
4851 w6 = Workplane().hLine(1).vLine(1).close().offset2D(0.5, forConstruction=True)
4852 self.assertEqual(len(w6.ctx.pendingWires), 0)
4853 self.assertEqual(w6.size(), 1)
4854 self.assertEqual(type(w6.val()), Wire)
4855 # make sure the resulting wire has forConstruction set
4856 self.assertEqual(w6.val().forConstruction, True)
4857
4858 def testConsolidateWires(self):
4859

Callers

nothing calls this directly

Calls 15

WorkplaneClass · 0.85
pushPointsMethod · 0.80
extrudeMethod · 0.80
mirrorYMethod · 0.80
mirrorXMethod · 0.80
polylineMethod · 0.80
vLineMethod · 0.80
hLineMethod · 0.80
offset2DMethod · 0.45
rectMethod · 0.45
sizeMethod · 0.45
edgesMethod · 0.45

Tested by

no test coverage detected