cadquery
Sketch
Workplane
Assembly

Sketch.edge()

The Sketch.edge() method is used in the CadQuery library to create a straight edge in a 2D sketch plane. This method takes two points as arguments that define the start and end points of the edge.

Syntax

The syntax for the Sketch.edge() method is as follows:

edge(start_point, end_point)

Parameters

  • start_point (tuple or list): A tuple or list of two values that represents the x and y coordinates of the starting point of the edge.
  • end_point (tuple or list): A tuple or list of two values that represents the x and y coordinates of the ending point of the edge.

Example

import cadquery as cq

# Create a 2D sketch plane
plane = cq.Workplane("XY").grid()

# Create a straight edge
edge1 = plane.edge((0,0),(10,10))

In the above example, a 2D sketch plane is first created using the grid() method. The Sketch.edge() method is then called to create a straight edge that starts at the point (0,0) and ends at the point (10,10). The resulting edge is stored in the variable edge1.

Return Value

The Sketch.edge() method returns a Wire object, which is a collection of connected edges that define a closed or open loop in the sketch plane.

Notes

  • The coordinates of the start and end points of the edge must be specified in the order (x,y).
  • The Sketch.edge() method can be used to create multiple connected edges by calling it multiple times with appropriate start and end points. These edges can then be combined using the Wire.combine() method to form a closed or open loop.
  • The Sketch.edge() method can also be used to create curved edges by passing in more than two points as arguments. However, it is generally recommended to use the Sketch.arc() or Sketch.spline() methods to create curved edges instead.