Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cadquery/cq.py
Original file line number Diff line number Diff line change
Expand Up @@ -1413,8 +1413,10 @@ def _findFromPoint(self, useLocalCoords: bool = False) -> Vector:
p = obj.endPoint()
elif isinstance(obj, Vector):
p = obj
elif isinstance(obj, Vertex):
p = obj.Center()
else:
raise RuntimeError("Cannot convert object type '%s' to vector " % type(obj))
raise ValueError(f"Cannot convert object type {type(obj)} to vector.")

if useLocalCoords:
return self.plane.toLocalCoords(p)
Expand Down
12 changes: 12 additions & 0 deletions tests/test_cadquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -5917,3 +5917,15 @@ def test_compound_faces_center(self):
), "Incorrect center of mass of the compound, expected {}, got {}".format(
expected_center, compound.Center()
)

def test_line_from_vertex(self):

# select one vertex and create an Edge
res = Workplane().rect(1, 1).vertices(">(1,1,0)").line(1, 0)

# check if an Edge was created
assert isinstance(res.val(), Edge)

# check that errors are handled
with raises(ValueError):
Workplane().box(1, 1, 1).line(1, 0)