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

Function test_parray

tests/test_sketch.py:226–304  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

224
225
226def test_parray():
227
228 with raises(ValueError):
229 Sketch().parray(2, 0, 90, 0).rect(1, 1)
230
231 s1 = Sketch().parray(2, 0, 90, 3).rect(1, 1)
232
233 assert s1._faces.Area() == approx(3)
234 assert len(s1._faces.Faces()) == 3
235
236 s2 = Sketch().push([(0, 0), (1, 1)]).parray(2, 0, 90, 3).rect(0.5, 0.5)
237
238 assert s2._faces.Area() == approx(6 * 0.25)
239 assert len(s2._faces.Faces()) == 6
240
241 s3 = Sketch().parray(2, 0, 90, 3, False).rect(0.5, 0.5).reset().vertices(">(1,1,0)")
242
243 assert len(s3._selection) == 1
244 assert s3._selection[0].toTuple() == approx(
245 (1.6642135623730951, 1.664213562373095, 0.0)
246 )
247
248 s4 = Sketch().push([(0, 0), (0, 1)]).parray(2, 0, 90, 3).rect(0.5, 0.5)
249 s4.reset().faces(">(0,1,0)")
250
251 assert s4._selection[0].Center().Length == approx(3)
252
253 s5 = Sketch().push([(0, 1)], tag="loc")
254
255 assert len(s5._tags["loc"]) == 1
256
257 s6 = Sketch().push([(-4, 1), (0, 0), (4, -1)]).parray(2, 10, 50, 3).rect(1.0, 0.5)
258 s6.reset().vertices(">(-1,0,0)")
259
260 assert s6._selection[0].toTuple() == approx(
261 (-3.46650635094611, 2.424038105676658, 0.0)
262 )
263
264 s6.reset().vertices(">(1,0,0)")
265
266 assert s6._selection[0].toTuple() == approx(
267 (6.505431426947252, -0.8120814940857262, 0.0)
268 )
269
270 s7 = Sketch().parray(1, 135, 0, 1).circle(0.1)
271 s7.reset().faces()
272
273 assert len(s7._selection) == 1
274 assert s7._selection[0].Center().toTuple() == approx(
275 (-0.7071067811865475, 0.7071067811865476, 0.0)
276 )
277
278 s8 = Sketch().parray(4, 20, 360, 6).rect(1.0, 0.5)
279
280 assert len(s8._faces.Faces()) == 6
281
282 s8.reset().vertices(">(0,-1,0)")
283

Callers

nothing calls this directly

Calls 12

SketchClass · 0.90
parrayMethod · 0.80
pushMethod · 0.80
resetMethod · 0.80
rectMethod · 0.45
AreaMethod · 0.45
FacesMethod · 0.45
verticesMethod · 0.45
toTupleMethod · 0.45
facesMethod · 0.45
CenterMethod · 0.45
circleMethod · 0.45

Tested by

no test coverage detected