| 2355 | |
| 2356 | |
| 2357 | def 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 | |
| 2390 | def test_step_export_filesize(tmpdir): |