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

Method test_project

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

Source from the content-addressed store, hash-verified

5647 assert d13 == approx(0.5)
5648
5649 def test_project(self):
5650
5651 # project a single letter
5652 t = Compound.makeText("T", 5, 0).Faces()[0]
5653 f = Workplane("XZ", origin=(0, 0, -7)).sphere(6).faces("not %PLANE").val()
5654
5655 res = t.project(f, (0, 0, 1))
5656
5657 assert res.isValid()
5658 assert len(res.Edges()) == len(t.Edges())
5659 assert t.distance(res) == approx(1)
5660
5661 # extrude it
5662 res_ex = Solid.extrudeLinear(t.project(f, (0, 0, -1)), (0.0, 0.0, 0.5))
5663
5664 assert res_ex.isValid()
5665 assert len(res_ex.Faces()) == 10
5666
5667 # project a wire
5668 w = t.outerWire()
5669
5670 res_w = w.project(f, (0, 0, 1))
5671
5672 assert len(res_w.Edges()) == 8
5673 assert res_w.isValid()
5674
5675 res_w1, res_w2 = w.project(f, (0, 0, 1), False)
5676
5677 assert len(res_w1.Edges()) == 8
5678 assert len(res_w2.Edges()) == 8
5679
5680 # project a single letter with openings
5681 o = Compound.makeText("O", 5, 0).Faces()[0]
5682 f = Workplane("XZ", origin=(0, 0, -7)).sphere(6).faces("not %PLANE").val()
5683
5684 res_o = o.project(f, (0, 0, 1))
5685
5686 assert res_o.isValid()
5687
5688 # extrude it
5689 res_o_ex = Solid.extrudeLinear(o.project(f, (0, 0, -1)), (0.0, 0.0, 0.5))
5690
5691 assert res_o_ex.isValid()
5692
5693 def test_makeNSidedSurface(self):
5694

Callers

nothing calls this directly

Calls 12

WorkplaneClass · 0.85
makeTextMethod · 0.80
sphereMethod · 0.80
isValidMethod · 0.80
EdgesMethod · 0.80
extrudeLinearMethod · 0.80
outerWireMethod · 0.80
FacesMethod · 0.45
valMethod · 0.45
facesMethod · 0.45
projectMethod · 0.45
distanceMethod · 0.45

Tested by

no test coverage detected