# CadQuery Class Summary¶

This page documents all of the methods and functions of the CadQuery classes, organized alphabetically.

For a listing organized by functional area, see the CadQuery API Reference

## Core Classes¶

 CQ cadquery.cq.Workplane のエイリアス Defines a coordinate system in space, in which 2D coordinates can be used. Assembly([obj, loc, name, color]) Nested assembly of Workplane and Shape objects defining their relative positions. Constraint(objects, args, sublocs, kind[, param]) Geometrical constraint between two shapes of an assembly.

## Topological Classes¶

 Shape(obj) Represents a shape in the system. Vertex(obj[, forConstruction]) A Single Point in Space Edge(obj) A trimmed curve that represents the border of a face Wire(obj) A series of connected, ordered Edges, that typically bounds a Face Face(obj) a bounded surface that represents part of the boundary of a solid Shell(obj) the outer boundary of a surface Solid(obj) a single solid Compound(obj) a collection of disconnected solids

## Geometry Classes¶

 Create a 3-dimensional vector A 3d , 4x4 transformation matrix. Plane(origin[, xDir, normal]) A 2D coordinate system in space Location in 3D space.

## Selector Classes¶

 Filters a list of objects. Selects object nearest the provided point. BoxSelector(point0, point1[, boundingbox]) Selects objects inside the 3D box defined by 2 points. BaseDirSelector(vector[, tolerance]) A selector that handles selection on the basis of a single direction vector. ParallelDirSelector(vector[, tolerance]) Selects objects parallel with the provided direction. DirectionSelector(vector[, tolerance]) Selects objects aligned with the provided direction. PerpendicularDirSelector(vector[, tolerance]) Selects objects perpendicular with the provided direction. TypeSelector(typeString) Selects objects having the prescribed geometry type. RadiusNthSelector(n[, directionMax, tolerance]) Select the object with the Nth radius. CenterNthSelector(vector, n[, directionMax, ...]) Sorts objects into a list with order determined by the distance of their center projected onto the specified direction. DirectionMinMaxSelector(vector[, ...]) Selects objects closest or farthest in the specified direction. DirectionNthSelector(vector, n[, ...]) Filters for objects parallel (or normal) to the specified direction then returns the Nth one. LengthNthSelector(n[, directionMax, tolerance]) Select the object(s) with the Nth length AreaNthSelector(n[, directionMax, tolerance]) Selects the object(s) with Nth area BinarySelector(left, right) Base class for selectors that operates with two other selectors. AndSelector(left, right) Intersection selector. SumSelector(left, right) Union selector. SubtractSelector(left, right) Difference selector. InverseSelector(selector) Inverts the selection of given selector. StringSyntaxSelector(selectorString) Filter lists objects using a simple string syntax.

## Class Details¶

class cadquery.Assembly(obj=None, loc=None, name=None, color=None)[ソース]

ベースクラス: object

Nested assembly of Workplane and Shape objects defining their relative positions.

パラメータ
• obj (Union[Shape, Workplane, None]) --

• loc (Optional[Location]) --

• name (Optional[str]) --

• color (Optional[Color]) --

__init__(obj=None, loc=None, name=None, color=None)[ソース]

construct an assembly

パラメータ
• obj (Union[Shape, Workplane, None]) -- root object of the assembly (default: None)

• loc (Optional[Location]) -- location of the root object (default: None, interpreted as identity transformation)

• name (Optional[str]) -- unique name of the root object (default: None, reasulting in an UUID being generated)

• color (Optional[Color]) -- color of the added object (default: None)

An Assembly object.

To create an empty assembly use:

assy = Assembly(None)


To create one constraint a root object:

b = Workplane().box(1,1,1)
assy = Assembly(b, Location(Vector(0,0,1)), name="root")

__weakref__

list of weak references to the object (if defined)

add(obj: cadquery.assembly.Assembly, loc: Optional[cadquery.occ_impl.geom.Location] = 'None', name: Optional[str] = 'None', color: Optional[cadquery.occ_impl.assembly.Color] = 'None') → cadquery.assembly.Assembly[ソース]
add(obj: Optional[Union[cadquery.occ_impl.shapes.Shape, cadquery.cq.Workplane]], loc: Optional[cadquery.occ_impl.geom.Location] = 'None', name: Optional[str] = 'None', color: Optional[cadquery.occ_impl.assembly.Color] = 'None') → cadquery.assembly.Assembly

Add a subassembly to the current assembly.

constrain(q1: str, q2: str, kind: Literal[Plane, Point, Axis, PointInPlane], param: Any = 'None') → cadquery.assembly.Assembly[ソース]
constrain(id1: str, s1: cadquery.occ_impl.shapes.Shape, id2: str, s2: cadquery.occ_impl.shapes.Shape, kind: Literal[Plane, Point, Axis, PointInPlane], param: Any = 'None') → cadquery.assembly.Assembly

Define a new constraint.

save(path, exportType=None)[ソース]

save as STEP or OCCT native XML file

パラメータ
• path (str) -- filepath

• exportType (Optional[Literal['STEP', 'XML']]) -- export format (default: None, results in format being inferred form the path)

Assembly

property shapes

List of Shape objects in the .obj field

List[Shape]

solve()[ソース]

Solve the constraints.

Assembly

toCompound()[ソース]

Returns a Compound made from this Assembly (including all children) with the current Locations applied. Usually this method would only be used after solving.

Compound

traverse()[ソース]

Yield (name, child) pairs in a bottom-up manner

Iterator[Tuple[str, Assembly]]

class cadquery.BoundBox(bb)[ソース]

ベースクラス: object

A BoundingBox for an object or set of objects. Wraps the OCP one

パラメータ

bb (Bnd_Box) --

__init__(bb)[ソース]

Initialize self. See help(type(self)) for accurate signature.

パラメータ

bb (Bnd_Box) --

__weakref__

list of weak references to the object (if defined)

add(obj, tol=None)[ソース]

Returns a modified (expanded) bounding box

obj can be one of several things:
1. a 3-tuple corresponding to x,y, and z amounts to add

2. a vector, containing the x,y,z values to add

3. another bounding box, where a new box will be created that encloses both.

This bounding box is not changed.

パラメータ
• obj (Union[Tuple[float, float, float], Vector, BoundBox]) --

• tol (Optional[float]) --

BoundBox

static findOutsideBox2D(bb1, bb2)[ソース]

Compares bounding boxes

Compares bounding boxes. Returns none if neither is inside the other. Returns the outer one if either is outside the other.

BoundBox.isInside works in 3d, but this is a 2d bounding box, so it doesn't work correctly plus, there was all kinds of rounding error in the built-in implementation i do not understand.

パラメータ
• bb1 (BoundBox) --

• bb2 (BoundBox) --

Optional[BoundBox]

isInside(b2)[ソース]

Is the provided bounding box inside this one?

パラメータ

b2 (BoundBox) --

bool

cadquery.CQ

cadquery.cq.Workplane のエイリアス

class cadquery.Color(name: str)[ソース]
class cadquery.Color(r: float, g: float, b: float, a: float = '0')

ベースクラス: object

Wrapper for the OCCT color object Quantity_ColorRGBA.

__init__(name: str)[ソース]
__init__(r: float, g: float, b: float, a: float = '0')

Initialize self. See help(type(self)) for accurate signature.

__weakref__

list of weak references to the object (if defined)

toTuple()[ソース]

Convert Color to RGB tuple.

Tuple[float, float, float, float]

class cadquery.Compound(obj)[ソース]

ベースクラス: cadquery.occ_impl.shapes.Shape, cadquery.occ_impl.shapes.Mixin3D

a collection of disconnected solids

パラメータ

obj (TopoDS_Shape) --

__iter__()[ソース]

Iterate over subshapes.

Iterator[Shape]

cut(*toCut)[ソース]

Remove a shape from another one

パラメータ

toCut (Shape) --

Shape

fuse(*toFuse, glue=False, tol=None)[ソース]

Fuse shapes together

パラメータ
• toFuse (Shape) --

• glue (bool) --

• tol (Optional[float]) --

Shape

intersect(*toIntersect)[ソース]

Construct shape intersection

パラメータ

toIntersect (Shape) --

Shape

classmethod makeCompound(listOfShapes)[ソース]

Create a compound out of a list of shapes

パラメータ
• cls (Type[Compound]) --

• listOfShapes (Iterable[Shape]) --

Compound

classmethod makeText(text, size, height, font='Arial', fontPath=None, kind='regular', halign='center', valign='center', position=<cadquery.occ_impl.geom.Plane object>)[ソース]

Create a 3D text

パラメータ
• cls (Type[Compound]) --

• text (str) --

• size (float) --

• height (float) --

• font (str) --

• fontPath (Optional[str]) --

• kind (Literal['regular', 'bold', 'italic']) --

• halign (Literal['center', 'left', 'right']) --

• valign (Literal['center', 'top', 'bottom']) --

• position (Plane) --

Shape

class cadquery.Constraint(objects, args, sublocs, kind, param=None)[ソース]

ベースクラス: object

Geometrical constraint between two shapes of an assembly.

パラメータ
• objects (Tuple[str, ...]) --

• args (Tuple[Shape, ...]) --

• sublocs (Tuple[Location, ...]) --

• kind (Literal['Plane', 'Point', 'Axis', 'PointInPlane']) --

• param (Optional[Any]) --

__init__(objects, args, sublocs, kind, param=None)[ソース]

Construct a constraint.

パラメータ
• objects (Tuple[str, ...]) -- object names referenced in the constraint

• args (Tuple[Shape, ...]) -- subshapes (e.g. faces or edges) of the objects

• sublocs (Tuple[Location, ...]) -- locations of the objects (only relevant if the objects are nested in a sub-assembly)

• kind (Literal['Plane', 'Point', 'Axis', 'PointInPlane']) -- constraint kind

• param (Optional[Any]) -- optional arbitrary parameter passed to the solver

__weakref__

list of weak references to the object (if defined)

toPOD()[ソース]

Convert the constraint to a representation used by the solver.

Tuple[Tuple[Union[gp_Pln, gp_Dir, gp_Pnt], ...], Tuple[Union[gp_Pln, gp_Dir, gp_Pnt, None], ...], Optional[Any]]

class cadquery.DirectionMinMaxSelector(vector, directionMax=True, tolerance=0.0001)[ソース]

Selects objects closest or farthest in the specified direction.

Applicability:

All object types. for a vertex, its point is used. for all other kinds of objects, the center of mass of the object is used.

You can use the string shortcuts >(X|Y|Z) or <(X|Y|Z) if you want to select based on a cardinal direction.

For example this:

