The wire method of the Workplane class in CadQuery creates a Wire object, which represents a wire in 3D space. A wire is a sequence of edges that encloses a region. This method can be used to create wires from scratch, or to modify existing wires.
wire(self, *args, **kwargs)
*args: variable-length argument list of edges
**kwargs: keyword arguments
tolerance: the maximum distance between two points to be considered coincident (default: 1e-06)extrude_both: if True, extrusions will be made along both directions of the wire edges; if False, only one direction is used (default: False)both: an alias for extrude_bothreturn_edges: if True, a list of edges corresponding to the wire will be returned (default: False)make_wire: if True, a wire object will be created from the edges; if False, the edges will be returned as a list (default: True)Wire object representing the wire, or a list of edges if make_wire is FalseCreating a wire from scratch:
import cadquery as cq
from cadquery import Edge, Wire
# create the edges of the wire
e1 = Edge.makeLine((0, 0, 0), (0, 1, 0))
e2 = Edge.makeLine((0, 1, 0), (1, 1, 0))
e3 = Edge.makeLine((1, 1, 0), (1, 0, 0))
e4 = Edge.makeLine((1, 0, 0), (0, 0, 0))
# create the wire from the edges
w = cq.Workplane().wire(e1, e2, e3, e4)
Modifying an existing wire:
import cadquery as cq
# import an STL file as a solid
solid = cq.importers.importFile("example.stl")
# get a wire from the solid
w = solid.edges().vals()[0].wire()
# reverse the direction of the wire
w = cq.Workplane().reverse(w)
Note: In the examples above, cq is an alias for cadquery.
Edge classWire classWorkplane class