The Sketch.vertices()
method is a function available in the CadQuery library. It can be used to retrieve a list of vertices from a 2D Sketch object. This method returns a list of Vertex
objects, which are essentially 2D points in the sketch coordinate system.
vertices(tolerance=None)
tolerance
(float): The minimum distance between two points to consider them different.The Sketch.vertices()
method returns a list of Vertex
objects.
import cadquery as cq
# create a new sketch and add some lines to it
sketch = cq.Workplane("XY").rect(2, 2).extrude(1)
points = sketch.vertices()
# print the list of points
for point in points:
print(point)
In this example, we create a new sketch and define a rectangle with a width and height of 2 units. We then extrude this sketch to create a 3D solid. Finally, we call the vertices()
method to retrieve a list of points from the sketch. The list of points is then printed to the console.
vertices()
method only works on 2D Sketch objects. It cannot be used on 3D solid objects.tolerance
parameter is set to None
. This means that all points will be returned, even if they are very close to each other. If you want to remove duplicate points, you can set this parameter to a small value.Vertex
objects have two attributes: x
and y
, which represent the coordinates of the point in the sketch coordinate system.