Skip to content

Commit 2517f4e

Browse files
Fix close for mixed mode edges (#1477)
* Fix close for mixed mode edges * black fix * Logic fix * Add a test --------- Co-authored-by: adam-urbanczyk <13981538+adam-urbanczyk@users.noreply.github.com>
1 parent 0cccbe4 commit 2517f4e

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

cadquery/sketch.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,14 @@ def _startPoint(self) -> Vector:
775775
if not self._edges:
776776
raise ValueError("No free edges available")
777777

778-
e = self._edges[0]
778+
# find the first edge matching current edge mode
779+
e = self._edges[-1]
780+
mode = e.forConstruction
781+
782+
for el in self._edges:
783+
if el.forConstruction == mode:
784+
e = el
785+
break
779786

780787
return e.startPoint()
781788

tests/test_sketch.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,3 +973,22 @@ def test_missing_selection(s1):
973973
# cannot tag without selection
974974
with raises(ValueError):
975975
s1.tag("name")
976+
977+
978+
def test_mixed_close():
979+
980+
# check that closing of mixed mode edges works correctly
981+
s = (
982+
Sketch()
983+
.arc((0, 0), 30, 0, 120, tag="e0", forConstruction=True)
984+
.edges(tag="e0")
985+
.distribute(1, rotate=False)
986+
.segment((0, 0), (10, 2))
987+
.segment((10, -2))
988+
.close()
989+
.assemble()
990+
.reset() # reset the implicit selection coming from distribute
991+
)
992+
993+
# the underlying face should be valid
994+
assert s.val().isValid()

0 commit comments

Comments
 (0)