|
5 | 5 | import copy
|
6 | 6 | from pathlib import Path, PurePath
|
7 | 7 | import re
|
| 8 | +from pytest import approx |
8 | 9 |
|
9 | 10 | import cadquery as cq
|
10 | 11 | from cadquery.occ_impl.exporters.assembly import (
|
@@ -1608,3 +1609,36 @@ def test_imprinting(touching_assy, disjoint_assy):
|
1608 | 1609 |
|
1609 | 1610 | for s in r.Solids():
|
1610 | 1611 | assert s in o
|
| 1612 | + |
| 1613 | + |
| 1614 | +def test_order_of_transform(): |
| 1615 | + |
| 1616 | + part = cq.Workplane().box(1, 1, 1).faces(">Z").vertices("<XY").tag("vtag") |
| 1617 | + marker = cq.Workplane().sphere(0.2) |
| 1618 | + |
| 1619 | + assy0 = cq.Assembly().add( |
| 1620 | + part, name="part1", loc=cq.Location((0, 0, 1.5), (0, 0, 1), 45), |
| 1621 | + ) |
| 1622 | + |
| 1623 | + assy1 = ( |
| 1624 | + cq.Assembly() |
| 1625 | + .add(assy0, name="assy0", loc=cq.Location(2, 0, 0)) |
| 1626 | + .add(marker, name="marker1") |
| 1627 | + ) |
| 1628 | + |
| 1629 | + # attach the first marker to the tagged corner |
| 1630 | + assy1.constrain("assy0/part1", "Fixed") |
| 1631 | + assy1.constrain("marker1", "assy0/part1?vtag", "Point") |
| 1632 | + assy1.solve() |
| 1633 | + |
| 1634 | + assy2 = cq.Assembly().add(assy1, name="assy1").add(marker, name="marker2") |
| 1635 | + |
| 1636 | + # attach the second marker to the tagged corner, but this time with nesting |
| 1637 | + assy2.constrain("assy1/marker1", "Fixed") |
| 1638 | + assy2.constrain("marker2", "assy1/assy0/part1?vtag", "Point") |
| 1639 | + assy2.solve() |
| 1640 | + |
| 1641 | + # marker1 and marker2 should coincide |
| 1642 | + m1, m2 = assy2.toCompound().Solids() |
| 1643 | + |
| 1644 | + assert (m1.Center() - m2.Center()).Length == approx(0) |
0 commit comments