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

Function test_order_of_transform

tests/test_assembly.py:2357–2387  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2355
2356
2357def test_order_of_transform():
2358
2359 part = cq.Workplane().box(1, 1, 1).faces(">Z").vertices("<XY").tag("vtag")
2360 marker = cq.Workplane().sphere(0.2)
2361
2362 assy0 = cq.Assembly().add(
2363 part, name="part1", loc=cq.Location((0, 0, 1.5), (0, 0, 1), 45),
2364 )
2365
2366 assy1 = (
2367 cq.Assembly()
2368 .add(assy0, name="assy0", loc=cq.Location(2, 0, 0))
2369 .add(marker, name="marker1")
2370 )
2371
2372 # attach the first marker to the tagged corner
2373 assy1.constrain("assy0/part1", "Fixed")
2374 assy1.constrain("marker1", "assy0/part1?vtag", "Point")
2375 assy1.solve()
2376
2377 assy2 = cq.Assembly().add(assy1, name="assy1").add(marker, name="marker2")
2378
2379 # attach the second marker to the tagged corner, but this time with nesting
2380 assy2.constrain("assy1/marker1", "Fixed")
2381 assy2.constrain("marker2", "assy1/assy0/part1?vtag", "Point")
2382 assy2.solve()
2383
2384 # marker1 and marker2 should coincide
2385 m1, m2 = assy2.toCompound().Solids()
2386
2387 assert (m1.Center() - m2.Center()).Length == approx(0)
2388
2389
2390def test_step_export_filesize(tmpdir):

Callers

nothing calls this directly

Calls 11

boxMethod · 0.80
sphereMethod · 0.80
SolidsMethod · 0.80
toCompoundMethod · 0.80
tagMethod · 0.45
verticesMethod · 0.45
facesMethod · 0.45
addMethod · 0.45
constrainMethod · 0.45
solveMethod · 0.45
CenterMethod · 0.45

Tested by

no test coverage detected