""" Marking utilities for `Cq.Workplane` Adds the functions to `Cq.Workplane`: 1. `tagPoint` 2. `tagPlane` """ import cadquery as Cq def tagPoint(self, tag: str): """ Adds a vertex that can be used in `Point` constraints. """ vertex = Cq.Vertex.makeVertex(0, 0, 0) self.eachpoint(vertex.moved, useLocalCoordinates=True).tag(tag) Cq.Workplane.tagPoint = tagPoint def tagPlane(self, tag: str, axis='Z'): """ Adds a phantom `Cq.Edge` in the given location which can be referenced in a `Axis`, `Point`, or `Plane` constraint. """ x, y, z = 0, 0, 0 if axis in ('z', 'Z'): z = 1 elif axis in ('y', 'Y'): y = 1 elif axis in ('x', 'X'): x = 1 else: assert False, "Axis must be one of x,y,z" edge = Cq.Edge.makeLine((-x, -y, -z), (x, y, z)) self.eachpoint(edge.moved, useLocalCoordinates=True).tag(tag) Cq.Workplane.tagPlane = tagPlane