Skip to content

Commit c0ebeba

Browse files
authored
Merge pull request #592 from greyltc/fix-empty-solve
fix unconstrained assembly.solve()
2 parents 53a76d4 + 48d7800 commit c0ebeba

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

cadquery/assembly.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,10 @@ def solve(self) -> "Assembly":
401401
for c in self.constraints:
402402
constraints.append(((ents[c.objects[0]], ents[c.objects[1]]), c.toPOD()))
403403

404+
# check if any constraints were specified
405+
if not constraints:
406+
raise ValueError("At least one constraint required")
407+
404408
# instantiate the solver
405409
solver = ConstraintSolver(locs, constraints, locked=[lock_ix])
406410

tests/test_assembly.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,9 @@ def test_duplicate_name(nested_assy):
212212

213213
with pytest.raises(ValueError):
214214
nested_assy.add(None, name="SECOND")
215+
216+
217+
def test_empty_solve(nested_assy):
218+
219+
with pytest.raises(ValueError):
220+
nested_assy.solve()

0 commit comments

Comments
 (0)