MCPcopy Index your code
hub / github.com/CadQuery/cadquery / test2DDrawing

Method test2DDrawing

tests/test_cadquery.py:1968–2035  ·  view source on GitHub ↗

Draw things like 2D lines and arcs, should be expanded later to include all 2D constructs

(self)

Source from the content-addressed store, hash-verified

1966 self.saveModel(r2)
1967
1968 def test2DDrawing(self):
1969 """
1970 Draw things like 2D lines and arcs, should be expanded later to include all 2D constructs
1971 """
1972 s = Workplane(Plane.XY())
1973 r = (
1974 s.lineTo(1.0, 0.0)
1975 .lineTo(1.0, 1.0)
1976 .threePointArc((1.0, 1.5), (0.0, 1.0))
1977 .lineTo(0.0, 0.0)
1978 .moveTo(1.0, 0.0)
1979 .lineTo(2.0, 0.0)
1980 .lineTo(2.0, 2.0)
1981 .threePointArc((2.0, 2.5), (0.0, 2.0))
1982 .lineTo(-2.0, 2.0)
1983 .lineTo(-2.0, 0.0)
1984 .close()
1985 )
1986
1987 self.assertEqual(1, r.wires().size())
1988
1989 # Test the *LineTo functions
1990 s = Workplane(Plane.XY())
1991 r = s.hLineTo(1.0).vLineTo(1.0).hLineTo(0.0).close()
1992
1993 self.assertEqual(1, r.wire().size())
1994 self.assertEqual(4, r.edges().size())
1995
1996 # Test the *Line functions
1997 s = Workplane(Plane.XY())
1998 r = s.hLine(1.0).vLine(1.0).hLine(-1.0).close()
1999
2000 self.assertEqual(1, r.wire().size())
2001 self.assertEqual(4, r.edges().size())
2002
2003 # Test the move function
2004 s = Workplane(Plane.XY())
2005 r = s.move(1.0, 1.0).hLine(1.0).vLine(1.0).hLine(-1.0).close()
2006
2007 self.assertEqual(1, r.wire().size())
2008 self.assertEqual(4, r.edges().size())
2009 self.assertEqual(
2010 (1.0, 1.0),
2011 (
2012 r.vertices(selectors.NearestToPointSelector((0.0, 0.0, 0.0)))
2013 .first()
2014 .val()
2015 .X,
2016 r.vertices(selectors.NearestToPointSelector((0.0, 0.0, 0.0)))
2017 .first()
2018 .val()
2019 .Y,
2020 ),
2021 )
2022
2023 # Test the sagittaArc and radiusArc functions
2024 a1 = Workplane(Plane.YZ()).threePointArc((5, 1), (10, 0))
2025 a2 = Workplane(Plane.YZ()).sagittaArc((10, 0), -1)

Callers

nothing calls this directly

Calls 15

lineToMethod · 0.95
hLineToMethod · 0.95
hLineMethod · 0.95
moveMethod · 0.95
WorkplaneClass · 0.85
XYMethod · 0.80
threePointArcMethod · 0.80
moveToMethod · 0.80
vLineToMethod · 0.80
vLineMethod · 0.80
YZMethod · 0.80
sagittaArcMethod · 0.80

Tested by

no test coverage detected