Skip to content

Commit

Permalink
Skip CQGI assignment of unsupported parameter type (tuple)
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzncode committed Jul 6, 2023
1 parent afdc4db commit 57d815a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 7 additions & 3 deletions cadquery/cqgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,13 @@ def visit_Assign(self, node):
if type(node.value) in astTypes:
self.handle_assignment(left_side.id, node.value)
elif type(node.value) == ast.Tuple:
# we have a multi-value assignment
for n, v in zip(left_side.elts, node.value.elts):
self.handle_assignment(n.id, v)
if isinstance(left_side, ast.Name):
# skip unsupported parameter type
pass
else:
# we have a multi-value assignment
for n, v in zip(left_side.elts, node.value.elts):
self.handle_assignment(n.id, v)
except:
traceback.print_exc()
print("Unable to handle assignment for node '%s'" % ast.dump(left_side))
Expand Down
6 changes: 4 additions & 2 deletions doc/assy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -783,12 +783,14 @@ Where:
.add(b1, loc=cq.Location((-2, 0, 0)), name="b3", color=cq.Color("red"))
)

pnt = (0.5, 0.5, 0.5)

# fix the position of b1
assy.constrain("b1", "Fixed")
# fix b2 center at point
assy.constrain("b2", "FixedPoint", (0.5, 0.5, 0.5))
assy.constrain("b2", "FixedPoint", pnt)
# fix b3 vertex position at point
assy.constrain("b3@vertices@<X and <Y and <Z", "FixedPoint", (0.5, 0.5, 0.5))
assy.constrain("b3@vertices@<X and <Y and <Z", "FixedPoint", pnt)

assy.solve()
show_object(assy)
Expand Down

0 comments on commit 57d815a

Please sign in to comment.