CQ(aCube).faces(DirectionMinMaxSelector((0, 0, 1), True)


Means to select the face having the center of mass farthest in the positive z direction, and is the same as:

CQ(aCube).faces(">Z")

パラメータ
• vector (Vector) --

• directionMax (bool) --

• tolerance (float) --

__init__(vector, directionMax=True, tolerance=0.0001)[ソース]

Initialize self. See help(type(self)) for accurate signature.

パラメータ
• vector (Vector) --

• directionMax (bool) --

• tolerance (float) --

class cadquery.DirectionSelector(vector, tolerance=0.0001)[ソース]

Selects objects aligned with the provided direction.

Applicability:

Linear Edges Planar Faces

Use the string syntax shortcut +/-(X|Y|Z) if you want to select based on a cardinal direction.

Example:

CQ(aCube).faces(DirectionSelector((0, 0, 1))


selects faces with the normal in the z direction, and is equivalent to:

CQ(aCube).faces("+Z")

パラメータ
• vector (Vector) --

• tolerance (float) --

test(vec)[ソース]

Test a specified vector. Subclasses override to provide other implementations

パラメータ

vec (Vector) --

bool

class cadquery.Edge(obj)[ソース]

ベースクラス: cadquery.occ_impl.shapes.Shape, cadquery.occ_impl.shapes.Mixin1D

A trimmed curve that represents the border of a face

パラメータ

obj (TopoDS_Shape) --

close()[ソース]

Close an Edge

Union[Edge, Wire]

classmethod makeEllipse(x_radius, y_radius, pnt=Vector: (0.0, 0.0, 0.0), dir=Vector: (0.0, 0.0, 1.0), xdir=Vector: (1.0, 0.0, 0.0), angle1=360.0, angle2=360.0, sense=1)[ソース]

Makes an Ellipse centered at the provided point, having normal in the provided direction.

パラメータ
• cls (Type[Edge]) --

• x_radius (float) -- x radius of the ellipse (along the x-axis of plane the ellipse should lie in)

• y_radius (float) -- y radius of the ellipse (along the y-axis of plane the ellipse should lie in)

• pnt (Union[Vector, Tuple[float, float, float]]) -- vector representing the center of the ellipse

• dir (Union[Vector, Tuple[float, float, float]]) -- vector representing the direction of the plane the ellipse should lie in

• angle1 (float) -- start angle of arc

• angle2 (float) -- end angle of arc (angle2 == angle1 return closed ellipse = default)

• sense (Literal[-1, 1]) -- clockwise (-1) or counter clockwise (1)

• xdir (Union[Vector, Tuple[float, float, float]]) --

Edge

an Edge

classmethod makeLine(v1, v2)[ソース]

Create a line between two points :type v1: Vector :param v1: Vector that represents the first point :type v2: Vector :param v2: Vector that represents the second point :rtype: Edge :return: A linear edge between the two provided points

パラメータ

cls (Type[Edge]) --

classmethod makeSpline(listOfVector, tangents=None, periodic=False, parameters=None, scale=True, tol=1e-06)[ソース]

Interpolate a spline through the provided points.

パラメータ
• listOfVector (List[Vector]) -- a list of Vectors that represent the points

• tangents (Optional[Sequence[Vector]]) -- tuple of Vectors specifying start and finish tangent

• periodic (bool) -- creation of periodic curves

• parameters (Optional[Sequence[float]]) -- the value of the parameter at each interpolation point. (The interpolated curve is represented as a vector-valued function of a scalar parameter.) If periodic == True, then len(parameters) must be len(intepolation points) + 1, otherwise len(parameters) must be equal to len(interpolation points).

• scale (bool) -- whether to scale the specified tangent vectors before interpolating. Each tangent is scaled, so it's length is equal to the derivative of the Lagrange interpolated curve. I.e., set this to True, if you want to use only the direction of the tangent vectors specified by tangents, but not their magnitude.

• tol (float) -- tolerance of the algorithm (consult OCC documentation). Used to check that the specified points are not too close to each other, and that tangent vectors are not too short. (In either case interpolation may fail.)

• cls (Type[Edge]) --

Edge

an Edge

classmethod makeSplineApprox(listOfVector, tol=0.001, smoothing=None, minDeg=1, maxDeg=6)[ソース]

Approximate a spline through the provided points.

パラメータ
• listOfVector (List[Vector]) -- a list of Vectors that represent the points

• tol (float) -- tolerance of the algorithm (consult OCC documentation).

• smoothing (Optional[Tuple[float, float, float]]) -- optional tuple of 3 weights use for variational smoothing (default: None)

• minDeg (int) -- minimum spline degree. Enforced only when smothing is None (default: 1)

• maxDeg (int) -- maximum spline degree (default: 6)

• cls (Type[Edge]) --

Edge

an Edge

classmethod makeTangentArc(v1, v2, v3)[ソース]

Makes a tangent arc from point v1, in the direction of v2 and ends at v3. :type cls: Type[Edge] :param cls: :type v1: Vector :param v1: start vector :type v2: Vector :param v2: tangent vector :type v3: Vector :param v3: end vector :rtype: Edge :return: an edge

classmethod makeThreePointArc(v1, v2, v3)[ソース]

Makes a three point arc through the provided points :type cls: Type[Edge] :param cls: :type v1: Vector :param v1: start vector :type v2: Vector :param v2: middle vector :type v3: Vector :param v3: end vector :rtype: Edge :return: an edge object through the three points

class cadquery.Face(obj)[ソース]

ベースクラス: cadquery.occ_impl.shapes.Shape

a bounded surface that represents part of the boundary of a solid

パラメータ

obj (TopoDS_Shape) --

Center()[ソース]

Vector

The point of the center of mass of this Shape

chamfer2D(d, vertices)[ソース]

Apply 2D chamfer to a face

パラメータ
• d (float) --

• vertices (Iterable[Vertex]) --

Face

fillet2D(radius, vertices)[ソース]

Apply 2D fillet to a face

パラメータ
• radius (float) --

• vertices (Iterable[Vertex]) --

Face

classmethod makeFromWires(outerWire, innerWires=[])[ソース]

Makes a planar face from one or more wires

パラメータ
• cls (Type[Face]) --

• outerWire (Wire) --

• innerWires (List[Wire]) --

Face

classmethod makeNSidedSurface(edges, points, continuity=<GeomAbs_Shape.GeomAbs_C0: 0>, degree=3, nbPtsOnCur=15, nbIter=2, anisotropy=False, tol2d=1e-05, tol3d=0.0001, tolAng=0.01, tolCurv=0.1, maxDeg=8, maxSegments=9)[ソース]

Returns a surface enclosed by a closed polygon defined by 'edges' and going through 'points'. :param points :type points: list of gp_Pnt :param edges :type edges: list of Edge :param continuity=GeomAbs_C0 :type continuity: OCC.Core.GeomAbs continuity condition :param Degree = 3 (OCCT default) :type Degree: Integer >= 2 :param NbPtsOnCur = 15 (OCCT default) :type: NbPtsOnCur Integer >= 15 :param NbIter = 2 (OCCT default) :type: NbIterInteger >= 2 :param Anisotropie = False (OCCT default) :type Anisotropie: Boolean :param: Tol2d = 0.00001 (OCCT default) :type Tol2d: float > 0 :param Tol3d = 0.0001 (OCCT default) :type Tol3dReal: float > 0 :param TolAng = 0.01 (OCCT default) :type TolAngReal: float > 0 :param TolCurv = 0.1 (OCCT default) :type TolCurvReal: float > 0 :param MaxDeg = 8 (OCCT default) :type MaxDegInteger: Integer >= 2 (?) :param MaxSegments = 9 (OCCT default) :type MaxSegments: Integer >= 2 (?)

パラメータ
• cls (Type[Face]) --

• edges (Iterable[Edge]) --

• points (Iterable[gp_Pnt]) --

• continuity (GeomAbs_Shape) --

• degree (int) --

• nbPtsOnCur (int) --

• nbIter (int) --

• anisotropy (bool) --

• tol2d (float) --

• tol3d (float) --

• tolAng (float) --

• tolCurv (float) --

• maxDeg (int) --

• maxSegments (int) --

Face

classmethod makeRuledSurface(edgeOrWire1: cadquery.occ_impl.shapes.Edge, edgeOrWire2: cadquery.occ_impl.shapes.Edge) → cadquery.occ_impl.shapes.Face[ソース]
classmethod makeRuledSurface(edgeOrWire1: cadquery.occ_impl.shapes.Wire, edgeOrWire2: cadquery.occ_impl.shapes.Wire) → cadquery.occ_impl.shapes.Face

'makeRuledSurface(Edge|Wire,Edge|Wire) -- Make a ruled surface Create a ruled surface out of two edges or wires. If wires are used then these must have the same number of edges

classmethod makeSplineApprox(points, tol=0.01, smoothing=None, minDeg=1, maxDeg=3)[ソース]

Approximate a spline surface through the provided points.

パラメータ
• points (List[List[Vector]]) -- a 2D list of Vectors that represent the points

• tol (float) -- tolerance of the algorithm (consult OCC documentation).

• smoothing (Optional[Tuple[float, float, float]]) -- optional tuple of 3 weights use for variational smoothing (default: None)

• minDeg (int) -- minimum spline degree. Enforced only when smothing is None (default: 1)

• maxDeg (int) -- maximum spline degree (default: 6)

• cls (Type[Face]) --

Face

an Face

normalAt(locationVector=None)[ソース]

Computes the normal vector at the desired location on the face.

Vector

a vector representing the direction

パラメータ

locationVector (a vector that lies on the surface.) -- the location to compute the normal at. If none, the center of the face is used.

toPln()[ソース]

Convert this face to a gp_Pln.

Note the Location of the resulting plane may not equal the center of this face, however the resulting plane will still contain the center of this face.

gp_Pln

class cadquery.Location[ソース]
class cadquery.Location(t: cadquery.occ_impl.geom.Vector)
class cadquery.Location(t: cadquery.occ_impl.geom.Plane)
class cadquery.Location(t: cadquery.occ_impl.geom.Plane, v: cadquery.occ_impl.geom.Vector)
class cadquery.Location(t: OCP.TopLoc.TopLoc_Location)
class cadquery.Location(t: OCP.gp.gp_Trsf)
class cadquery.Location(t: cadquery.occ_impl.geom.Vector, ax: cadquery.occ_impl.geom.Vector, angle: float)

ベースクラス: object

Location in 3D space. Depending on usage can be absolute or relative.

This class wraps the TopLoc_Location class from OCCT. It can be used to move Shape objects in both relative and absolute manner. It is the preferred type to locate objects in CQ.

__init__() → None[ソース]
__init__(t: cadquery.occ_impl.geom.Vector) → None
__init__(t: cadquery.occ_impl.geom.Plane) → None
__init__(t: cadquery.occ_impl.geom.Plane, v: cadquery.occ_impl.geom.Vector) → None
__init__(t: OCP.TopLoc.TopLoc_Location) → None
__init__(t: OCP.gp.gp_Trsf) → None
__init__(t: cadquery.occ_impl.geom.Vector, ax: cadquery.occ_impl.geom.Vector, angle: float) → None

Initialize self. See help(type(self)) for accurate signature.

__weakref__

list of weak references to the object (if defined)

toTuple()[ソース]

Convert the location to a translation, rotation tuple.

Tuple[Tuple[float, float, float], Tuple[float, float, float]]

class cadquery.Matrix[ソース]
class cadquery.Matrix(matrix: Union[OCP.gp.gp_GTrsf, OCP.gp.gp_Trsf])
class cadquery.Matrix(matrix: Sequence[Sequence[float]])

ベースクラス: object

A 3d , 4x4 transformation matrix.

Used to move geometry in space.

The provided "matrix" parameter may be None, a gp_GTrsf, or a nested list of values.

If given a nested list, it is expected to be of the form:

[[m11, m12, m13, m14],

[m21, m22, m23, m24], [m31, m32, m33, m34]]

A fourth row may be given, but it is expected to be: [0.0, 0.0, 0.0, 1.0] since this is a transform matrix.

__getitem__(rc)[ソース]

Provide Matrix[r, c] syntax for accessing individual values. The row and column parameters start at zero, which is consistent with most python libraries, but is counter to gp_GTrsf(), which is 1-indexed.

パラメータ

rc (Tuple[int, int]) --

float

__init__() → None[ソース]
__init__(matrix: Union[OCP.gp.gp_GTrsf, OCP.gp.gp_Trsf]) → None
__init__(matrix: Sequence[Sequence[float]]) → None

Initialize self. See help(type(self)) for accurate signature.

__repr__()[ソース]

Generate a valid python expression representing this Matrix

str

__weakref__

list of weak references to the object (if defined)

transposed_list()[ソース]

Needed by the cqparts gltf exporter

Sequence[float]

class cadquery.NearestToPointSelector(pnt)[ソース]

Selects object nearest the provided point.

If the object is a vertex or point, the distance is used. For other kinds of shapes, the center of mass is used to to compute which is closest.

Applicability: All Types of Shapes

Example:

CQ(aCube).vertices(NearestToPointSelector((0,1,0))


returns the vertex of the unit cube closest to the point x=0,y=1,z=0

__init__(pnt)[ソース]

Initialize self. See help(type(self)) for accurate signature.

filter(objectList)[ソース]

Filter the provided list.

The default implementation returns the original list unfiltered. :param objectList: list to filter :type objectList: list of OCCT primitives :return: filtered list

class cadquery.ParallelDirSelector(vector, tolerance=0.0001)[ソース]

Selects objects parallel with the provided direction.

Applicability:

Linear Edges Planar Faces

Use the string syntax shortcut |(X|Y|Z) if you want to select based on a cardinal direction.

Example:

CQ(aCube).faces(ParallelDirSelector((0, 0, 1))


selects faces with the normal parallel to the z direction, and is equivalent to:

CQ(aCube).faces("|Z")

パラメータ
• vector (Vector) --

• tolerance (float) --

test(vec)[ソース]

Test a specified vector. Subclasses override to provide other implementations

パラメータ

vec (Vector) --

bool

class cadquery.PerpendicularDirSelector(vector, tolerance=0.0001)[ソース]

Selects objects perpendicular with the provided direction.

Applicability:

Linear Edges Planar Faces

Use the string syntax shortcut #(X|Y|Z) if you want to select based on a cardinal direction.

Example:

CQ(aCube).faces(PerpendicularDirSelector((0, 0, 1))


selects faces with the normal perpendicular to the z direction, and is equivalent to:

CQ(aCube).faces("#Z")

パラメータ
• vector (Vector) --

• tolerance (float) --

test(vec)[ソース]

Test a specified vector. Subclasses override to provide other implementations

パラメータ

vec (Vector) --

bool

class cadquery.Plane(origin, xDir=None, normal=0, 0, 1)[ソース]

ベースクラス: object

A 2D coordinate system in space

A 2D coordinate system in space, with the x-y axes on the plane, and a particular point as the origin.

A plane allows the use of 2D coordinates, which are later converted to global, 3d coordinates when the operations are complete.

Frequently, it is not necessary to create work planes, as they can be created automatically from faces.

パラメータ
• origin (Union[Tuple[float, float, float], Vector]) --

• xDir (Union[Tuple[float, float, float], Vector, None]) --

• normal (Union[Tuple[float, float, float], Vector]) --

__eq__(other)[ソース]

Return self==value.

__init__(origin, xDir=None, normal=0, 0, 1)[ソース]

Create a Plane with an arbitrary orientation

パラメータ
• origin (Union[Tuple[float, float, float], Vector]) -- the origin in global coordinates

• xDir (Union[Tuple[float, float, float], Vector, None]) -- an optional vector representing the xDirection.

• normal (Union[Tuple[float, float, float], Vector]) -- the normal direction for the plane

ValueError -- if the specified xDir is not orthogonal to the provided normal

__ne__(other)[ソース]

Return self!=value.

__weakref__

list of weak references to the object (if defined)

classmethod named(stdName, origin=0, 0, 0)[ソース]

Create a predefined Plane based on the conventional names.

パラメータ
• stdName (string) -- one of (XY|YZ|ZX|XZ|YX|ZY|front|back|left|right|top|bottom)

• origin (3-tuple of the origin of the new plane, in global coordinates.) -- the desired origin, specified in global coordinates

Available named planes are as follows. Direction references refer to the global directions.

Name

xDir

yDir

zDir

XY

+x

+y

+z

YZ

+y

+z

+x

ZX

+z

+x

+y

XZ

+x

+z

-y

YX

+y

+x

-z

ZY

+z

+y

-x

front

+x

+y

+z

back

-x

+y

-z

left

+z

+y

-x

right

-z

+y

+x

top

+x

-z

+y

bottom

+x

+z

-y

パラメータ

cls (Type[Plane]) --

Plane

rotated(rotate=0, 0, 0)[ソース]

Returns a copy of this plane, rotated about the specified axes

Since the z axis is always normal the plane, rotating around Z will always produce a plane that is parallel to this one.

The origin of the workplane is unaffected by the rotation.

Rotations are done in order x, y, z. If you need a different order, manually chain together multiple rotate() commands.

パラメータ

rotate -- Vector [xDegrees, yDegrees, zDegrees]

a copy of this plane rotated as requested.

setOrigin2d(x, y)[ソース]

Set a new origin in the plane itself

Set a new origin in the plane itself. The plane's orientation and xDrection are unaffected.

パラメータ
• x (float) -- offset in the x direction

• y (float) -- offset in the y direction

void

The new coordinates are specified in terms of the current 2D system. As an example:

p = Plane.XY() p.setOrigin2d(2, 2) p.setOrigin2d(2, 2)

results in a plane with its origin at (x, y) = (4, 4) in global coordinates. Both operations were relative to local coordinates of the plane.

toLocalCoords(obj)[ソース]

Project the provided coordinates onto this plane

パラメータ

obj -- an object or vector to convert

an object of the same type, but converted to local coordinates

Most of the time, the z-coordinate returned will be zero, because most operations based on a plane are all 2D. Occasionally, though, 3D points outside of the current plane are transformed. One such example is Workplane.box(), where 3D corners of a box are transformed to orient the box in space correctly.

toWorldCoords(tuplePoint)[ソース]

Convert a point in local coordinates to global coordinates

パラメータ

tuplePoint (a 2 or three tuple of float. The third value is taken to be zero if not supplied.) -- point in local coordinates to convert.

Vector

a Vector in global coordinates

class cadquery.Selector[ソース]

ベースクラス: object

Filters a list of objects.

Filters must provide a single method that filters objects.

__weakref__

list of weak references to the object (if defined)

filter(objectList)[ソース]

Filter the provided list.

The default implementation returns the original list unfiltered. :param objectList: list to filter :type objectList: list of OCCT primitives :return: filtered list

class cadquery.Shape(obj)[ソース]

ベースクラス: object

Represents a shape in the system. Wraps TopoDS_Shape.

パラメータ

obj (TopoDS_Shape) --

Area()[ソース]

float

The surface area of all faces in this Shape

BoundingBox(tolerance=None)[ソース]

Create a bounding box for this Shape.

パラメータ

tolerance (Optional[float]) -- Tolerance value passed to BoundBox

BoundBox

A BoundBox object for this Shape

Center()[ソース]

Vector

The point of the center of mass of this Shape

CenterOfBoundBox(tolerance=None)[ソース]
パラメータ

tolerance (Optional[float]) -- Tolerance passed to the BoundingBox() method

Vector

Center of the bounding box of this shape

Closed()[ソース]

bool

The closedness flag

static CombinedCenter(objects)[ソース]

Calculates the center of mass of multiple objects.

パラメータ

objects (Iterable[Shape]) -- A list of objects with mass

Vector

static CombinedCenterOfBoundBox(objects)[ソース]

Calculates the center of a bounding box of multiple objects.

パラメータ

objects (List[Shape]) -- A list of objects

Vector

CompSolids()[ソース]

List[CompSolid]

All the compsolids in this Shape

Compounds()[ソース]

List[Compound]

All the compounds in this Shape

Edges()[ソース]

List[Edge]

All the edges in this Shape

Faces()[ソース]

List[Face]

All the faces in this Shape

Shells()[ソース]

List[Shell]

All the shells in this Shape

Solids()[ソース]

List[Solid]

All the solids in this Shape

Vertices()[ソース]

List[Vertex]

All the vertices in this Shape

Volume()[ソース]

float

The volume of this Shape

Wires()[ソース]

List[Wire]

All the wires in this Shape

__eq__(other)[ソース]

Return self==value.

bool

__hash__()[ソース]

Return hash(self).

int

__init__(obj)[ソース]

Initialize self. See help(type(self)) for accurate signature.

パラメータ

obj (TopoDS_Shape) --

__weakref__

list of weak references to the object (if defined)

classmethod cast(obj, forConstruction=False)[ソース]

Returns the right type of wrapper, given a OCCT object

パラメータ
• cls (Type[Shape]) --

• obj (TopoDS_Shape) --

• forConstruction (bool) --

Shape

static centerOfMass(obj)[ソース]

Calculates the center of 'mass' of an object.

パラメータ

obj (Shape) -- Compute the center of mass of this object

Vector

clean()[ソース]

Experimental clean using ShapeUpgrade

パラメータ

self (~T) --

~T

static computeMass(obj)[ソース]

Calculates the 'mass' of an object.

パラメータ

obj (Shape) -- Compute the mass of this object

float

copy()[ソース]

Creates a new object that is a copy of this object.

Shape

cut(*toCut)[ソース]

Remove the positional arguments from this Shape.

パラメータ

toCut (Shape) --

Shape

exportBrep(f)[ソース]

Export this shape to a BREP file

パラメータ

f (Union[str, BytesIO]) --

bool

exportStep(fileName)[ソース]

Export this shape to a STEP file

パラメータ

fileName (str) --

IFSelect_ReturnStatus

exportStl(fileName, tolerance=0.001, angularTolerance=0.1)[ソース]

Exports a shape to a specified STL file.

パラメータ
• fileName (fileName) -- The path and file name to write the STL output to.

• tolerance (float) -- A linear deflection setting which limits the distance between a curve and its tessellation. Setting this value too low will result in large meshes that can consume computing resources. Setting the value too high can result in meshes with a level of detail that is too low. Default is 0.1, which is good starting point for a range of cases.

• angularTolerance (float) --

• Angular deflection setting which limits the angle between subsequent segments in a polyline. Default is 0.1.

bool

facesIntersectedByLine(point, axis, tol=0.0001, direction=None)[ソース]

Computes the intersections between the provided line and the faces of this Shape

Point

Base point for defining a line

Axis

Axis on which the line rest

Tol

Intersection tolerance

Direction

Valid values : "AlongAxis", "Opposite", if specified will ignore all faces that are not in the specified direction

including the face where the :point: lies if it is the case

A list of intersected faces sorted by distance from :point:

パラメータ
• point (Union[Vector, Tuple[float, float, float]]) --

• axis (Union[Vector, Tuple[float, float, float]]) --

• tol (float) --

• direction (Optional[Literal['AlongAxis', 'Opposite']]) --

fix()[ソース]

Try to fix shape if not valid

パラメータ

self (~T) --

~T

fuse(*toFuse, glue=False, tol=None)[ソース]

Fuse the positional arguments with this Shape.

パラメータ
• glue (bool) -- Sets the glue option for the algorithm, which allows increasing performance of the intersection of the input shapes

• tol (Optional[float]) -- Additional tolerance

• toFuse (Shape) --

Shape

geomType()[ソース]

Gets the underlying geometry type.

Implementations can return any values desired, but the values the user uses in type filters should correspond to these.

As an example, if a user does:

CQ(object).faces("%mytype")


The expectation is that the geomType attribute will return 'mytype'

The return values depend on the type of the shape:

Vertex: always 'Vertex'
Edge: LINE, ARC, CIRCLE, SPLINE
Face: PLANE, SPHERE, CONE
Solid: 'Solid'
Shell: 'Shell'
Compound: 'Compound'
Wire: 'Wire'

Literal['Vertex', 'Wire', 'Shell', 'Solid', 'Compound', 'PLANE', 'CYLINDER', 'CONE', 'SPHERE', 'TORUS', 'BEZIER', 'BSPLINE', 'REVOLUTION', 'EXTRUSION', 'OFFSET', 'OTHER', 'LINE', 'CIRCLE', 'ELLIPSE', 'HYPERBOLA', 'PARABOLA']

A string according to the geometry type

hashCode()[ソース]

Returns a hashed value denoting this shape. It is computed from the TShape and the Location. The Orientation is not used.

int

classmethod importBrep(f)[ソース]

Import shape from a BREP file

パラメータ

f (Union[str, BytesIO]) --

Shape

intersect(*toIntersect)[ソース]

Intersection of the positional arguments and this Shape.

パラメータ

toIntersect (Shape) --

Shape

isEqual(other)[ソース]

Returns True if two shapes are equal, i.e. if they share the same TShape with the same Locations and Orientations. Also see isSame().

パラメータ

other (Shape) --

bool

isNull()[ソース]

Returns true if this shape is null. In other words, it references no underlying shape with the potential to be given a location and an orientation.

bool

isSame(other)[ソース]

Returns True if other and this shape are same, i.e. if they share the same TShape with the same Locations. Orientations may differ. Also see isEqual()

パラメータ

other (Shape) --

bool

isValid()[ソース]

Returns True if no defect is detected on the shape S or any of its subshapes. See the OCCT docs on BRepCheck_Analyzer::IsValid for a full description of what is checked.

bool

locate(loc)[ソース]

Apply a location in absolute sense to self

パラメータ
• self (~T) --

• loc (Location) --

~T

located(loc)[ソース]

Apply a location in absolute sense to a copy of self

パラメータ

loc (Location) --

Shape

location()[ソース]

Return the current location

Location

mesh(tolerance, angularTolerance=0.1)[ソース]

Generate triangulation if none exists.

パラメータ
• tolerance (float) --

• angularTolerance (float) --

mirror(mirrorPlane='XY', basePointVector=0, 0, 0)[ソース]

Applies a mirror transform to this Shape. Does not duplicate objects about the plane.

パラメータ
• mirrorPlane (Union[Literal['XY', 'YX', 'XZ', 'ZX', 'YZ', 'ZY'], Vector, Tuple[float, float, float]]) -- The direction of the plane to mirror about - one of 'XY', 'XZ' or 'YZ'

• basePointVector (Union[Vector, Tuple[float, float, float]]) -- The origin of the plane to mirror about

Shape

The mirrored shape

move(loc)[ソース]

Apply a location in relative sense (i.e. update current location) to self

パラメータ
• self (~T) --

• loc (Location) --

~T

moved(loc)[ソース]

Apply a location in relative sense (i.e. update current location) to a copy of self

パラメータ

loc (Location) --

Shape

rotate(startVector, endVector, angleDegrees)[ソース]

Rotates a shape around an axis.

パラメータ
• startVector (either a 3-tuple or a Vector) -- start point of rotation axis

• endVector (either a 3-tuple or a Vector) -- end point of rotation axis

• angleDegrees (float) -- angle to rotate, in degrees

• self (~T) --

~T

a copy of the shape, rotated

scale(factor)[ソース]

Scales this shape through a transformation.

パラメータ

factor (float) --

Shape

split(*splitters)[ソース]

Split this shape with the positional arguments.

パラメータ

splitters (Shape) --

Shape

toVtkPolyData(tolerance, angularTolerance=0.1, normals=True)[ソース]

Convert shape to vtkPolyData

パラメータ
• tolerance (float) --

• angularTolerance (float) --

• normals (bool) --

vtkPolyData

transformGeometry(tMatrix)[ソース]

Transforms this shape by tMatrix.

WARNING: transformGeometry will sometimes convert lines and circles to splines, but it also has the ability to handle skew and stretching transformations.

If your transformation is only translation and rotation, it is safer to use transformShape(), which doesn't change the underlying type of the geometry, but cannot handle skew transformations.

パラメータ

tMatrix (Matrix) -- The transformation matrix

Shape

a copy of the object, but with geometry transformed instead of just rotated.

transformShape(tMatrix)[ソース]

Transforms this Shape by tMatrix. Also see transformGeometry().

パラメータ

tMatrix (Matrix) -- The transformation matrix

Shape

a copy of the object, transformed by the provided matrix, with all objects keeping their type

translate(vector)[ソース]

Translates this shape through a transformation.

パラメータ
• self (~T) --

• vector (Vector) --

~T

class cadquery.Shell(obj)[ソース]

ベースクラス: cadquery.occ_impl.shapes.Shape

the outer boundary of a surface

パラメータ

obj (TopoDS_Shape) --

class cadquery.Solid(obj)[ソース]

ベースクラス: cadquery.occ_impl.shapes.Shape, cadquery.occ_impl.shapes.Mixin3D

a single solid

パラメータ

obj (TopoDS_Shape) --

classmethod extrudeLinear(outerWire, innerWires, vecNormal, taper=0)[ソース]

Attempt to extrude the list of wires into a prismatic solid in the provided direction

パラメータ
• outerWire (Wire) -- the outermost wire

• innerWires (List[Wire]) -- a list of inner wires

• vecNormal (Vector) -- a vector along which to extrude the wires

• taper (float) -- taper angle, default=0

Solid

a Solid object

The wires must not intersect

Extruding wires is very non-trivial. Nested wires imply very different geometry, and there are many geometries that are invalid. In general, the following conditions must be met:

• all wires must be closed

• there cannot be any intersecting or self-intersecting wires

• wires must be listed from outside in

• more than one levels of nesting is not supported reliably

This method will attempt to sort the wires, but there is much work remaining to make this method reliable.

パラメータ

cls (Type[Solid]) --

classmethod extrudeLinearWithRotation(outerWire, innerWires, vecCenter, vecNormal, angleDegrees)[ソース]

Creates a 'twisted prism' by extruding, while simultaneously rotating around the extrusion vector.

Though the signature may appear to be similar enough to extrudeLinear to merit combining them, the construction methods used here are different enough that they should be separate.

At a high level, the steps followed are: (1) accept a set of wires (2) create another set of wires like this one, but which are transformed and rotated (3) create a ruledSurface between the sets of wires (4) create a shell and compute the resulting object

パラメータ
• outerWire (Wire) -- the outermost wire, a cad.Wire

• innerWires (List[Wire]) -- a list of inner wires, a list of cad.Wire

• vecCenter (Vector) -- the center point about which to rotate. the axis of rotation is defined by vecNormal, located at vecCenter. ( a cad.Vector )

• vecNormal (Vector) -- a vector along which to extrude the wires ( a cad.Vector )

• angleDegrees (float) -- the angle to rotate through while extruding

• cls (Type[Solid]) --

Solid

classmethod interpPlate(surf_edges, surf_pts, thickness, degree=3, nbPtsOnCur=15, nbIter=2, anisotropy=False, tol2d=1e-05, tol3d=0.0001, tolAng=0.01, tolCurv=0.1, maxDeg=8, maxSegments=9)[ソース]

Returns a plate surface that is 'thickness' thick, enclosed by 'surf_edge_pts' points, and going through 'surf_pts' points.

:param surf_edges :type 1 surf_edges: list of [x,y,z] float ordered coordinates :type 2 surf_edges: list of ordered or unordered CadQuery wires :param surf_pts = [] (uses only edges if []) :type surf_pts: list of [x,y,z] float coordinates :param thickness = 0 (returns 2D surface if 0) :type thickness: float (may be negative or positive depending on thickening direction) :param Degree = 3 (OCCT default) :type Degree: Integer >= 2 :param NbPtsOnCur = 15 (OCCT default) :type: NbPtsOnCur Integer >= 15 :param NbIter = 2 (OCCT default) :type: NbIterInteger >= 2 :param Anisotropie = False (OCCT default) :type Anisotropie: Boolean :param: Tol2d = 0.00001 (OCCT default) :type Tol2d: float > 0 :param Tol3d = 0.0001 (OCCT default) :type Tol3dReal: float > 0 :param TolAng = 0.01 (OCCT default) :type TolAngReal: float > 0 :param TolCurv = 0.1 (OCCT default) :type TolCurvReal: float > 0 :param MaxDeg = 8 (OCCT default) :type MaxDegInteger: Integer >= 2 (?) :param MaxSegments = 9 (OCCT default) :type MaxSegments: Integer >= 2 (?)

パラメータ

cls (Type[Solid]) --

Union[Solid, Face]

static isSolid(obj)[ソース]

Returns true if the object is a solid, false otherwise

パラメータ

obj (Shape) --

bool

classmethod makeBox(length, width, height, pnt=Vector: (0.0, 0.0, 0.0), dir=Vector: (0.0, 0.0, 1.0))[ソース]

By default pnt=Vector(0,0,0) and dir=Vector(0,0,1)'

パラメータ
• cls (Type[Solid]) --

• length (float) --

• width (float) --

• height (float) --

• pnt (Vector) --

• dir (Vector) --

Solid

classmethod makeCone(radius1, radius2, height, pnt=Vector: (0.0, 0.0, 0.0), dir=Vector: (0.0, 0.0, 1.0), angleDegrees=360)[ソース]

Make a cone with given radii and height By default pnt=Vector(0,0,0), dir=Vector(0,0,1) and angle=360'

パラメータ
• cls (Type[Solid]) --

• radius1 (float) --

• radius2 (float) --

• height (float) --

• pnt (Vector) --

• dir (Vector) --

• angleDegrees (float) --

Solid

classmethod makeCylinder(radius, height, pnt=Vector: (0.0, 0.0, 0.0), dir=Vector: (0.0, 0.0, 1.0), angleDegrees=360)[ソース]

makeCylinder(radius,height,[pnt,dir,angle]) -- Make a cylinder with a given radius and height By default pnt=Vector(0,0,0),dir=Vector(0,0,1) and angle=360'

パラメータ
• cls (Type[Solid]) --

• radius (float) --

• height (float) --

• pnt (Vector) --

• dir (Vector) --

• angleDegrees (float) --

Solid

classmethod makeLoft(listOfWire, ruled=False)[ソース]

makes a loft from a list of wires The wires will be converted into faces when possible-- it is presumed that nobody ever actually wants to make an infinitely thin shell for a real FreeCADPart.

パラメータ
• cls (Type[Solid]) --

• listOfWire (List[Wire]) --

• ruled (bool) --

Solid

classmethod makeSphere(radius, pnt=Vector: (0.0, 0.0, 0.0), dir=Vector: (0.0, 0.0, 1.0), angleDegrees1=0, angleDegrees2=90, angleDegrees3=360)[ソース]

Make a sphere with a given radius By default pnt=Vector(0,0,0), dir=Vector(0,0,1), angle1=0, angle2=90 and angle3=360

パラメータ
• cls (Type[Solid]) --

• radius (float) --

• pnt (Vector) --

• dir (Vector) --

• angleDegrees1 (float) --

• angleDegrees2 (float) --

• angleDegrees3 (float) --

Shape

classmethod makeTorus(radius1, radius2, pnt=Vector: (0.0, 0.0, 0.0), dir=Vector: (0.0, 0.0, 1.0), angleDegrees1=0, angleDegrees2=360)[ソース]

makeTorus(radius1,radius2,[pnt,dir,angle1,angle2,angle]) -- Make a torus with a given radii and angles By default pnt=Vector(0,0,0),dir=Vector(0,0,1),angle1=0 ,angle1=360 and angle=360'

パラメータ
• cls (Type[Solid]) --

• radius1 (float) --

• radius2 (float) --

• pnt (Vector) --

• dir (Vector) --

• angleDegrees1 (float) --

• angleDegrees2 (float) --

Solid

classmethod makeWedge(dx, dy, dz, xmin, zmin, xmax, zmax, pnt=Vector: (0.0, 0.0, 0.0), dir=Vector: (0.0, 0.0, 1.0))[ソース]

Make a wedge located in pnt By default pnt=Vector(0,0,0) and dir=Vector(0,0,1)

パラメータ
• cls (Type[Solid]) --

• dx (float) --

• dy (float) --

• dz (float) --

• xmin (float) --

• zmin (float) --

• xmax (float) --

• zmax (float) --

• pnt (Vector) --

• dir (Vector) --

Solid

classmethod revolve(outerWire, innerWires, angleDegrees, axisStart, axisEnd)[ソース]

Attempt to revolve the list of wires into a solid in the provided direction

パラメータ
• outerWire (Wire) -- the outermost wire

• innerWires (List[Wire]) -- a list of inner wires

• angleDegrees (float, anything less than 360 degrees will leave the shape open) -- the angle to revolve through.

• axisStart (tuple, a two tuple) -- the start point of the axis of rotation

• axisEnd (tuple, a two tuple) -- the end point of the axis of rotation

Solid

a Solid object

The wires must not intersect

• all wires must be closed

• there cannot be any intersecting or self-intersecting wires

• wires must be listed from outside in

• more than one levels of nesting is not supported reliably

• the wire(s) that you're revolving cannot be centered

This method will attempt to sort the wires, but there is much work remaining to make this method reliable.

パラメータ

cls (Type[Solid]) --

classmethod sweep(outerWire, innerWires, path, makeSolid=True, isFrenet=False, mode=None, transitionMode='transformed')[ソース]

Attempt to sweep the list of wires into a prismatic solid along the provided path

パラメータ
• outerWire (Wire) -- the outermost wire

• innerWires (List[Wire]) -- a list of inner wires

• path (Union[Wire, Edge]) -- The wire to sweep the face resulting from the wires over

• makeSolid (bool) -- return Solid or Shell (default True)

• isFrenet (bool) -- Frenet mode (default False)

• mode (Union[Vector, Wire, Edge, None]) -- additional sweep mode parameters.

• transitionMode (Literal['transformed', 'round', 'right']) -- handling of profile orientation at C1 path discontinuities. Possible values are {'transformed','round', 'right'} (default: 'right').

• cls (Type[Solid]) --

• makeSolid --

• isFrenet --

Shape

a Solid object

classmethod sweep_multi(profiles, path, makeSolid=True, isFrenet=False, mode=None)[ソース]

Multi section sweep. Only single outer profile per section is allowed.

パラメータ
• profiles (List[Wire]) -- list of profiles

• path (Union[Wire, Edge]) -- The wire to sweep the face resulting from the wires over

• mode (Union[Vector, Wire, Edge, None]) -- additional sweep mode parameters.

• cls (Type[Solid]) --

• makeSolid (bool) --

• isFrenet (bool) --

Solid

a Solid object

class cadquery.StringSyntaxSelector(selectorString)[ソース]

Filter lists objects using a simple string syntax. All of the filters available in the string syntax are also available ( usually with more functionality ) through the creation of full-fledged selector objects. see Selector and its subclasses

Filtering works differently depending on the type of object list being filtered.

パラメータ

selectorString -- A two-part selector string, [selector][axis]

objects that match the specified selector

*Modifiers* are ('|','+','-','<','>','%')

|

parallel to ( same as ParallelDirSelector ). Can return multiple objects.

#

perpendicular to (same as PerpendicularDirSelector )

+

positive direction (same as DirectionSelector )

-

negative direction (same as DirectionSelector )

>

maximize (same as DirectionMinMaxSelector with directionMax=True)

<

minimize (same as DirectionMinMaxSelector with directionMax=False )

%

curve/surface type (same as TypeSelector)

*axisStrings* are: X,Y,Z,XY,YZ,XZ or (x,y,z) which defines an arbitrary direction

It is possible to combine simple selectors together using logical operations. The following operations are supported

and

Logical AND, e.g. >X and >Y

or

Logical OR, e.g. |X or |Y

not

Logical NOT, e.g. not #XY

exc(ept)

Set difference (equivalent to AND NOT): |X exc >Z

Finally, it is also possible to use even more complex expressions with nesting and arbitrary number of terms, e.g.

(not >X[0] and #XY) or >XY[0]

Selectors are a complex topic: see String Selectors Reference for more information

__init__(selectorString)[ソース]

Feed the input string through the parser and construct an relevant complex selector object

filter(objectList)[ソース]

Filter give object list through th already constructed complex selector object

class cadquery.TypeSelector(typeString)[ソース]

Selects objects having the prescribed geometry type.

Applicability:

Faces: PLANE, CYLINDER, CONE, SPHERE, TORUS, BEZIER, BSPLINE, REVOLUTION, EXTRUSION, OFFSET, OTHER Edges: LINE, CIRCLE, ELLIPSE, HYPERBOLA, PARABOLA, BEZIER, BSPLINE, OFFSET, OTHER

You can use the string selector syntax. For example this:

CQ(aCube).faces ( TypeSelector("PLANE") )


will select 6 faces, and is equivalent to:

CQ(aCube).faces( "%PLANE" )

パラメータ

typeString (str) --

__init__(typeString)[ソース]

Initialize self. See help(type(self)) for accurate signature.

パラメータ

typeString (str) --

filter(objectList)[ソース]

Filter the provided list.

The default implementation returns the original list unfiltered. :type objectList: Sequence[Shape] :param objectList: list to filter :type objectList: list of OCCT primitives :rtype: List[Shape] :return: filtered list

class cadquery.Vector(x: float, y: float, z: float)[ソース]
class cadquery.Vector(x: float, y: float)
class cadquery.Vector(v: cadquery.occ_impl.geom.Vector)
class cadquery.Vector(v: Sequence[float])
class cadquery.Vector(v: Union[OCP.gp.gp_Vec, OCP.gp.gp_Pnt, OCP.gp.gp_Dir, OCP.gp.gp_XYZ])
class cadquery.Vector

ベースクラス: object

Create a 3-dimensional vector

パラメータ

args -- a 3D vector, with x-y-z parts.

you can either provide:
• nothing (in which case the null vector is return)

• a gp_Vec

• a vector ( in which case it is copied )

• a 3-tuple

• a 2-tuple (z assumed to be 0)

• three float values: x, y, and z

• two float values: x,y

Center()[ソース]

Return the vector itself

The center of myself is myself. Provided so that vectors, vertices, and other shapes all support a common interface, when Center() is requested for all objects on the stack.

Vector

__eq__(other)[ソース]

Return self==value.

パラメータ

other (Vector) --

bool

__init__(x: float, y: float, z: float) → None[ソース]
__init__(x: float, y: float) → None
__init__(v: cadquery.occ_impl.geom.Vector) → None
__init__(v: Sequence[float]) → None
__init__(v: Union[OCP.gp.gp_Vec, OCP.gp.gp_Pnt, OCP.gp.gp_Dir, OCP.gp.gp_XYZ]) → None
__init__() → None

Initialize self. See help(type(self)) for accurate signature.

__repr__()[ソース]

Return repr(self).

str

__str__()[ソース]

Return str(self).

str

__weakref__

list of weak references to the object (if defined)

multiply(scale)[ソース]

Return a copy multiplied by the provided scalar

パラメータ

scale (float) --

Vector

normalized()[ソース]

Return a normalized version of this vector

Vector

projectToLine(line)[ソース]

Returns a new vector equal to the projection of this Vector onto the line represented by Vector <line>

パラメータ

args -- Vector

Returns the projected vector.

パラメータ

line (Vector) --

Vector

projectToPlane(plane)[ソース]

Vector is projected onto the plane provided as input.

パラメータ

args -- Plane object

Returns the projected vector.

パラメータ

plane (Plane) --

Vector

class cadquery.Vertex(obj, forConstruction=False)[ソース]

ベースクラス: cadquery.occ_impl.shapes.Shape

A Single Point in Space

パラメータ
• obj (TopoDS_Shape) --

• forConstruction (bool) --

Center()[ソース]

The center of a vertex is itself!

Vector

__init__(obj, forConstruction=False)[ソース]

Create a vertex from a FreeCAD Vertex

パラメータ
• obj (TopoDS_Shape) --

• forConstruction (bool) --

class cadquery.Wire(obj)[ソース]

ベースクラス: cadquery.occ_impl.shapes.Shape, cadquery.occ_impl.shapes.Mixin1D

A series of connected, ordered Edges, that typically bounds a Face

パラメータ

obj (TopoDS_Shape) --

classmethod assembleEdges(listOfEdges)[ソース]

Attempts to build a wire that consists of the edges in the provided list :type cls: Type[Wire] :param cls: :type listOfEdges: Iterable[Edge] :param listOfEdges: a list of Edge objects. The edges are not to be consecutive. :rtype: Wire :return: a wire with the edges assembled :BRepBuilderAPI_MakeWire::Error() values

:BRepBuilderAPI_WireDone = 0 :BRepBuilderAPI_EmptyWire = 1 :BRepBuilderAPI_DisconnectedWire = 2 :BRepBuilderAPI_NonManifoldWire = 3

chamfer2D(d, vertices)[ソース]

Apply 2D chamfer to a wire

パラメータ
• d (float) --

• vertices (Iterable[Vertex]) --

Wire

close()[ソース]

Close a Wire

Wire

classmethod combine(listOfWires, tol=1e-09)[ソース]

Attempt to combine a list of wires and edges into a new wire. :type cls: Type[Wire] :param cls: :type listOfWires: Iterable[Union[Wire, Edge]] :param listOfWires: :type tol: float :param tol: default 1e-9 :rtype: List[Wire] :return: List[Wire]

fillet2D(radius, vertices)[ソース]

Apply 2D fillet to a wire

パラメータ
• radius (float) --

• vertices (Iterable[Vertex]) --

Wire

classmethod makeCircle(radius, center, normal)[ソース]

Makes a Circle centered at the provided point, having normal in the provided direction :type radius: float :param radius: floating point radius of the circle, must be > 0 :type center: Vector :param center: vector representing the center of the circle :type normal: Vector :param normal: vector representing the direction of the plane the circle should lie in :rtype: Wire :return:

パラメータ

cls (Type[Wire]) --

classmethod makeEllipse(x_radius, y_radius, center, normal, xDir, angle1=360.0, angle2=360.0, rotation_angle=0.0, closed=True)[ソース]

Makes an Ellipse centered at the provided point, having normal in the provided direction :type x_radius: float :param x_radius: floating point major radius of the ellipse (x-axis), must be > 0 :type y_radius: float :param y_radius: floating point minor radius of the ellipse (y-axis), must be > 0 :type center: Vector :param center: vector representing the center of the circle :type normal: Vector :param normal: vector representing the direction of the plane the circle should lie in :type angle1: float :param angle1: start angle of arc :type angle2: float :param angle2: end angle of arc :type rotation_angle: float :param rotation_angle: angle to rotate the created ellipse / arc :rtype: Wire :return: Wire

パラメータ
• cls (Type[Wire]) --

• xDir (Vector) --

• closed (bool) --

classmethod makeHelix(pitch, height, radius, center=Vector: (0.0, 0.0, 0.0), dir=Vector: (0.0, 0.0, 1.0), angle=360.0, lefthand=False)[ソース]

Make a helix with a given pitch, height and radius By default a cylindrical surface is used to create the helix. If the fourth parameter is set (the apex given in degree) a conical surface is used instead'

パラメータ
• cls (Type[Wire]) --

• pitch (float) --

• height (float) --

• radius (float) --

• center (Vector) --

• dir (Vector) --

• angle (float) --

• lefthand (bool) --

Wire

offset2D(d, kind='arc')[ソース]

Offsets a planar wire

パラメータ
• d (float) --

• kind (Literal['arc', 'intersection', 'tangent']) --

List[Wire]

stitch(other)[ソース]

Attempt to stich wires

パラメータ

other (Wire) --

Wire

class cadquery.Workplane(obj: Union[cadquery.occ_impl.geom.Vector, cadquery.occ_impl.geom.Location, cadquery.occ_impl.shapes.Shape])[ソース]
class cadquery.Workplane(inPlane: Union[cadquery.occ_impl.geom.Plane, str] = "'XY'", origin: Union[Tuple[float, float], Tuple[float, float, float], cadquery.occ_impl.geom.Vector] = '0, 0, 0', obj: Optional[Union[cadquery.occ_impl.geom.Vector, cadquery.occ_impl.geom.Location, cadquery.occ_impl.shapes.Shape]] = 'None')

ベースクラス: object

Defines a coordinate system in space, in which 2D coordinates can be used.

パラメータ
• plane (a Plane object, or a string in (XY|YZ|XZ|front|back|top|bottom|left|right)) -- the plane in which the workplane will be done

• origin (a 3-tuple in global coordinates, or None to default to the origin) -- the desired origin of the new workplane

• obj (a CAD primitive, or None to use the centerpoint of the plane as the initial stack value.) -- an object to use initially for the stack

Raises

ValueError if the provided plane is not a plane, a valid named workplane

A Workplane object, with coordinate system matching the supplied plane.

The most common use is:

s = Workplane("XY")


After creation, the stack contains a single point, the origin of the underlying plane, and the current point is on the origin.

You can also create workplanes on the surface of existing faces using CQ.workplane()

__add__(toUnion)[ソース]

Syntactic sugar for union. Notice that r = a + b is equivalent to r = a.union(b) and r = a | b.

パラメータ
• self (~T) --

• toUnion (Union[Workplane, Solid, Compound]) --

~T

__and__(toUnion)[ソース]

Syntactic sugar for intersect. Notice that r = a & b is equivalent to r = a.intersect(b).

Example:

Box = Workplane("XY").box(1, 1, 1, centered=(False, False, False))
Sphere = Workplane("XY").sphere(1)
result = Box & Sphere

パラメータ
• self (~T) --

• toUnion (Union[Workplane, Solid, Compound]) --

~T

__init__(obj: Union[cadquery.occ_impl.geom.Vector, cadquery.occ_impl.geom.Location, cadquery.occ_impl.shapes.Shape]) → None[ソース]
__init__(inPlane: Union[cadquery.occ_impl.geom.Plane, str] = "'XY'", origin: Union[Tuple[float, float], Tuple[float, float, float], cadquery.occ_impl.geom.Vector] = '0, 0, 0', obj: Optional[Union[cadquery.occ_impl.geom.Vector, cadquery.occ_impl.geom.Location, cadquery.occ_impl.shapes.Shape]] = 'None') → None

make a workplane from a particular plane

パラメータ
• inPlane (a Plane object, or a string in (XY|YZ|XZ|front|back|top|bottom|left|right)) -- the plane in which the workplane will be done

• origin (a 3-tuple in global coordinates, or None to default to the origin) -- the desired origin of the new workplane

• obj (a CAD primitive, or None to use the centerpoint of the plane as the initial stack value.) -- an object to use initially for the stack

Raises

ValueError if the provided plane is not a plane, or one of XY|YZ|XZ

A Workplane object, with coordinate system matching the supplied plane.

The most common use is:

s = Workplane("XY")


After creation, the stack contains a single point, the origin of the underlying plane, and the current point is on the origin.

__or__(toUnion)[ソース]

Syntactic sugar for union. Notice that r = a | b is equivalent to r = a.union(b) and r = a + b.

Example:

Box = Workplane("XY").box(1, 1, 1, centered=(False, False, False))
Sphere = Workplane("XY").sphere(1)
result = Box | Sphere

パラメータ
• self (~T) --

• toUnion (Union[Workplane, Solid, Compound]) --

~T

__sub__(toUnion)[ソース]

Syntactic sugar for cut. Notice that r = a - b is equivalent to r = a.cut(b).

Example:

Box = Workplane("XY").box(1, 1, 1, centered=(False, False, False))
Sphere = Workplane("XY").sphere(1)
result = Box - Sphere

パラメータ
• self (~T) --

• toUnion (Union[Workplane, Solid, Compound]) --

~T

__weakref__

list of weak references to the object (if defined)

add(obj: cadquery.cq.Workplane) → T[ソース]
add(obj: Union[cadquery.occ_impl.geom.Vector, cadquery.occ_impl.geom.Location, cadquery.occ_impl.shapes.Shape]) → T
add(obj: Iterable[Union[cadquery.occ_impl.geom.Vector, cadquery.occ_impl.geom.Location, cadquery.occ_impl.shapes.Shape]]) → T

Adds an object or a list of objects to the stack

パラメータ

obj (a Workplane, CAD primitive, or list of CAD primitives) -- an object to add

a Workplane with the requested operation performed

If an Workplane object, the values of that object's stack are added. If a list of cad primitives, they are all added. If a single CAD primitive then it is added.

Used in rare cases when you need to combine the results of several CQ results into a single Workplane object. Shelling is one common example.

all()[ソース]

Return a list of all CQ objects on the stack.

useful when you need to operate on the elements individually.

Contrast with vals, which returns the underlying objects for all of the items on the stack

パラメータ

self (~T) --

List[~T]

box(length, width, height, centered=True, combine=True, clean=True)[ソース]

Return a 3d box with specified dimensions for each object on the stack.

パラメータ
• length (float > 0) -- box size in X direction

• width (float > 0) -- box size in Y direction

• height (float > 0) -- box size in Z direction

• centered (Union[bool, Tuple[bool, bool, bool]]) -- If True, the box will be centered around the reference point. If False, the corner of the box will be on the reference point and it will extend in the positive x, y and z directions. Can also use a 3-tuple to specify centering along each axis.

• combine (bool) -- should the results be combined with other solids on the stack (and each other)?

• clean (bool) -- call clean() afterwards to have a clean shape

One box is created for each item on the current stack. If no items are on the stack, one box using the current workplane center is created.

If combine is true, the result will be a single object on the stack. If a solid was found in the chain, the result is that solid with all boxes produced fused onto it otherwise, the result is the combination of all the produced boxes.

If combine is false, the result will be a list of the boxes produced.

Most often boxes form the basis for a part:

# make a single box with lower left corner at origin
s = Workplane().box(1, 2, 3, centered=False)


But sometimes it is useful to create an array of them:

# create 4 small square bumps on a larger base plate:
s = (
Workplane().
box(4, 4, 0.5).
faces(">Z").
workplane().
rect(3, 3, forConstruction=True)
.vertices()
.box(0.25, 0.25, 0.25, combine=True)
)

パラメータ

self (~T) --

~T

cboreHole(diameter, cboreDiameter, cboreDepth, depth=None, clean=True)[ソース]

Makes a counterbored hole for each item on the stack.

パラメータ
• diameter (float > 0) -- the diameter of the hole

• cboreDiameter (float > 0 and > diameter) -- the diameter of the cbore

• cboreDepth (float > 0) -- depth of the counterbore

• depth (float > 0 or None to drill thru the entire part.) -- the depth of the hole

• clean (boolean) -- call clean() afterwards to have a clean shape

The surface of the hole is at the current workplane plane.

One hole is created for each item on the stack. A very common use case is to use a construction rectangle to define the centers of a set of holes, like so:

s = Workplane(Plane.XY()).box(2,4,0.5).faces(">Z").workplane()                    .rect(1.5,3.5,forConstruction=True)                    .vertices().cboreHole(0.125, 0.25,0.125,depth=None)


This sample creates a plate with a set of holes at the corners.

Plugin Note: this is one example of the power of plugins. Counterbored holes are quite time consuming to create, but are quite easily defined by users.

see cskHole() to make countersinks instead of counterbores

パラメータ
• self (~T) --

• clean (bool) --

~T

center(x, y)[ソース]

Shift local coordinates to the specified location.

The location is specified in terms of local coordinates.

パラメータ
• x (float) -- the new x location

• y (float) -- the new y location

~T

the workplane object, with the center adjusted.

The current point is set to the new center. This method is useful to adjust the center point after it has been created automatically on a face, but not where you'd like it to be.

In this example, we adjust the workplane center to be at the corner of a cube, instead of the center of a face, which is the default:

#this workplane is centered at x=0.5,y=0.5, the center of the upper face
s = Workplane().box(1,1,1).faces(">Z").workplane()

s = s.center(-0.5,-0.5) # move the center to the corner
t = s.circle(0.25).extrude(0.2)
assert ( t.faces().size() == 9 ) # a cube with a cylindrical nub at the top right corner


The result is a cube with a round boss on the corner

パラメータ
• self (~T) --

• x (float) --

• y (float) --

chamfer(length, length2=None)[ソース]

Chamfers a solid on the selected edges.

The edges on the stack are chamfered. The solid to which the edges belong must be in the parent chain of the selected edges.

Optional parameter length2 can be supplied with a different value than length for a chamfer that is shorter on one side longer on the other side.

パラメータ
• length (positive float) -- the length of the chamfer, must be greater than zero

• length2 (positive float) -- optional parameter for asymmetrical chamfer

• ValueError -- if at least one edge is not selected

• ValueError -- if the solid containing the edge is not in the chain

~T

cq object with the resulting solid selected.

This example will create a unit cube, with the top edges chamfered:

s = Workplane("XY").box(1,1,1).faces("+Z").chamfer(0.1)


This example will create chamfers longer on the sides:

s = Workplane("XY").box(1,1,1).faces("+Z").chamfer(0.2, 0.1)

パラメータ

self (~T) --

circle(radius, forConstruction=False)[ソース]

Make a circle for each item on the stack.

パラメータ
• radius (float > 0) -- radius of the circle

• forConstruction (true if the wires are for reference, false if they are creating part geometry) -- should the new wires be reference geometry only?

~T

a new CQ object with the created wires on the stack

A common use case is to use a for-construction rectangle to define the centers of a hole pattern:

s = Workplane().rect(4.0,4.0,forConstruction=True).vertices().circle(0.25)


Creates 4 circles at the corners of a square centered on the origin. Another common case is to use successive circle() calls to create concentric circles. This works because the center of a circle is its reference point:

s = Workplane().circle(2.0).circle(1.0)


Creates two concentric circles, which when extruded will form a ring.

Future Enhancements:

better way to handle forConstruction project points not in the workplane plane onto the workplane plane

パラメータ

self (~T) --

clean()[ソース]

Cleans the current solid by removing unwanted edges from the faces.

Normally you don't have to call this function. It is automatically called after each related operation. You can disable this behavior with clean=False parameter if method has any. In some cases this can improve performance drastically but is generally dis-advised since it may break some operations such as fillet.

Note that in some cases where lots of solid operations are chained, clean() may actually improve performance since the shape is 'simplified' at each step and thus next operation is easier.

Also note that, due to limitation of the underlying engine, clean may fail to produce a clean output in some cases such as spherical faces.

パラメータ

self (~T) --

~T

close()[ソース]

End 2D construction, and attempt to build a closed wire.

~T

a CQ object with a completed wire on the stack, if possible.

After 2D drafting with methods such as lineTo, threePointArc, tangentArcPoint and polyline, it is necessary to convert the edges produced by these into one or more wires.

When a set of edges is closed, cadQuery assumes it is safe to build the group of edges into a wire. This example builds a simple triangular prism:

s = Workplane().lineTo(1,0).lineTo(1,1).close().extrude(0.2)

パラメータ

self (~T) --

combine(clean=True, glue=False, tol=None)[ソース]

Attempts to combine all of the items on the stack into a single item. WARNING: all of the items must be of the same type!

パラメータ
• clean (bool) -- call clean() afterwards to have a clean shape

• glue (bool) -- use a faster gluing mode for non-overlapping shapes (default False)

• tol (Optional[float]) -- tolerance value for fuzzy bool operation mode (default None)

• self (~T) --

• clean --

• glue --

• tol --

Raises

ValueError if there are no items on the stack, or if they cannot be combined

~T

a CQ object with the resulting object selected

combineSolids(otherCQToCombine=None)[ソース]

!!!DEPRECATED!!! use union() Combines all solids on the current stack, and any context object, together into a single object.

After the operation, the returned solid is also the context solid.

パラメータ

otherCQToCombine (Optional[Workplane]) -- another CadQuery to combine.

Workplane

a cQ object with the resulting combined solid on the stack.

Most of the time, both objects will contain a single solid, which is combined and returned on the stack of the new object.

compounds(selector=None, tag=None)[ソース]

Select compounds on the stack, optionally filtering the selection. If there are multiple objects on the stack, they are collected and a list of all the distinct compounds is returned.

パラメータ
• selector (None, a Selector object, or a string selector expression.) -- A selector

• tag (string) -- if set, search the tagged CQ object instead of self

~T

a CQ object who's stack contains all of the distinct solids of all objects on the current stack, filtered by the provided selector.

A compound contains multiple CAD primitives that resulted from a single operation, such as a union, cut, split, or fillet. Compounds can contain multiple edges, wires, or solids.

パラメータ

self (~T) --

consolidateWires()[ソース]

Attempt to consolidate wires on the stack into a single. If possible, a new object with the results are returned. if not possible, the wires remain separated

パラメータ

self (~T) --

~T

copyWorkplane(obj)[ソース]

Copies the workplane from obj.

パラメータ

obj (a CQ object) -- an object to copy the workplane from

~T

a CQ object with obj's workplane

cskHole(diameter, cskDiameter, cskAngle, depth=None, clean=True)[ソース]

Makes a countersunk hole for each item on the stack.

パラメータ
• diameter (float > 0) -- the diameter of the hole

• cskDiameter (float > 0 and > diameter) -- the diameter of the countersink

• cskAngle (float > 0) -- angle of the countersink, in degrees ( 82 is common )

• depth (float > 0 or None to drill thru the entire part.) -- the depth of the hole

• clean (boolean) -- call clean() afterwards to have a clean shape

The surface of the hole is at the current workplane.

One hole is created for each item on the stack. A very common use case is to use a construction rectangle to define the centers of a set of holes, like so:

s = Workplane(Plane.XY()).box(2,4,0.5).faces(">Z").workplane()                    .rect(1.5,3.5,forConstruction=True)                    .vertices().cskHole(0.125, 0.25,82,depth=None)


This sample creates a plate with a set of holes at the corners.

Plugin Note: this is one example of the power of plugins. CounterSunk holes are quite time consuming to create, but are quite easily defined by users.

see cboreHole() to make counterbores instead of countersinks

パラメータ
• self (~T) --

• clean (bool) --

~T

cut(toCut, clean=True)[ソース]

Cuts the provided solid from the current solid, IE, perform a solid subtraction

パラメータ
• toCut (a solid object, or a CQ object having a solid,) -- object to cut

• clean (bool) -- call clean() afterwards to have a clean shape

• self (~T) --

• clean --

ValueError -- if there is no solid to subtract from in the chain

~T

a CQ object with the resulting object selected

cutBlind(until, clean=True, taper=None)[ソース]

Use all un-extruded wires in the parent chain to create a prismatic cut from existing solid. You must define either :distance: , :untilNextFace: or :untilLastFace:

Similar to extrude, except that a solid in the parent chain is required to remove material from. cutBlind always removes material from a part.

パラメータ
• until (Union[float, Literal['next', 'last'], Face]) -- The distance to cut to, normal to the workplane plane. When a negative float is passed the cut extends this far in the opposite direction to the normal of the plane (i.e in the solid). The string "next" cuts until the next face orthogonal to the wire normal. "last" cuts to the last face. If a object of type Face is passed then the cut will extend until this face.

• clean (boolean) -- call clean() afterwards to have a clean shape

• taper (float) -- angle for optional tapered extrusion

ValueError -- if there is no solid to subtract from in the chain

~T

a CQ object with the resulting object selected

see cutThruAll() to cut material from the entire part

パラメータ
• self (~T) --

• clean (bool) --

• taper (Optional[float]) --

cutEach(fcn, useLocalCoords=False, clean=True)[ソース]

Evaluates the provided function at each point on the stack (ie, eachpoint) and then cuts the result from the context solid. :type fcn: Callable[[Location], Shape] :param fcn: a function suitable for use in the eachpoint method: ie, that accepts a vector :type useLocalCoords: bool :param useLocalCoords: same as for eachpoint() :param boolean clean: call clean() afterwards to have a clean shape :raises ValueError: if no solids or compounds are found in the stack or parent chain :rtype: ~T :return: a CQ object that contains the resulting solid

パラメータ
• self (~T) --

• clean (bool) --

cutThruAll(clean=True, taper=0)[ソース]

Use all un-extruded wires in the parent chain to create a prismatic cut from existing solid. Cuts through all material in both normal directions of workplane.

Similar to extrude, except that a solid in the parent chain is required to remove material from. cutThruAll always removes material from a part.

パラメータ

clean (boolean) -- call clean() afterwards to have a clean shape

• ValueError -- if there is no solid to subtract from in the chain

• ValueError -- if there are no pending wires to cut with

~T

a CQ object with the resulting object selected

see cutBlind() to cut material to a limited depth

パラメータ
• self (~T) --

• clean (bool) --

• taper (float) --

cylinder(height, radius, direct=Vector: (0.0, 0.0, 1.0), angle=360, centered=True, combine=True, clean=True)[ソース]

Returns a cylinder with the specified radius and height for each point on the stack

パラメータ
• height (float > 0) -- The height of the cylinder

• radius (float > 0) -- The radius of the cylinder

• direct (A three-tuple) -- The direction axis for the creation of the cylinder

• angle (float > 0) -- The angle to sweep the cylinder arc through

• centered (Union[bool, Tuple[bool, bool, bool]]) -- If True, the cylinder will be centered around the reference point. If False, the corner of a bounding box around the cylinder will be on the reference point and it will extend in the positive x, y and z directions. Can also use a 3-tuple to specify centering along each axis.

• combine (true to combine shapes, false otherwise) -- Whether the results should be combined with other solids on the stack (and each other)

• clean (bool) -- call clean() afterwards to have a clean shape

~T

A cylinder object for each point on the stack

One cylinder is created for each item on the current stack. If no items are on the stack, one cylinder is created using the current workplane center.

If combine is true, the result will be a single object on the stack. If a solid was found in the chain, the result is that solid with all cylinders produced fused onto it otherwise, the result is the combination of all the produced cylinders.

If combine is false, the result will be a list of the cylinders produced.

パラメータ

self (~T) --

each(callback, useLocalCoordinates=False)[ソース]

Runs the provided function on each value in the stack, and collects the return values into a new CQ object.

Special note: a newly created workplane always has its center point as its only stack item

パラメータ
• callBackFunction -- the function to call for each item on the current stack.

• useLocalCoordinates (boolean) -- should values be converted from local coordinates first?

The callback function must accept one argument, which is the item on the stack, and return one object, which is collected. If the function returns None, nothing is added to the stack. The object passed into the callBackFunction is potentially transformed to local coordinates, if useLocalCoordinates is true

useLocalCoordinates is very useful for plugin developers.

If false, the callback function is assumed to be working in global coordinates. Objects created are added as-is, and objects passed into the function are sent in using global coordinates

If true, the calling function is assumed to be working in local coordinates. Objects are transformed to local coordinates before they are passed into the callback method, and result objects are transformed to global coordinates after they are returned.

This allows plugin developers to create objects in local coordinates, without worrying about the fact that the working plane is different than the global coordinate system.

TODO: wrapper object for Wire will clean up forConstruction flag everywhere

パラメータ
• self (~T) --

• callback (Callable[[Union[Vector, Location, Shape]], Shape]) --

~T

eachpoint(callback, useLocalCoordinates=False)[ソース]

Same as each(), except each item on the stack is converted into a point before it is passed into the callback function.

~T

CadQuery object which contains a list of vectors (points ) on its stack.

パラメータ

useLocalCoordinates (boolean) -- should points be in local or global coordinates

The resulting object has a point on the stack for each object on the original stack. Vertices and points remain a point. Faces, Wires, Solids, Edges, and Shells are converted to a point by using their center of mass.

If the stack has zero length, a single point is returned, which is the center of the current workplane/coordinate system

パラメータ
• self (~T) --

• callback (Callable[[Location], Shape]) --

edges(selector=None, tag=None)[ソース]

Select the edges of objects on the stack, optionally filtering the selection. If there are multiple objects on the stack, the edges of all objects are collected and a list of all the distinct edges is returned.

パラメータ
• selector (None, a Selector object, or a string selector expression.) -- A selector

• tag (string) -- if set, search the tagged CQ object instead of self

~T

a CQ object who's stack contains all of the distinct edges of all objects on the current stack, filtered by the provided selector.

If there are no edges for any objects on the current stack, an empty CQ object is returned

The typical use is to select the edges of a single object on the stack. For example:

CQ(aCube).faces("+Z").edges().size()


returns 4, because a cube has one face with a normal in the +Z direction. Similarly:

CQ(aCube).edges().size()


returns 12, because a cube has a total of 12 edges, And:

CQ(aCube).edges("|Z").size()


returns 4, because a cube has 4 edges parallel to the z direction

パラメータ

self (~T) --

ellipse(x_radius, y_radius, rotation_angle=0.0, forConstruction=False)[ソース]

Make an ellipse for each item on the stack.

パラメータ
• x_radius (float > 0) -- x radius of the ellipse (x-axis of plane the ellipse should lie in)

• y_radius (float > 0) -- y radius of the ellipse (y-axis of plane the ellipse should lie in)

• rotation_angle (float) -- angle to rotate the ellipse (0 = no rotation = default)

• forConstruction (true if the wires are for reference, false if they are creating part geometry) -- should the new wires be reference geometry only?

~T

a new CQ object with the created wires on the stack

NOTE Due to a bug in opencascade (https://tracker.dev.opencascade.org/view.php?id=31290) the center of mass (equals center for next shape) is shifted. To create concentric ellipses use Workplane("XY")

.center(10, 20).ellipse(100,10) .center(0, 0).ellipse(50, 5)

パラメータ

self (~T) --

ellipseArc(x_radius, y_radius, angle1=360, angle2=360, rotation_angle=0.0, sense=1, forConstruction=False, startAtCurrent=True, makeWire=False)[ソース]

Draw an elliptical arc with x and y radiuses either with start point at current point or or current point being the center of the arc

パラメータ
• x_radius (float) -- x radius of the ellipse (along the x-axis of plane the ellipse should lie in)

• y_radius (float) -- y radius of the ellipse (along the y-axis of plane the ellipse should lie in)

• angle1 (float) -- start angle of arc

• angle2 (float) -- end angle of arc (angle2 == angle1 return closed ellipse = default)

• rotation_angle (float) -- angle to rotate the created ellipse / arc

• sense (Literal[-1, 1]) -- clockwise (-1) or counter clockwise (1)

• startAtCurrent (bool) -- True: start point of arc is moved to current point; False: center of arc is on current point

• makeWire (bool) -- convert the resulting arc edge to a wire

• self (~T) --

• forConstruction (bool) --

~T

end(n=1)[ソース]

Return the nth parent of this CQ element :type n: int :param n: number of ancestor to return (default: 1) :rtype: a CQ object :raises: ValueError if there are no more parents in the chain.

For example:

CQ(obj).faces("+Z").vertices().end()


will return the same as:

CQ(obj).faces("+Z")

exportSvg(fileName)[ソース]

Exports the first item on the stack as an SVG file

For testing purposes mainly.

パラメータ

fileName (String, absolute path to the file) -- the filename to export

None

extrude(until, combine=True, clean=True, both=False, taper=None)[ソース]

Use all un-extruded wires in the parent chain to create a prismatic solid.

パラメータ
• until (Union[float, Literal['next', 'last'], Face]) -- the distance to extrude, normal to the workplane plane

• until -- The distance to extrude, normal to the workplane plane. When a float is passed, the extrusion extends this far and a negative value is in the opposite direction to the normal of the plane. The string "next" extrudes until the next face orthogonal to the wire normal. "last" extrudes to the last face. If a object of type Face is passed then the extrusion will extend until this face.

• combine (boolean) -- True to combine the resulting solid with parent solids if found.

• clean (boolean) -- call clean() afterwards to have a clean shape

• both (boolean) -- extrude in both directions symmetrically

• taper (float) -- angle for optional tapered extrusion

~T

a CQ object with the resulting solid selected.

extrude always adds material to a part.

The returned object is always a CQ object, and depends on whether combine is True, and whether a context solid is already defined:

• if combine is False, the new value is pushed onto the stack. Note that when extruding

until a specified face, combine can not be False

• if combine is true, the value is combined with the context solid if it exists, and the resulting solid becomes the new context solid.

パラメータ
• self (~T) --

• combine (bool) --

• clean (bool) --

• both (bool) --

• taper (Optional[float]) --

faces(selector=None, tag=None)[ソース]

Select the faces of objects on the stack, optionally filtering the selection. If there are multiple objects on the stack, the faces of all objects are collected and a list of all the distinct faces is returned.

パラメータ
• selector (None, a Selector object, or a string selector expression.) -- A selector

• tag (string) -- if set, search the tagged CQ object instead of self

~T

a CQ object who's stack contains all of the distinct faces of all objects on the current stack, filtered by the provided selector.

If there are no vertices for any objects on the current stack, an empty CQ object is returned.

The typical use is to select the faces of a single object on the stack. For example:

CQ(aCube).faces("+Z").size()


returns 1, because a cube has one face with a normal in the +Z direction. Similarly:

CQ(aCube).faces().size()


returns 6, because a cube has a total of 6 faces, And:

CQ(aCube).faces("|Z").size()


returns 2, because a cube has 2 faces having normals parallel to the z direction

パラメータ

self (~T) --

fillet(radius)[ソース]

Fillets a solid on the selected edges.

The edges on the stack are filleted. The solid to which the edges belong must be in the parent chain of the selected edges.

パラメータ

radius (positive float) -- the radius of the fillet, must be > zero

• ValueError -- if at least one edge is not selected

• ValueError -- if the solid containing the edge is not in the chain

~T

cq object with the resulting solid selected.

This example will create a unit cube, with the top edges filleted:

s = Workplane().box(1,1,1).faces("+Z").edges().fillet(0.1)

パラメータ

self (~T) --

findFace(searchStack=True, searchParents=True)[ソース]

Finds the first face object in the chain, searching from the current node backwards through parents until one is found.

パラメータ
• searchStack (bool) -- should objects on the stack be searched first.

• searchParents (bool) -- should parents be searched?

Face

A face or None if no face is found.

findSolid(searchStack=True, searchParents=True)[ソース]

Finds the first solid object in the chain, searching from the current node backwards through parents until one is found.

パラメータ
• searchStack (bool) -- should objects on the stack be searched first?

• searchParents (bool) -- should parents be searched?

ValueError -- if no solid is found

This function is very important for chains that are modifying a single parent object, most often a solid.

Most of the time, a chain defines or selects a solid, and then modifies it using workplanes or other operations.

Plugin Developers should make use of this method to find the solid that should be modified, if the plugin implements a unary operation, or if the operation will automatically merge its results with an object already on the stack.

Union[Solid, Compound]

first()[ソース]

Return the first item on the stack :returns: the first item on the stack. :rtype: a CQ object

パラメータ

self (~T) --

hLine(distance, forConstruction=False)[ソース]

Make a horizontal line from the current point the provided distance

パラメータ
• distance (float) --

1. distance from current point

• self (~T) --

• distance --

• forConstruction (bool) --

~T

the Workplane object with the current point at the end of the new line

hLineTo(xCoord, forConstruction=False)[ソース]

Make a horizontal line from the current point to the provided x coordinate.

Useful if it is more convenient to specify the end location rather than distance, as in hLine()

パラメータ
• xCoord (float) -- x coordinate for the end of the line

• self (~T) --

• xCoord --

• forConstruction (bool) --

~T

the Workplane object with the current point at the end of the new line

hole(diameter, depth=None, clean=True)[ソース]

Makes a hole for each item on the stack.

パラメータ
• diameter (float > 0) -- the diameter of the hole

• depth (float > 0 or None to drill thru the entire part.) -- the depth of the hole

• clean (boolean) -- call clean() afterwards to have a clean shape

The surface of the hole is at the current workplane.

One hole is created for each item on the stack. A very common use case is to use a construction rectangle to define the centers of a set of holes, like so:

s = Workplane(Plane.XY()).box(2,4,0.5).faces(">Z").workplane()                    .rect(1.5,3.5,forConstruction=True)                    .vertices().hole(0.125, 0.25,82,depth=None)


This sample creates a plate with a set of holes at the corners.

Plugin Note: this is one example of the power of plugins. CounterSunk holes are quite time consuming to create, but are quite easily defined by users.

see cboreHole() and cskHole() to make counterbores or countersinks

パラメータ
• self (~T) --

• clean (bool) --

~T

interpPlate(surf_edges, surf_pts=[], thickness=0, combine=False, clean=True, degree=3, nbPtsOnCur=15, nbIter=2, anisotropy=False, tol2d=1e-05, tol3d=0.0001, tolAng=0.01, tolCurv=0.1, maxDeg=8, maxSegments=9)[ソース]

Returns a plate surface that is 'thickness' thick, enclosed by 'surf_edge_pts' points, and going through 'surf_pts' points. Using pushpoints directly with interpPlate and combine=True, can be very resources intensive depending on the complexity of the shape. In this case set combine=False.

:param surf_edges :type 1 surf_edges: list of [x,y,z] float ordered coordinates :type 2 surf_edges: list of ordered or unordered CadQuery wires :param surf_pts = [] (uses only edges if []) :type surf_pts: list of [x,y,z] float coordinates :param thickness = 0 (returns 2D surface if 0) :type thickness: float (may be negative or positive depending on thickening direction) :type combine: bool :param combine: should the results be combined with other solids on the stack

(and each other)?

パラメータ

clean (boolean) -- call clean() afterwards to have a clean shape

:param Degree = 3 (OCCT default) :type Degree: Integer >= 2 :param NbPtsOnCur = 15 (OCCT default) :type: NbPtsOnCur Integer >= 15 :param NbIter = 2 (OCCT default) :type: NbIterInteger >= 2 :param anisotropy = False (OCCT default) :type anisotropy: Boolean :param: Tol2d = 0.00001 (OCCT default) :type Tol2d: float > 0 :param Tol3d = 0.0001 (OCCT default) :type Tol3dReal: float > 0 :param TolAng = 0.01 (OCCT default) :type TolAngReal: float > 0 :param TolCurv = 0.1 (OCCT default) :type TolCurvReal: float > 0 :param MaxDeg = 8 (OCCT default) :type MaxDegInteger: Integer >= 2 (?) :param MaxSegments = 9 (OCCT default) :type MaxSegments: Integer >= 2 (?)

パラメータ
• self (~T) --

• surf_edges (Union[Sequence[Union[Tuple[float, float], Tuple[float, float, float], Vector]], Sequence[Edge]]) --

• surf_pts (Sequence[Union[Tuple[float, float], Tuple[float, float, float], Vector]]) --

• thickness (float) --

• clean (bool) --

• degree (int) --

• nbPtsOnCur (int) --

• nbIter (int) --

• anisotropy (bool) --

• tol2d (float) --

• tol3d (float) --

• tolAng (float) --

• tolCurv (float) --

• maxDeg (int) --

• maxSegments (int) --

~T

intersect(toIntersect, clean=True)[ソース]

Intersects the provided solid from the current solid.

パラメータ
• toIntersect (a solid object, or a CQ object having a solid,) -- object to intersect

• clean (bool) -- call clean() afterwards to have a clean shape

• self (~T) --

• clean --

ValueError -- if there is no solid to intersect with in the chain

~T

a CQ object with the resulting object selected

item(i)[ソース]

Return the ith item on the stack. :rtype: a CQ object

パラメータ
• self (~T) --

• i (int) --

largestDimension()[ソース]

Finds the largest dimension in the stack.

Used internally to create thru features, this is how you can compute how long or wide a feature must be to make sure to cut through all of the material

ValueError -- if no solids or compounds are found

float

A value representing the largest dimension of the first solid on the stack

last()[ソース]

Return the last item on the stack. :rtype: a CQ object

パラメータ

self (~T) --

line(xDist, yDist, forConstruction=False)[ソース]

Make a line from the current point to the provided point, using dimensions relative to the current point

パラメータ
• xDist (float) -- x distance from current point

• yDist (float) -- y distance from current point

~T

the workplane object with the current point at the end of the new line

see lineTo() if you want to use absolute coordinates to make a line instead.

パラメータ
• self (~T) --

• xDist (float) --

• yDist (float) --

• forConstruction (bool) --

lineTo(x, y, forConstruction=False)[ソース]

Make a line from the current point to the provided point

パラメータ
• x (float) -- the x point, in workplane plane coordinates

• y (float) -- the y point, in workplane plane coordinates

~T

the Workplane object with the current point at the end of the new line

see line() if you want to use relative dimensions to make a line instead.

パラメータ
• self (~T) --

• x (float) --

• y (float) --

• forConstruction (bool) --

loft(filled=True, ruled=False, combine=True)[ソース]

Make a lofted solid, through the set of wires. :rtype: ~T :return: a CQ object containing the created loft

パラメータ
• self (~T) --

• filled (bool) --

• ruled (bool) --

• combine (bool) --

mirror(mirrorPlane='XY', basePointVector=None, union=False)[ソース]

Mirror a single CQ object.

パラメータ

mirrorPlane (string, one of "XY", "YX", "XZ", "ZX", "YZ", "ZY" the planes) -- the plane to mirror about

or the normal vector of the plane eg (1,0,0) or a Face object :type basePointVector: Union[Tuple[float, float], Tuple[float, float, float], Vector, None] :param basePointVector: the base point to mirror about (this is overwritten if a Face is passed) :type basePointVector: tuple :type union: bool :param union: If true will perform a union operation on the mirrored object :type union: bool

パラメータ

self (~T) --

~T

mirrorX()[ソース]

Mirror entities around the x axis of the workplane plane.

~T

a new object with any free edges consolidated into as few wires as possible.

All free edges are collected into a wire, and then the wire is mirrored, and finally joined into a new wire

Typically used to make creating wires with symmetry easier.

パラメータ

self (~T) --

mirrorY()[ソース]

Mirror entities around the y axis of the workplane plane.

~T

a new object with any free edges consolidated into as few wires as possible.

All free edges are collected into a wire, and then the wire is mirrored, and finally joined into a new wire

Typically used to make creating wires with symmetry easier. This line of code:

s = Workplane().lineTo(2,2).threePointArc((3,1),(2,0)).mirrorX().extrude(0.25)


Produces a flat, heart shaped object

パラメータ

self (~T) --

move(xDist=0, yDist=0)[ソース]

Move the specified distance from the current point, without drawing.

パラメータ
• xDist (float, or none for zero) -- desired x distance, in local coordinates

• yDist (float, or none for zero.) -- desired y distance, in local coordinates

Not to be confused with center(), which moves the center of the entire workplane, this method only moves the current point ( and therefore does not affect objects already drawn ).

See moveTo() to do the same thing but using absolute coordinates

パラメータ

self (~T) --

~T

moveTo(x=0, y=0)[ソース]

Move to the specified point, without drawing.

パラメータ
• x (float, or none for zero) -- desired x location, in local coordinates

• y (float, or none for zero.) -- desired y location, in local coordinates

Not to be confused with center(), which moves the center of the entire workplane, this method only moves the current point ( and therefore does not affect objects already drawn ).

See move() to do the same thing but using relative dimensions

パラメータ

self (~T) --

~T

newObject(objlist)[ソース]

Create a new workplane object from this one.

Overrides CQ.newObject, and should be used by extensions, plugins, and subclasses to create new objects.

パラメータ
• objlist (a list of CAD primitives) -- new objects to put on the stack

• self (~T) --

~T

a new Workplane object with the current workplane as a parent.

offset2D(d, kind='arc', forConstruction=False)[ソース]

Creates a 2D offset wire.

パラメータ
• d (float) -- thickness. Negative thickness denotes offset to inside.

• kind (Literal['arc', 'intersection', 'tangent']) -- offset kind. Use "arc" for rounded and "intersection" for sharp edges (default: "arc")

• forConstruction (bool) -- Should the result be added to pending wires?

• self (~T) --

~T

CQ object with resulting wire(s).

parametricCurve(func, N=400, start=0, stop=1, tol=1e-06, minDeg=1, maxDeg=6, smoothing=1, 1, 1, makeWire=True)[ソース]

Create a spline curve approximating the provided function.

パラメータ
• func (float --> (float,float,float)) -- function f(t) that will generate (x,y,z) pairs

• N (int) -- number of points for discretization

• start (float) -- starting value of the parameter t

• stop (float) -- final value of the parameter t

• tol (float) -- tolerance of the algorithm (default: 1e-6)

• minDeg (int) -- minimum spline degree (default: 1)

• maxDeg (int) -- maximum spline degree (default: 6)

• smoothing (Optional[Tuple[float, float, float]]) -- optional parameters for the variational smoothing algorithm (default: (1,1,1))

• makeWire (bool) -- convert the resulting spline edge to a wire

• self (~T) --

~T

a Workplane object with the current point unchanged

parametricSurface(func, N=20, start=0, stop=1, tol=0.01, minDeg=1, maxDeg=6, smoothing=1, 1, 1)[ソース]

Create a spline surface approximating the provided function.

パラメータ
• func ((float,float) --> (float,float,float)) -- function f(u,v) that will generate (x,y,z) pairs

• N (int) -- number of points for discretization in one direction

• start (float) -- starting value of the parameters u,v

• stop (float) -- final value of the parameters u,v

• tol (float) -- tolerance used by the approximation algorithm (default: 1e-3)

• minDeg (int) -- minimum spline degree (default: 1)

• maxDeg (int) -- maximum spline degree (default: 3)

• smoothing (Optional[Tuple[float, float, float]]) -- optional parameters for the variational smoothing algorithm (default: (1,1,1))

~T

a Workplane object with the current point unchanged

This method might be unstable and may require tuning of the tol parameter.

パラメータ

self (~T) --

polarArray(radius, startAngle, angle, count, fill=True, rotate=True)[ソース]

Creates an polar array of points and pushes them onto the stack. The 0 degree reference angle is located along the local X-axis.

パラメータ
• radius (float) -- Radius of the array.

• startAngle (float) -- Starting angle (degrees) of array. 0 degrees is situated along local X-axis.

• angle (float) -- The angle (degrees) to fill with elements. A positive value will fill in the counter-clockwise direction. If fill is false, angle is the angle between elements.

• count (int) -- Number of elements in array. ( > 0 )

• fill (bool) -- Interpret the angle as total if True (default: True).

• rotate (bool) -- Rotate every item (default: True).

• self (~T) --

~T

polarLine(distance, angle, forConstruction=False)[ソース]

Make a line of the given length, at the given angle from the current point

パラメータ
• distance (float) -- distance of the end of the line from the current point

• angle (float) -- angle of the vector to the end of the line with the x-axis

• self (~T) --

• distance --

• angle --

• forConstruction (bool) --

~T

the Workplane object with the current point at the end of the new line

polarLineTo(distance, angle, forConstruction=False)[ソース]

Make a line from the current point to the given polar coordinates

Useful if it is more convenient to specify the end location rather than the distance and angle from the current point

パラメータ
• distance (float) -- distance of the end of the line from the origin

• angle (float) -- angle of the vector to the end of the line with the x-axis

• self (~T) --

• distance --

• angle --

• forConstruction (bool) --

~T

the Workplane object with the current point at the end of the new line

polygon(nSides, diameter, forConstruction=False)[ソース]

Creates a polygon inscribed in a circle of the specified diameter for each point on the stack

The first vertex is always oriented in the x direction.

パラメータ
• nSides (int) -- number of sides, must be >= 3

• diameter (float) -- the size of the circle the polygon is inscribed into

• self (~T) --

• forConstruction (bool) --

~T

a polygon wire

polyline(listOfXYTuple, forConstruction=False, includeCurrent=False)[ソース]

Create a polyline from a list of points

パラメータ
• listOfXYTuple (list of 2-tuples) -- a list of points in Workplane coordinates

• forConstruction (true if the edges are for reference, false if they are for creating geometry part geometry) -- whether or not the edges are used for reference

• includeCurrent (bool) -- use current point as a starting point of the polyline

~T

a new CQ object with a list of edges on the stack

NOTE most commonly, the resulting wire should be closed.

パラメータ

self (~T) --

pushPoints(pntList)[ソース]

Pushes a list of points onto the stack as vertices. The points are in the 2D coordinate space of the workplane face

パラメータ

pntList (list of 2-tuples, in local coordinates) -- a list of points to push onto the stack

~T

a new workplane with the desired points on the stack.

A common use is to provide a list of points for a subsequent operation, such as creating circles or holes. This example creates a cube, and then drills three holes through it, based on three points:

s = Workplane().box(1,1,1).faces(">Z").workplane().                pushPoints([(-0.3,0.3),(0.3,0.3),(0,0)])
body = s.circle(0.05).cutThruAll()


Here the circle function operates on all three points, and is then extruded to create three holes. See circle() for how it works.

パラメータ

self (~T) --

radiusArc(endPoint, radius, forConstruction=False)[ソース]

Draw an arc from the current point to endPoint with an arc defined by the radius.

パラメータ
• endPoint (2-tuple, in workplane coordinates) -- end point for the arc

• radius (float, the radius of the arc between start point and end point.) -- the radius of the arc

~T

a workplane with the current point at the end of the arc

Given that a closed contour is drawn clockwise; A positive radius means convex arc and negative radius means concave arc.

パラメータ
• self (~T) --

• forConstruction (bool) --

rarray(xSpacing, ySpacing, xCount, yCount, center=True)[ソース]

Creates an array of points and pushes them onto the stack. If you want to position the array at another point, create another workplane that is shifted to the position you would like to use as a reference

パラメータ
• xSpacing (float) -- spacing between points in the x direction ( must be > 0)

• ySpacing (float) -- spacing between points in the y direction ( must be > 0)

• xCount (int) -- number of points ( > 0 )

• yCount (int) -- number of points ( > 0 )

• center (Union[bool, Tuple[bool, bool]]) -- If True, the array will be centered around the workplane center. If False, the lower corner will be on the reference point and the array will extend in the positive x and y directions. Can also use a 2-tuple to specify centering along each axis.

• self (~T) --

~T

rect(xLen, yLen, centered=True, forConstruction=False)[ソース]

Make a rectangle for each item on the stack.

パラメータ
• xLen (float) -- length in the x direction (in workplane coordinates)

• yLen (float) -- length in the y direction (in workplane coordinates)

• centered (Union[bool, Tuple[bool, bool]]) -- If True, the rectangle will be centered around the reference point. If False, the corner of the rectangle will be on the reference point and it will extend in the positive x and y directions. Can also use a 2-tuple to specify centering along each axis.

• forConstruction (true if the wires are for reference, false if they are creating part geometry) -- should the new wires be reference geometry only?

~T

a new CQ object with the created wires on the stack

A common use case is to use a for-construction rectangle to define the centers of a hole pattern:

s = Workplane().rect(4.0,4.0,forConstruction=True).vertices().circle(0.25)


Creates 4 circles at the corners of a square centered on the origin.

Negative values for xLen and yLen are permitted, although they only have an effect when centered is False.

Future Enhancements:
• project points not in the workplane plane onto the workplane plane

パラメータ

self (~T) --

revolve(angleDegrees=360.0, axisStart=None, axisEnd=None, combine=True, clean=True)[ソース]

Use all un-revolved wires in the parent chain to create a solid.

パラメータ
• angleDegrees (float, anything less than 360 degrees will leave the shape open) -- the angle to revolve through.

• axisStart (tuple, a two tuple) -- the start point of the axis of rotation

• axisEnd (tuple, a two tuple) -- the end point of the axis of rotation

• combine (boolean, combine with parent solid) -- True to combine the resulting solid with parent solids if found.

• clean (boolean) -- call clean() afterwards to have a clean shape

~T

a CQ object with the resulting solid selected.

The returned object is always a CQ object, and depends on whether combine is True, and whether a context solid is already defined:

• if combine is False, the new value is pushed onto the stack.

• if combine is true, the value is combined with the context solid if it exists, and the resulting solid becomes the new context solid.

パラメータ
• self (~T) --

• clean (bool) --

rotate(axisStartPoint, axisEndPoint, angleDegrees)[ソース]

Returns a copy of all of the items on the stack rotated through and angle around the axis of rotation.

パラメータ
• axisStartPoint (a 3-tuple of floats) -- The first point of the axis of rotation

• axisEndPoint (a 3-tuple of floats) -- The second point of the axis of rotation

• angleDegrees (float) -- the rotation angle, in degrees

• self (~T) --

~T

a CQ object

rotateAboutCenter(axisEndPoint, angleDegrees)[ソース]

Rotates all items on the stack by the specified angle, about the specified axis

The center of rotation is a vector starting at the center of the object on the stack, and ended at the specified point.

パラメータ
• axisEndPoint (a three-tuple in global coordinates) -- the second point of axis of rotation

• angleDegrees (float) -- the rotation angle, in degrees

~T

a CQ object, with all items rotated.

WARNING: This version returns the same cq object instead of a new one-- the old object is not accessible.

Future Enhancements:
• A version of this method that returns a transformed copy, rather than modifying the originals

• This method doesn't expose a very good interface, because the axis of rotation could be inconsistent between multiple objects. This is because the beginning of the axis is variable, while the end is fixed. This is fine when operating on one object, but is not cool for multiple.

パラメータ

self (~T) --

sagittaArc(endPoint, sag, forConstruction=False)[ソース]

Draw an arc from the current point to endPoint with an arc defined by the sag (sagitta).

パラメータ
• endPoint (2-tuple, in workplane coordinates) -- end point for the arc

• sag (float, perpendicular distance from arc center to arc baseline.) -- the sagitta of the arc

~T

a workplane with the current point at the end of the arc

The sagitta is the distance from the center of the arc to the arc base. Given that a closed contour is drawn clockwise; A positive sagitta means convex arc and negative sagitta means concave arc. See "https://en.wikipedia.org/wiki/Sagitta_(geometry)" for more information.

パラメータ
• self (~T) --

• forConstruction (bool) --

section(height=0.0)[ソース]

Slices current solid at the given height.

パラメータ
• height (float) -- height to slice at (default: 0)

• self (~T) --

• height --

ValueError -- if no solids or compounds are found

~T

a CQ object with the resulting face(s).

shell(thickness, kind='arc')[ソース]

Remove the selected faces to create a shell of the specified thickness.

To shell, first create a solid, and in the same chain select the faces you wish to remove.

パラメータ
• thickness (float) -- a positive float, representing the thickness of the desired shell. Negative values shell inwards, positive values shell outwards.

• kind (Literal['arc', 'intersection']) -- kind of joints, intersection or arc (default: arc).

ValueError -- if the current stack contains objects that are not faces of a solid further up in the chain.

~T

a CQ object with the resulting shelled solid selected.

This example will create a hollowed out unit cube, where the top most face is open, and all other walls are 0.2 units thick:

Workplane().box(1,1,1).faces("+Z").shell(0.2)


Shelling is one of the cases where you may need to use the add method to select several faces. For example, this example creates a 3-walled corner, by removing three faces of a cube:

s = Workplane().box(1,1,1)
s1 = s.faces("+Z")
self.saveModel(s1.shell(0.2))


This fairly yucky syntax for selecting multiple faces is planned for improvement

Note: When sharp edges are shelled inwards, they remain sharp corners, but outward shells are automatically filleted, because an outward offset from a corner generates a radius.

Future Enhancements:

Better selectors to make it easier to select multiple faces

パラメータ

self (~T) --

shells(selector=None, tag=None)[ソース]

Select the shells of objects on the stack, optionally filtering the selection. If there are multiple objects on the stack, the shells of all objects are collected and a list of all the distinct shells is returned.

パラメータ
• selector (None, a Selector object, or a string selector expression.) -- A selector

• tag (string) -- if set, search the tagged CQ object instead of self

~T

a CQ object who's stack contains all of the distinct solids of all objects on the current stack, filtered by the provided selector.

If there are no shells for any objects on the current stack, an empty CQ object is returned

Most solids will have a single shell, which represents the outer surface. A shell will typically be composed of multiple faces.

パラメータ

self (~T) --

size()[ソース]

Return the number of objects currently on the stack

int

slot2D(length, diameter, angle=0)[ソース]

Creates a rounded slot for each point on the stack.

パラメータ
• diameter (float) -- desired diameter, or width, of slot

• length (float) -- desired end to end length of slot

• angle (float) -- angle of slot in degrees, with 0 being along x-axis

~T

a new CQ object with the created wires on the stack

Can be used to create arrays of slots, such as in cooling applications:

result = cq.Workplane("XY").box(10,25,1).rarray(1,2,1,10).slot2D(8,1,0).cutThruAll()

パラメータ

self (~T) --

solids(selector=None, tag=None)[ソース]

Select the solids of objects on the stack, optionally filtering the selection. If there are multiple objects on the stack, the solids of all objects are collected and a list of all the distinct solids is returned.

パラメータ
• selector (None, a Selector object, or a string selector expression.) -- A selector

• tag (string) -- if set, search the tagged CQ object instead of self

~T

a CQ object who's stack contains all of the distinct solids of all objects on the current stack, filtered by the provided selector.

If there are no solids for any objects on the current stack, an empty CQ object is returned

The typical use is to select the a single object on the stack. For example:

CQ(aCube).solids().size()


returns 1, because a cube consists of one solid.

It is possible for single CQ object ( or even a single CAD primitive ) to contain multiple solids.

パラメータ

self (~T) --

sphere(radius, direct=0, 0, 1, angle1=- 90, angle2=90, angle3=360, centered=True, combine=True, clean=True)[ソース]

Returns a 3D sphere with the specified radius for each point on the stack

パラメータ
• radius (float > 0) -- The radius of the sphere

• direct (A three-tuple) -- The direction axis for the creation of the sphere

• angle1 (float > 0) -- The first angle to sweep the sphere arc through

• angle2 (float > 0) -- The second angle to sweep the sphere arc through

• angle3 (float > 0) -- The third angle to sweep the sphere arc through

• centered (Union[bool, Tuple[bool, bool, bool]]) -- If True, the sphere will be centered around the reference point. If False, the corner of a bounding box around the sphere will be on the reference point and it will extend in the positive x, y and z directions. Can also use a 3-tuple to specify centering along each axis.

• combine (true to combine shapes, false otherwise) -- Whether the results should be combined with other solids on the stack (and each other)

• clean (bool) -- call clean() afterwards to have a clean shape

~T

A sphere object for each point on the stack

One sphere is created for each item on the current stack. If no items are on the stack, one box using the current workplane center is created.

If combine is true, the result will be a single object on the stack. If a solid was found in the chain, the result is that solid with all spheres produced fused onto it otherwise, the result is the combination of all the produced spheres.

If combine is false, the result will be a list of the spheres produced.

パラメータ

self (~T) --

spline(listOfXYTuple, tangents=None, periodic=False, parameters=None, scale=True, tol=None, forConstruction=False, includeCurrent=False, makeWire=False)[ソース]

Create a spline interpolated through the provided points (2D or 3D).

パラメータ
• listOfXYTuple (Iterable[Union[Tuple[float, float], Tuple[float, float, float], Vector]]) -- points to interpolate through

• tangents (Optional[Sequence[Union[Tuple[float, float], Tuple[float, float, float], Vector]]]) --

vectors specifying the direction of the tangent to the curve at each of the specified interpolation points.

If only 2 tangents are given, they will be used as the initial and final tangent.

If some tangents are not specified (i.e., are None), no tangent constraint will be applied to the corresponding interpolation point.

The spline will be C2 continuous at the interpolation points where no tangent constraint is specified, and C1 continuous at the points where a tangent constraint is specified.

• periodic (bool) -- creation of periodic curves

• parameters (Optional[Sequence[float]]) --

the value of the parameter at each interpolation point. (The interpolated curve is represented as a vector-valued function of a scalar parameter.)

If periodic == True, then len(parameters) must be len(interpolation points) + 1, otherwise len(parameters) must be equal to len(interpolation points).

• scale (bool) --

whether to scale the specified tangent vectors before interpolating.

Each tangent is scaled, so it's length is equal to the derivative of the Lagrange interpolated curve.

I.e., set this to True, if you want to use only the direction of the tangent vectors specified by tangents, but not their magnitude.

• tol (Optional[float]) --

tolerance of the algorithm (consult OCC documentation)

Used to check that the specified points are not too close to each other, and that tangent vectors are not too short. (In either case interpolation may fail.)

Set to None to use the default tolerance.

• includeCurrent (bool) -- use current point as a starting point of the curve

• makeWire (bool) -- convert the resulting spline edge to a wire

~T

a Workplane object with the current point at the end of the spline

The spline will begin at the current point, and end with the last point in the XY tuple list

This example creates a block with a spline for one side:

s = Workplane(Plane.XY())
sPnts = [
(2.75,1.5),
(2.5,1.75),
(2.0,1.5),
(1.5,1.0),
(1.0,1.25),
(0.5,1.0),
(0,1.0)
]
r = s.lineTo(3.0,0).lineTo(3.0,1.0).spline(sPnts).close()
r = r.extrude(0.5)


WARNING It is fairly easy to create a list of points that cannot be correctly interpreted as a spline.

パラメータ
• self (~T) --

• forConstruction (bool) --

splineApprox(points, tol=1e-06, minDeg=1, maxDeg=6, smoothing=1, 1, 1, forConstruction=False, includeCurrent=False, makeWire=False)[ソース]

Create a spline interpolated through the provided points (2D or 3D).

パラメータ
• points (Iterable[Union[Tuple[float, float], Tuple[float, float, float], Vector]]) -- points to interpolate through

• tol (Optional[float]) -- tolerance of the algorithm (default: 1e-6)

• minDeg (int) -- minimum spline degree (default: 1)

• maxDeg (int) -- maximum spline degree (default: 6)

• smoothing (Optional[Tuple[float, float, float]]) -- optional parameters for the variational smoothing algorithm (default: (1,1,1))

• includeCurrent (bool) -- use current point as a starting point of the curve

• makeWire (bool) -- convert the resulting spline edge to a wire

~T

a Workplane object with the current point at the end of the spline

WARNING for advanced users.

パラメータ
• self (~T) --

• forConstruction (bool) --

split(keepTop: bool = 'False', keepBottom: bool = 'False') → T[ソース]
split(splitter: Union[T, cadquery.occ_impl.shapes.Shape]) → T

Splits a solid on the stack into two parts, optionally keeping the separate parts.

パラメータ
• keepTop (boolean) -- True to keep the top, False or None to discard it

• keepBottom (boolean) -- True to keep the bottom, False or None to discard it

• ValueError -- if keepTop and keepBottom are both false.

• ValueError -- if there is no solid in the current stack or parent chain

~T

CQ object with the desired objects on the stack.

The most common operation splits a solid and keeps one half. This sample creates split bushing:

# drill a hole in the side
c = Workplane().box(1,1,1).faces(">Z").workplane().circle(0.25).cutThruAll()

# now cut it in half sideways
c = c.faces(">Y").workplane(-0.5).split(keepTop=True)

パラメータ

self (~T) --

sweep(path, multisection=False, sweepAlongWires=None, makeSolid=True, isFrenet=False, combine=True, clean=True, transition='right', normal=None, auxSpine=None)[ソース]

Use all un-extruded wires in the parent chain to create a swept solid.

パラメータ
• path (Workplane) -- A wire along which the pending wires will be swept

• multiSection (boolean) -- False to create multiple swept from wires on the chain along path. True to create only one solid swept along path with shape following the list of wires on the chain

• combine (bool) -- True to combine the resulting solid with parent solids if found.

• clean (bool) -- call clean() afterwards to have a clean shape

• transition (Literal['right', 'round', 'transformed']) -- handling of profile orientation at C1 path discontinuities. Possible values are {'transformed','round', 'right'} (default: 'right').

• normal (Union[Tuple[float, float], Tuple[float, float, float], Vector, None]) -- optional fixed normal for extrusion

• auxSpine (Optional[Workplane]) -- a wire defining the binormal along the extrusion path

• self (~T) --

• multisection (bool) --

• sweepAlongWires (Optional[bool]) --

• makeSolid (bool) --

• isFrenet (bool) --

• combine --

• clean --

~T

a CQ object with the resulting solid selected.

tag(name)[ソース]

Tags the current CQ object for later reference.

パラメータ
• name (string) -- the name to tag this object with

• self (~T) --

~T

self, a cq object with tag applied

tangentArcPoint(endpoint, forConstruction=False, relative=True)[ソース]

Draw an arc as a tangent from the end of the current edge to endpoint.

パラメータ
• endpoint (2-tuple, 3-tuple or Vector) -- point for the arc to end at

• relative (Bool) -- True if endpoint is specified relative to the current point, False if endpoint is in workplane coordinates

~T

a Workplane object with an arc on the stack

Requires the the current first object on the stack is an Edge, as would be the case after a lineTo operation or similar.

パラメータ
• self (~T) --

• forConstruction (bool) --

text(txt, fontsize, distance, cut=True, combine=False, clean=True, font='Arial', fontPath=None, kind='regular', halign='center', valign='center')[ソース]

Create a 3D text

パラメータ
• txt (str) -- text to be rendered

• fontsize (float) -- size of the font in model units

• distance (float, negative means opposite the normal direction) -- the distance to extrude or cut, normal to the workplane plane

• cut (bool) -- True to cut the resulting solid from the parent solids if found

• combine (bool) -- True to combine the resulting solid with parent solids if found

• clean (bool) -- call clean() afterwards to have a clean shape

• font (str) -- font name

• fontPath (Optional[str]) -- path to font file

• kind (Literal['regular', 'bold', 'italic']) -- font type

• halign (Literal['center', 'left', 'right']) -- horizontal alignment

• valign (Literal['center', 'top', 'bottom']) -- vertical alignment

~T

a CQ object with the resulting solid selected

The returned object is always a Workplane object, and depends on whether combine is True, and whether a context solid is already defined:

• if combine is False, the new value is pushed onto the stack.

• if combine is true, the value is combined with the context solid if it exists, and the resulting solid becomes the new context solid.

Examples:

cq.Workplane().text("CadQuery", 5, 1)


Specify the font (name), and kind to use an installed system font:

cq.Workplane().text("CadQuery", 5, 1, font="Liberation Sans Narrow", kind="italic")


Specify fontPath to use a font from a given file:

cq.Workplane().text("CadQuery", 5, 1, fontPath="/opt/fonts/texgyrecursor-bold.otf")


Cutting text into a solid:

cq.Workplane().box(8, 8, 8).faces(">Z").workplane().text("Z", 5, -1.0)

パラメータ

self (~T) --

threePointArc(point1, point2, forConstruction=False)[ソース]

Draw an arc from the current point, through point1, and ending at point2

パラメータ
• point1 (2-tuple, in workplane coordinates) -- point to draw through

• point2 (2-tuple, in workplane coordinates) -- end point for the arc

~T

a workplane with the current point at the end of the arc

Future Enhancements:

provide a version that allows an arc using relative measures provide a centerpoint arc provide tangent arcs

パラメータ
• self (~T) --

• forConstruction (bool) --

toOCC()[ソース]

Directly returns the wrapped OCCT object. :rtype: Any :return: The wrapped OCCT object :rtype TopoDS_Shape or a subclass

toPending()[ソース]

Adds wires/edges to pendingWires/pendingEdges.

~T

same CQ object with updated context.

パラメータ

self (~T) --

toSvg(opts=None)[ソース]

Returns svg text that represents the first item on the stack.

for testing purposes.

パラメータ

opts (dictionary, width and height) -- svg formatting options

str

a string that contains SVG that represents this item.

transformed(rotate=0, 0, 0, offset=0, 0, 0)[ソース]

Create a new workplane based on the current one. The origin of the new plane is located at the existing origin+offset vector, where offset is given in coordinates local to the current plane The new plane is rotated through the angles specified by the components of the rotation vector. :type rotate: Union[Tuple[float, float], Tuple[float, float, float], Vector] :param rotate: 3-tuple of angles to rotate, in degrees relative to work plane coordinates :type offset: Union[Tuple[float, float], Tuple[float, float, float], Vector] :param offset: 3-tuple to offset the new plane, in local work plane coordinates :rtype: ~T :return: a new work plane, transformed as requested

パラメータ

self (~T) --

translate(vec)[ソース]

Returns a copy of all of the items on the stack moved by the specified translation vector.

パラメータ
• tupleDistance (a 3-tuple of float) -- distance to move, in global coordinates

• self (~T) --

• vec (Union[Tuple[float, float], Tuple[float, float, float], Vector]) --

~T

a CQ object

twistExtrude(distance, angleDegrees, combine=True, clean=True)[ソース]

Extrudes a wire in the direction normal to the plane, but also twists by the specified angle over the length of the extrusion

The center point of the rotation will be the center of the workplane

See extrude for more details, since this method is the same except for the the addition of the angle. In fact, if angle=0, the result is the same as a linear extrude.

NOTE This method can create complex calculations, so be careful using it with complex geometries

パラメータ
• distance (float) -- the distance to extrude normal to the workplane

• angle -- angle (in degrees) to rotate through the extrusion

• combine (bool) -- True to combine the resulting solid with parent solids if found.

• clean (bool) -- call clean() afterwards to have a clean shape

• self (~T) --

• angleDegrees (float) --

• combine --

• clean --

~T

a CQ object with the resulting solid selected.

union(toUnion=None, clean=True, glue=False, tol=None)[ソース]

Unions all of the items on the stack of toUnion with the current solid. If there is no current solid, the items in toUnion are unioned together.

パラメータ
• toUnion (a solid object, or a CQ object having a solid,) --

• clean (bool) -- call clean() afterwards to have a clean shape (default True)

• glue (bool) -- use a faster gluing mode for non-overlapping shapes (default False)

• tol (Optional[float]) -- tolerance value for fuzzy bool operation mode (default None)

• self (~T) --

• clean --

• glue --

• tol --

Raises

ValueError if there is no solid to add to in the chain

~T

a CQ object with the resulting object selected

vLine(distance, forConstruction=False)[ソース]

Make a vertical line from the current point the provided distance

パラメータ
• distance (float) --

1. distance from current point

• self (~T) --

• distance --

• forConstruction (bool) --

~T

the workplane object with the current point at the end of the new line

vLineTo(yCoord, forConstruction=False)[ソース]

Make a vertical line from the current point to the provided y coordinate.

Useful if it is more convenient to specify the end location rather than distance, as in vLine()

パラメータ
• yCoord (float) -- y coordinate for the end of the line

• self (~T) --

• yCoord --

• forConstruction (bool) --

~T

the Workplane object with the current point at the end of the new line

val()[ソース]

Return the first value on the stack. If no value is present, current plane origin is returned.

the first value on the stack.

vals()[ソース]

get the values in the current list

list of occ_impl objects

the values of the objects on the stack.

Contrast with all(), which returns CQ objects for all of the items on the stack

vertices(selector=None, tag=None)[ソース]

Select the vertices of objects on the stack, optionally filtering the selection. If there are multiple objects on the stack, the vertices of all objects are collected and a list of all the distinct vertices is returned.

パラメータ
• selector (None, a Selector object, or a string selector expression.) --

• tag (string) -- if set, search the tagged CQ object instead of self

~T

a CQ object who's stack contains the distinct vertices of all objects on the current stack, after being filtered by the selector, if provided

If there are no vertices for any objects on the current stack, an empty CQ object is returned

The typical use is to select the vertices of a single object on the stack. For example:

Workplane().box(1,1,1).faces("+Z").vertices().size()


returns 4, because the topmost face of cube will contain four vertices. While this:

Workplane().box(1,1,1).faces().vertices().size()


returns 8, because a cube has a total of 8 vertices

Note Circles are peculiar, they have a single vertex at the center!

StringSyntaxSelector

パラメータ

self (~T) --

wedge(dx, dy, dz, xmin, zmin, xmax, zmax, pnt=Vector: (0.0, 0.0, 0.0), dir=Vector: (0.0, 0.0, 1.0), centered=True, combine=True, clean=True)[ソース]
パラメータ
• dx (float) -- Distance along the X axis

• dy (float) -- Distance along the Y axis

• dz (float) -- Distance along the Z axis

• xmin (float) -- The minimum X location

• zmin (float) -- The minimum Z location

• xmax (float) -- The maximum X location

• zmax (float) -- The maximum Z location

• pnt (Union[Tuple[float, float], Tuple[float, float, float], Vector]) -- A vector (or tuple) for the origin of the direction for the wedge

• dir (Union[Tuple[float, float], Tuple[float, float, float], Vector]) -- The direction vector (or tuple) for the major axis of the wedge

• centered (Union[bool, Tuple[bool, bool, bool]]) -- If True, the wedge will be centered around the reference point. If False, the corner of the wedge will be on the reference point and it will extend in the positive x, y and z directions. Can also use a 3-tuple to specify centering along each axis.

• combine (bool) -- Whether the results should be combined with other solids on the stack (and each other)

• clean (bool) -- True to attempt to have the kernel clean up the geometry, False otherwise

~T

A wedge object for each point on the stack

One wedge is created for each item on the current stack. If no items are on the stack, one wedge using the current workplane center is created.

If combine is True, the result will be a single object on the stack. If a solid was found in the chain, the result is that solid with all wedges produced fused onto it otherwise, the result is the combination of all the produced wedges.

If combine is False, the result will be a list of the wedges produced.

パラメータ

self (~T) --

wire(forConstruction=False)[ソース]

Returns a CQ object with all pending edges connected into a wire.

All edges on the stack that can be combined will be combined into a single wire object, and other objects will remain on the stack unmodified. If there are no pending edges, this method will just return self.

パラメータ

forConstruction (bool) -- whether the wire should be used to make a solid, or if it is just for reference

This method is primarily of use to plugin developers making utilities for 2D construction. This method should be called when a user operation implies that 2D construction is finished, and we are ready to begin working in 3d.

SEE '2D construction concepts' for a more detailed explanation of how CadQuery handles edges, wires, etc.

Any non edges will still remain.

パラメータ

self (~T) --

~T

wires(selector=None, tag=None)[ソース]

Select the wires of objects on the stack, optionally filtering the selection. If there are multiple objects on the stack, the wires of all objects are collected and a list of all the distinct wires is returned.

パラメータ
• selector (None, a Selector object, or a string selector expression.) -- A selector

• tag (string) -- if set, search the tagged CQ object instead of self

~T

a CQ object who's stack contains all of the distinct wires of all objects on the current stack, filtered by the provided selector.

If there are no wires for any objects on the current stack, an empty CQ object is returned

The typical use is to select the wires of a single object on the stack. For example:

CQ(aCube).faces("+Z").wires().size()


returns 1, because a face typically only has one outer wire

パラメータ

self (~T) --

workplane(offset=0.0, invert=False, centerOption='ProjectedOrigin', origin=None)[ソース]

Creates a new 2D workplane, located relative to the first face on the stack.

パラメータ
• offset (float or None=0.0) -- offset for the work plane in the Z direction. Default

• invert (boolean or None=False) -- invert the Z direction from that of the face.

• centerOption (string or None='ProjectedOrigin') -- how local origin of workplane is determined.

• origin (Vector or None) -- origin for plane center, requires 'ProjectedOrigin' centerOption.

Workplane object ( which is a subclass of CQ )

The first element on the stack must be a face, a set of co-planar faces or a vertex. If a vertex, then the parent item on the chain immediately before the vertex must be a face.

The result will be a 2D working plane with a new coordinate system set up as follows:

• The centerOption parameter sets how the center is defined. Options are 'CenterOfMass', 'CenterOfBoundBox', or 'ProjectedOrigin'. 'CenterOfMass' and 'CenterOfBoundBox' are in relation to the selected face(s) or vertex (vertices). 'ProjectedOrigin' uses by default the current origin or the optional origin parameter (if specified) and projects it onto the plane defined by the selected face(s).

• The Z direction will be normal to the plane of the face,computed at the center point.

• The X direction will be parallel to the x-y plane. If the workplane is parallel to the global x-y plane, the x direction of the workplane will co-incide with the global x direction.

Most commonly, the selected face will be planar, and the workplane lies in the same plane of the face ( IE, offset=0). Occasionally, it is useful to define a face offset from an existing surface, and even more rarely to define a workplane based on a face that is not planar.

To create a workplane without first having a face, use the Workplane() method.

Future Enhancements:
• Allow creating workplane from planar wires

• Allow creating workplane based on an arbitrary point on a face, not just the center. For now you can work around by creating a workplane and then offsetting the center afterwards.

パラメータ

self (~T) --

workplaneFromTagged(name)[ソース]

Copies the workplane from a tagged parent.

パラメータ

name (string) -- tag to search for

Workplane

a CQ object with name's workplane

cadquery.sortWiresByBuildOrder(wireList)[ソース]

Tries to determine how wires should be combined into faces.

Assume:

The wires make up one or more faces, which could have 'holes' Outer wires are listed ahead of inner wires there are no wires inside wires inside wires ( IE, islands -- we can deal with that later on ) none of the wires are construction wires

Compute:

one or more sets of wires, with the outer wire listed first, and inner ones

Returns, list of lists.

パラメータ

wireList (List[Wire]) --

List[List[Wire]]

class cadquery.occ_impl.shapes.Mixin1D[ソース]

ベースクラス: object

endPoint()[ソース]

Vector

a vector representing the end point of this edge.

Note, circles may have the start and end points the same

パラメータ

self (Mixin1DProtocol) --

locationAt(d, mode='length', frame='frenet')[ソース]

Generate a location along the underlying curve. :type d: float :param d: distance or parameter value :type mode: Literal['length', 'parameter'] :param mode: position calculation mode (default: length) :type frame: Literal['frenet', 'corrected'] :param frame: moving frame calculation method (default: frenet) :rtype: Location :return: A Location object representing local coordinate system at the specified distance.

パラメータ

self (Mixin1DProtocol) --

locations(ds, mode='length', frame='frenet')[ソース]

Generate location along the curve :type ds: Iterable[float] :param ds: distance or parameter values :type mode: Literal['length', 'parameter'] :param mode: position calculation mode (default: length) :type frame: Literal['frenet', 'corrected'] :param frame: moving frame calculation method (default: frenet) :rtype: List[Location] :return: A list of Location objects representing local coordinate systems at the specified distances.

パラメータ

self (Mixin1DProtocol) --

normal()[ソース]

Calculate the normal Vector. Only possible for planar curves.

Vector

normal vector

パラメータ

self (Mixin1DProtocol) --

paramAt(d)[ソース]

Compute parameter value at the specified normalized distance.

パラメータ
• d (float) -- normalized distance [0, 1]

• self (Mixin1DProtocol) --

float

parameter value

positionAt(d, mode='length')[ソース]

Generate a position along the underlying curve. :type d: float :param d: distance or parameter value :type mode: Literal['length', 'parameter'] :param mode: position calculation mode (default: length) :rtype: Vector :return: A Vector on the underlying curve located at the specified d value.

パラメータ

self (Mixin1DProtocol) --

positions(ds, mode='length')[ソース]

Generate positions along the underlying curve :type ds: Iterable[float] :param ds: distance or parameter values :type mode: Literal['length', 'parameter'] :param mode: position calculation mode (default: length) :rtype: List[Vector] :return: A list of Vector objects.

パラメータ

self (Mixin1DProtocol) --

radius()[ソース]

Note that when applied to a Wire, the radius is simply the radius of the first edge.

float

ValueError -- if kernel can not reduce the shape to a circular edge

パラメータ

self (Mixin1DProtocol) --

startPoint()[ソース]

Vector

a vector representing the start point of this edge

Note, circles may have the start and end points the same

パラメータ

self (Mixin1DProtocol) --

tangentAt(locationParam=0.5, mode='length')[ソース]

Compute tangent vector at the specified location.

パラメータ
• locationParam (float) -- distance or parameter value (default: 0.5)

• mode (Literal['length', 'parameter']) -- position calculation mode (default: parameter)

• self (Mixin1DProtocol) --

Vector

tangent vector

class cadquery.occ_impl.shapes.Mixin3D[ソース]

ベースクラス: object

chamfer(length, length2, edgeList)[ソース]

Chamfers the specified edges of this solid. :type length: float :param length: length > 0, the length (length) of the chamfer :type length2: Optional[float] :param length2: length2 > 0, optional parameter for asymmetrical chamfer. Should be None if not required. :type edgeList: Iterable[Edge] :param edgeList: a list of Edge objects, which must belong to this solid :rtype: Any :return: Chamfered solid

パラメータ

self (Any) --

dprism(basis, profiles, depth=None, taper=0, upToFace=None, thruAll=True, additive=True)[ソース]

Make a prismatic feature (additive or subtractive)

パラメータ
• basis (Optional[Face]) -- face to perfrom the operation on

• profiles (List[Wire]) -- list of profiles

• depth (Optional[float]) -- depth of the cut or extrusion

• upToFace (Optional[Face]) -- a face to extrude until

• thruAll (bool) -- cut thruAll

• additive (bool) -- set the kind of operation (additive or subtractive)

• self (~TS) --

• taper (float) --

~TS

a Solid object

fillet(radius, edgeList)[ソース]

Fillets the specified edges of this solid. :type radius: float :param radius: float > 0, the radius of the fillet :type edgeList: Iterable[Edge] :param edgeList: a list of Edge objects, which must belong to this solid :rtype: Any :return: Filleted solid

パラメータ

self (Any) --

isInside(point, tolerance=1e-06)[ソース]

Returns whether or not the point is inside a solid or compound object within the specified tolerance.

パラメータ
• point (Union[Vector, Tuple[float, float, float]]) -- tuple or Vector representing 3D point to be tested

• tolerance (float) -- tolerance for inside determination, default=1.0e-6

• self (ShapeProtocol) --

bool

bool indicating whether or not point is within solid

shell(faceList, thickness, tolerance=0.0001, kind='arc')[ソース]

Make a shelled solid of self.

パラメータ
• faceList (Optional[Iterable[Face]]) -- List of faces to be removed, which must be part of the solid. Can be an empty list.

• thickness (float) -- Floating point thickness. Positive shells outwards, negative shells inwards.

• tolerance (float) -- Modelling tolerance of the method, default=0.0001.

• self (Any) --

• kind (Literal['arc', 'intersection']) --

Any

A shelled solid.

Copyright (C) 2011-2015 Parametric Products Intellectual Holdings, LLC

This file is part of CadQuery.

CadQuery is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

CadQuery is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; If not, see <http://www.gnu.org/licenses/>

class cadquery.selectors.AndSelector(left, right)[ソース]

Intersection selector. Returns objects that is selected by both selectors.

class cadquery.selectors.AreaNthSelector(n, directionMax=True, tolerance=0.0001)[ソース]

ベースクラス: cadquery.selectors._NthSelector

Selects the object(s) with Nth area

Applicability:
• Faces, Shells, Solids - Shape.Area() is used to compute area

• closed planar Wires - a temporary face is created to compute area

Will ignore non-planar or non-closed wires.

Among other things can be used to select one of the nested coplanar wires or faces.

For example to create a fillet on a shank:

result = (
cq.Workplane("XY")
.circle(5)
.extrude(2)
.circle(2)
.extrude(10)
.faces(">Z[-2]")
.wires(AreaNthSelector(0))
.fillet(2)
)


Or to create a lip on a case seam:

result = (
cq.Workplane("XY")
.rect(20, 20)
.extrude(10)
.edges("|Z or <Z")
.fillet(2)
.faces(">Z")
.shell(2)
.faces(">Z")
.wires(AreaNthSelector(-1))
.toPending()
.workplane()
.offset2D(-1)
.extrude(1)
.faces(">Z[-2]")
.wires(AreaNthSelector(0))
.toPending()
.workplane()
.cutBlind(2)
)

パラメータ
• n (int) --

• directionMax (bool) --

• tolerance (float) --

key(obj)[ソース]

Return the key for ordering. Can raise a ValueError if obj can not be used to create a key, which will result in obj being dropped by the clustering method.

パラメータ

obj (Shape) --

float

class cadquery.selectors.BaseDirSelector(vector, tolerance=0.0001)[ソース]

A selector that handles selection on the basis of a single direction vector.

パラメータ
• vector (Vector) --

• tolerance (float) --

filter(objectList)[ソース]

There are lots of kinds of filters, but for planes they are always based on the normal of the plane, and for edges on the tangent vector along the edge

パラメータ

objectList (Sequence[Shape]) --

List[Shape]

test(vec)[ソース]

Test a specified vector. Subclasses override to provide other implementations

パラメータ

vec (Vector) --

bool

class cadquery.selectors.BinarySelector(left, right)[ソース]

Base class for selectors that operates with two other selectors. Subclass must implement the :filterResults(): method.

filter(objectList)[ソース]

Filter the provided list.

The default implementation returns the original list unfiltered. :param objectList: list to filter :type objectList: list of OCCT primitives :return: filtered list

class cadquery.selectors.BoxSelector(point0, point1, boundingbox=False)[ソース]

Selects objects inside the 3D box defined by 2 points.

If boundingbox is True only the objects that have their bounding box inside the given box is selected. Otherwise only center point of the object is tested.

Applicability: all types of shapes

Example:

CQ(aCube).edges(BoxSelector((0,1,0), (1,2,1))

filter(objectList)[ソース]

Filter the provided list.

The default implementation returns the original list unfiltered. :param objectList: list to filter :type objectList: list of OCCT primitives :return: filtered list

class cadquery.selectors.CenterNthSelector(vector, n, directionMax=True, tolerance=0.0001)[ソース]

ベースクラス: cadquery.selectors._NthSelector

Sorts objects into a list with order determined by the distance of their center projected onto the specified direction.

Applicability:

All Shapes.

パラメータ
• vector (Vector) --

• n (int) --

• directionMax (bool) --

• tolerance (float) --

key(obj)[ソース]

Return the key for ordering. Can raise a ValueError if obj can not be used to create a key, which will result in obj being dropped by the clustering method.

パラメータ

obj (Shape) --

float

class cadquery.selectors.DirectionMinMaxSelector(vector, directionMax=True, tolerance=0.0001)[ソース]

Selects objects closest or farthest in the specified direction.

Applicability:

All object types. for a vertex, its point is used. for all other kinds of objects, the center of mass of the object is used.

You can use the string shortcuts >(X|Y|Z) or <(X|Y|Z) if you want to select based on a cardinal direction.

For example this:

CQ(aCube).faces(DirectionMinMaxSelector((0, 0, 1), True)


Means to select the face having the center of mass farthest in the positive z direction, and is the same as:

CQ(aCube).faces(">Z")

パラメータ
• vector (Vector) --

• directionMax (bool) --

• tolerance (float) --

class cadquery.selectors.DirectionNthSelector(vector, n, directionMax=True, tolerance=0.0001)[ソース]

Filters for objects parallel (or normal) to the specified direction then returns the Nth one.

Applicability:

Linear Edges Planar Faces

パラメータ
• vector (Vector) --

• n (int) --

• directionMax (bool) --

• tolerance (float) --

filter(objectlist)[ソース]

There are lots of kinds of filters, but for planes they are always based on the normal of the plane, and for edges on the tangent vector along the edge

パラメータ

objectlist (Sequence[Shape]) --

List[Shape]

class cadquery.selectors.DirectionSelector(vector, tolerance=0.0001)[ソース]

Selects objects aligned with the provided direction.

Applicability:

Linear Edges Planar Faces

Use the string syntax shortcut +/-(X|Y|Z) if you want to select based on a cardinal direction.

Example:

CQ(aCube).faces(DirectionSelector((0, 0, 1))


selects faces with the normal in the z direction, and is equivalent to:

CQ(aCube).faces("+Z")

パラメータ
• vector (Vector) --

• tolerance (float) --

test(vec)[ソース]

Test a specified vector. Subclasses override to provide other implementations

パラメータ

vec (Vector) --

bool

class cadquery.selectors.InverseSelector(selector)[ソース]

Inverts the selection of given selector. In other words, selects all objects that is not selected by given selector.

filter(objectList)[ソース]

Filter the provided list.

The default implementation returns the original list unfiltered. :param objectList: list to filter :type objectList: list of OCCT primitives :return: filtered list

class cadquery.selectors.LengthNthSelector(n, directionMax=True, tolerance=0.0001)[ソース]

ベースクラス: cadquery.selectors._NthSelector

Select the object(s) with the Nth length

Applicability:

All Edge and Wire objects

パラメータ
• n (int) --

• directionMax (bool) --

• tolerance (float) --

key(obj)[ソース]

Return the key for ordering. Can raise a ValueError if obj can not be used to create a key, which will result in obj being dropped by the clustering method.

パラメータ

obj (Shape) --

float

class cadquery.selectors.NearestToPointSelector(pnt)[ソース]

Selects object nearest the provided point.

If the object is a vertex or point, the distance is used. For other kinds of shapes, the center of mass is used to to compute which is closest.

Applicability: All Types of Shapes

Example:

CQ(aCube).vertices(NearestToPointSelector((0,1,0))


returns the vertex of the unit cube closest to the point x=0,y=1,z=0

filter(objectList)[ソース]

Filter the provided list.

The default implementation returns the original list unfiltered. :param objectList: list to filter :type objectList: list of OCCT primitives :return: filtered list

class cadquery.selectors.ParallelDirSelector(vector, tolerance=0.0001)[ソース]

Selects objects parallel with the provided direction.

Applicability:

Linear Edges Planar Faces

Use the string syntax shortcut |(X|Y|Z) if you want to select based on a cardinal direction.

Example:

CQ(aCube).faces(ParallelDirSelector((0, 0, 1))


selects faces with the normal parallel to the z direction, and is equivalent to:

CQ(aCube).faces("|Z")

パラメータ
• vector (Vector) --

• tolerance (float) --

test(vec)[ソース]

Test a specified vector. Subclasses override to provide other implementations

パラメータ

vec (Vector) --

bool

class cadquery.selectors.PerpendicularDirSelector(vector, tolerance=0.0001)[ソース]

Selects objects perpendicular with the provided direction.

Applicability:

Linear Edges Planar Faces

Use the string syntax shortcut #(X|Y|Z) if you want to select based on a cardinal direction.

Example:

CQ(aCube).faces(PerpendicularDirSelector((0, 0, 1))


selects faces with the normal perpendicular to the z direction, and is equivalent to:

CQ(aCube).faces("#Z")

パラメータ
• vector (Vector) --

• tolerance (float) --

test(vec)[ソース]

Test a specified vector. Subclasses override to provide other implementations

パラメータ

vec (Vector) --

bool

class cadquery.selectors.RadiusNthSelector(n, directionMax=True, tolerance=0.0001)[ソース]

ベースクラス: cadquery.selectors._NthSelector

Select the object with the Nth radius.

Applicability:

All Edge and Wires.

Will ignore any shape that can not be represented as a circle or an arc of a circle.

パラメータ
• n (int) --

• directionMax (bool) --

• tolerance (float) --

key(obj)[ソース]

Return the key for ordering. Can raise a ValueError if obj can not be used to create a key, which will result in obj being dropped by the clustering method.

パラメータ

obj (Shape) --

float

class cadquery.selectors.Selector[ソース]

ベースクラス: object

Filters a list of objects.

Filters must provide a single method that filters objects.

filter(objectList)[ソース]

Filter the provided list.

The default implementation returns the original list unfiltered. :param objectList: list to filter :type objectList: list of OCCT primitives :return: filtered list

class cadquery.selectors.StringSyntaxSelector(selectorString)[ソース]

Filter lists objects using a simple string syntax. All of the filters available in the string syntax are also available ( usually with more functionality ) through the creation of full-fledged selector objects. see Selector and its subclasses

Filtering works differently depending on the type of object list being filtered.

パラメータ

selectorString -- A two-part selector string, [selector][axis]

objects that match the specified selector

*Modifiers* are ('|','+','-','<','>','%')

|

parallel to ( same as ParallelDirSelector ). Can return multiple objects.

#

perpendicular to (same as PerpendicularDirSelector )

+

positive direction (same as DirectionSelector )

-

negative direction (same as DirectionSelector )

>

maximize (same as DirectionMinMaxSelector with directionMax=True)

<

minimize (same as DirectionMinMaxSelector with directionMax=False )

%

curve/surface type (same as TypeSelector)

*axisStrings* are: X,Y,Z,XY,YZ,XZ or (x,y,z) which defines an arbitrary direction

It is possible to combine simple selectors together using logical operations. The following operations are supported

and

Logical AND, e.g. >X and >Y

or

Logical OR, e.g. |X or |Y

not

Logical NOT, e.g. not #XY

exc(ept)

Set difference (equivalent to AND NOT): |X exc >Z

Finally, it is also possible to use even more complex expressions with nesting and arbitrary number of terms, e.g.

(not >X[0] and #XY) or >XY[0]

Selectors are a complex topic: see String Selectors Reference for more information

filter(objectList)[ソース]

Filter give object list through th already constructed complex selector object

class cadquery.selectors.SubtractSelector(left, right)[ソース]

Difference selector. Subtract results of a selector from another selectors results.

class cadquery.selectors.SumSelector(left, right)[ソース]

Union selector. Returns the sum of two selectors results.

class cadquery.selectors.TypeSelector(typeString)[ソース]

Selects objects having the prescribed geometry type.

Applicability:

Faces: PLANE, CYLINDER, CONE, SPHERE, TORUS, BEZIER, BSPLINE, REVOLUTION, EXTRUSION, OFFSET, OTHER Edges: LINE, CIRCLE, ELLIPSE, HYPERBOLA, PARABOLA, BEZIER, BSPLINE, OFFSET, OTHER

You can use the string selector syntax. For example this:

CQ(aCube).faces ( TypeSelector("PLANE") )


will select 6 faces, and is equivalent to:

CQ(aCube).faces( "%PLANE" )

パラメータ

typeString (str) --

filter(objectList)[ソース]

Filter the provided list.

The default implementation returns the original list unfiltered. :type objectList: Sequence[Shape] :param objectList: list to filter :type objectList: list of OCCT primitives :rtype: List[Shape] :return: filtered list