CadQueryクラスの概要

このページでは、CadQuery クラスのすべてのメソッドと関数について、アルファベット順に整理して説明しています。

参考

機能分野別の一覧は、 API Reference をご覧ください。

コアクラス

Sketch(parent, locs, obj)

2Dスケッチ。

Workplane(, obj=None))

2次元座標を使用できる空間上の座標系を定義します。

Assembly([obj, loc, name, color, metadata])

WorkplaneとShapeオブジェクトの相対的な位置を定義するネストされたアセンブリ。

Constraint

:py:class:`~cadquery.occ_impl.solver.ConstraintSpec`の別名です。

トポロジカルクラス

Shape(obj)

システム内の形状を表します。

Vertex(obj[, forConstruction])

空間の中の一点

Edge(obj)

面の境界を表すトリミングされた曲線

cadquery.occ_impl.shapes.Mixin1D()

Wire(obj)

接続され、順序付けられた一連のEdgeで、通常、Faceを囲みます。

Face(obj)

固体の境界の一部を表す有界面

Shell(obj)

サーフェスの外側の境界線

cadquery.occ_impl.shapes.Mixin3D()

Solid(obj)

単体

Compound(obj)

切断された固体の集合体

ジオメトリークラス

Vector()

3次元ベクトルを作成する

Matrix()

3d , 4x4 の変換行列。

Plane(origin[, xDir, normal])

空間における2次元座標系

Location(t)

3D空間での位置。

セレクタクラス

Selector()

オブジェクトのリストにフィルタをかける。

NearestToPointSelector(pnt)

指定された点に最も近いオブジェクトを選択します。

BoxSelector(point0, point1[, boundingbox])

2点で定義された3Dボックス内のオブジェクトを選択します。

BaseDirSelector(vector[, tolerance])

単一の方向ベクトルに基づく選択を処理するセレクタ。

ParallelDirSelector(vector[, tolerance])

指定した方向と平行なオブジェクトを選択します。

DirectionSelector(vector[, tolerance])

指定した方向に並んだオブジェクトを選択します。

PerpendicularDirSelector(vector[, tolerance])

指定した方向と直交するオブジェクトを選択します。

TypeSelector(typeString)

所定のジオメトリタイプを持つオブジェクトを選択します。

RadiusNthSelector(n[, directionMax, tolerance])

N 番目の半径を持つオブジェクトを選択します。

CenterNthSelector(vector, n[, directionMax, ...])

オブジェクトを、指定された方向に投影された中心からの距離によって決まる順序でリストにソートします。

DirectionMinMaxSelector(vector[, ...])

指定した方向に最も近い、または最も遠いオブジェクトを選択します。

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: Optional[Union[Shape, Workplane]] = None, loc: Optional[Location] = None, name: Optional[str] = None, color: Optional[Color] = None, metadata: Optional[Dict[str, Any]] = None)[ソース]

ベースクラス: object

WorkplaneとShapeオブジェクトの相対的な位置を定義するネストされたアセンブリ。

パラメータ:
__init__(obj: Optional[Union[Shape, Workplane]] = None, loc: Optional[Location] = None, name: Optional[str] = None, color: Optional[Color] = None, metadata: Optional[Dict[str, Any]] = None)[ソース]

construct an assembly

パラメータ:
  • obj (Optional[Union[Shape, Workplane]]) -- 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, resulting in an UUID being generated)

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

  • metadata (Optional[Dict[str, Any]]) -- a store for user-defined metadata (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")
__iter__(loc: Optional[Location] = None, name: Optional[str] = None, color: Optional[Color] = None) Iterator[Tuple[Shape, str, Location, Optional[Color]]][ソース]

Assembly iterator yielding shapes, names, locations and colors.

パラメータ:
  • loc (Optional[Location]) --

  • name (Optional[str]) --

  • color (Optional[Color]) --

戻り値の型:

Iterator[Tuple[Shape, str, Location, Optional[Color]]]

__weakref__

list of weak references to the object (if defined)

add(obj: Assembly, loc: Optional[Location] = None, name: Optional[str] = None, color: Optional[Color] = None) Assembly[ソース]
add(obj: Optional[Union[Shape, Workplane]], loc: Optional[Location] = None, name: Optional[str] = None, color: Optional[Color] = None, metadata: Optional[Dict[str, Any]] = None) Assembly

Add a subassembly to the current assembly.

constrain(q1: str, q2: str, kind: Literal['Plane', 'Point', 'Axis', 'PointInPlane', 'Fixed', 'FixedPoint', 'FixedAxis', 'PointOnLine', 'FixedRotation'], param: Any = None) Assembly[ソース]
constrain(q1: str, kind: Literal['Plane', 'Point', 'Axis', 'PointInPlane', 'Fixed', 'FixedPoint', 'FixedAxis', 'PointOnLine', 'FixedRotation'], param: Any = None) Assembly
constrain(id1: str, s1: Shape, id2: str, s2: Shape, kind: Literal['Plane', 'Point', 'Axis', 'PointInPlane', 'Fixed', 'FixedPoint', 'FixedAxis', 'PointOnLine', 'FixedRotation'], param: Any = None) Assembly
constrain(id1: str, s1: Shape, kind: Literal['Plane', 'Point', 'Axis', 'PointInPlane', 'Fixed', 'FixedPoint', 'FixedAxis', 'PointOnLine', 'FixedRotation'], param: Any = None) Assembly

Define a new constraint.

export(path: str, exportType: Optional[Literal['STEP', 'XML', 'GLTF', 'VTKJS', 'VRML', 'STL']] = None, mode: Literal['default', 'fused'] = 'default', tolerance: float = 0.1, angularTolerance: float = 0.1, **kwargs) Assembly[ソース]

Save assembly to a file.

パラメータ:
  • path (str) -- Path and filename for writing.

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

  • mode (Literal['default', 'fused']) -- STEP only - See exportAssembly().

  • tolerance (float) -- the deflection tolerance, in model units. Only used for glTF, VRML. Default 0.1.

  • angularTolerance (float) -- the angular tolerance, in radians. Only used for glTF, VRML. Default 0.1.

  • **kwargs -- Additional keyword arguments. Only used for STEP, glTF and STL. See exportAssembly().

  • ascii (bool) -- STL only - Sets whether or not STL export should be text or binary

戻り値の型:

Assembly

save(path: str, exportType: Optional[Literal['STEP', 'XML', 'GLTF', 'VTKJS', 'VRML', 'STL']] = None, mode: Literal['default', 'fused'] = 'default', tolerance: float = 0.1, angularTolerance: float = 0.1, **kwargs) Assembly[ソース]

Save assembly to a file.

パラメータ:
  • path (str) -- Path and filename for writing.

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

  • mode (Literal['default', 'fused']) -- STEP only - See exportAssembly().

  • tolerance (float) -- the deflection tolerance, in model units. Only used for glTF, VRML. Default 0.1.

  • angularTolerance (float) -- the angular tolerance, in radians. Only used for glTF, VRML. Default 0.1.

  • **kwargs -- Additional keyword arguments. Only used for STEP, glTF and STL. See exportAssembly().

  • ascii (bool) -- STL only - Sets whether or not STL export should be text or binary

戻り値の型:

Assembly

property shapes: List[Shape]

List of Shape objects in the .obj field

solve(verbosity: int = 0) Assembly[ソース]

Solve the constraints.

パラメータ:

verbosity (int) --

戻り値の型:

Assembly

toCompound() Compound[ソース]

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() Iterator[Tuple[str, Assembly]][ソース]

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

戻り値の型:

Iterator[Tuple[str, Assembly]]

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

ベースクラス: object

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

パラメータ:

bb (Bnd_Box) --

__init__(bb: Bnd_Box) None[ソース]
パラメータ:

bb (Bnd_Box) --

戻り値の型:

None

__weakref__

list of weak references to the object (if defined)

add(obj: Union[Tuple[float, float, float], Vector, BoundBox], tol: Optional[float] = None) BoundBox[ソース]

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

enlarge(tol: float) BoundBox[ソース]

Returns a modified (expanded) bounding box, expanded in all directions by the tolerance value.

This means that the minimum values of its X, Y and Z intervals of the bounding box are reduced by the absolute value of tol, while the maximum values are increased by the same amount.

パラメータ:

tol (float) --

戻り値の型:

BoundBox

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

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.

パラメータ:
戻り値の型:

Optional[BoundBox]

isInside(b2: BoundBox) bool[ソース]

Is the provided bounding box inside this one?

パラメータ:

b2 (BoundBox) --

戻り値の型:

bool

cadquery.CQ

:py:class:`~cadquery.cq.Workplane`の別名です。

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

ベースクラス: object

Wrapper for the OCCT color object Quantity_ColorRGBA.

__eq__(other)[ソース]

Return self==value.

__hash__()[ソース]

Return hash(self).

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

list of weak references to the object (if defined)

toTuple() Tuple[float, float, float, float][ソース]

Convert Color to RGB tuple.

戻り値の型:

Tuple[float, float, float, float]

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

ベースクラス: Shape, Mixin3D

切断された固体の集合体

パラメータ:

obj (TopoDS_Shape) --

__bool__() bool[ソース]

Check if empty.

戻り値の型:

bool

ancestors(shape: Shape, kind: Literal['Vertex', 'Edge', 'Wire', 'Face', 'Shell', 'Solid', 'CompSolid', 'Compound']) Compound[ソース]

Iterate over ancestors, i.e. shapes of same kind within shape that contain elements of self.

パラメータ:
  • shape (Shape) --

  • kind (Literal['Vertex', 'Edge', 'Wire', 'Face', 'Shell', 'Solid', 'CompSolid', 'Compound']) --

戻り値の型:

Compound

cut(*toCut: Shape, tol: Optional[float] = None) Compound[ソース]

Remove the positional arguments from this Shape.

パラメータ:
  • tol (Optional[float]) -- Fuzzy mode tolerance

  • toCut (Shape) --

戻り値の型:

Compound

fuse(*toFuse: Shape, glue: bool = False, tol: Optional[float] = None) Compound[ソース]

Fuse shapes together

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

  • glue (bool) --

  • tol (Optional[float]) --

戻り値の型:

Compound

intersect(*toIntersect: Shape, tol: Optional[float] = None) Compound[ソース]

Intersection of the positional arguments and this Shape.

パラメータ:
  • tol (Optional[float]) -- Fuzzy mode tolerance

  • toIntersect (Shape) --

戻り値の型:

Compound

classmethod makeCompound(listOfShapes: Iterable[Shape]) Compound[ソース]

Create a compound out of a list of shapes

パラメータ:

listOfShapes (Iterable[Shape]) --

戻り値の型:

Compound

classmethod makeText(text: str, size: float, height: float, font: str = 'Arial', fontPath: Optional[str] = None, kind: Literal['regular', 'bold', 'italic'] = 'regular', halign: Literal['center', 'left', 'right'] = 'center', valign: Literal['center', 'top', 'bottom'] = 'center', position: Plane = Plane(origin=(0.0, 0.0, 0.0), xDir=(1.0, 0.0, 0.0), normal=(0.0, 0.0, 1.0))) Shape[ソース]

Create a 3D text

パラメータ:
  • 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

remove(shape: Shape)[ソース]

Remove the specified shape.

パラメータ:

shape (Shape) --

siblings(shape: Shape, kind: Literal['Vertex', 'Edge', 'Wire', 'Face', 'Shell', 'Solid', 'CompSolid', 'Compound'], level: int = 1) Compound[ソース]

Iterate over siblings, i.e. shapes within shape that share subshapes of kind with the elements of self.

パラメータ:
  • shape (Shape) --

  • kind (Literal['Vertex', 'Edge', 'Wire', 'Face', 'Shell', 'Solid', 'CompSolid', 'Compound']) --

  • level (int) --

戻り値の型:

Compound

cadquery.Constraint

:py:class:`~cadquery.occ_impl.solver.ConstraintSpec`の別名です。

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

ベースクラス: CenterNthSelector

指定した方向に最も近い、または最も遠いオブジェクトを選択します。

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: Vector, directionMax: bool = True, tolerance: float = 0.0001)[ソース]
パラメータ:
  • vector (Vector) --

  • directionMax (bool) --

  • tolerance (float) --

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

ベースクラス: BaseDirSelector

指定した方向に並んだオブジェクトを選択します。

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: Vector) bool[ソース]

Test a specified vector. Subclasses override to provide other implementations

パラメータ:

vec (Vector) --

戻り値の型:

bool

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

ベースクラス: Shape, Mixin1D

面の境界を表すトリミングされた曲線

パラメータ:

obj (TopoDS_Shape) --

arcCenter() Vector[ソース]

Center of an underlying circle or ellipse geometry.

戻り値の型:

Vector

close() Union[Edge, Wire][ソース]

Close an Edge

戻り値の型:

Union[Edge, Wire]

classmethod makeBezier(points: List[Vector]) Edge[ソース]

Create a cubic Bézier Curve from the points.

パラメータ:

points (List[Vector]) -- a list of Vectors that represent the points. The edge will pass through the first and the last point, and the inner points are Bézier control points.

戻り値:

An edge

戻り値の型:

Edge

classmethod makeEllipse(x_radius: float, y_radius: float, pnt: ~typing.Union[~cadquery.occ_impl.geom.Vector, ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float]], ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float], ~typing.Union[int, float]]] = Vector: (0.0, 0.0, 0.0), dir: ~typing.Union[~cadquery.occ_impl.geom.Vector, ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float]], ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float], ~typing.Union[int, float]]] = Vector: (0.0, 0.0, 1.0), xdir: ~typing.Union[~cadquery.occ_impl.geom.Vector, ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float]], ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float], ~typing.Union[int, float]]] = Vector: (1.0, 0.0, 0.0), angle1: float = 360.0, angle2: float = 360.0, sense: ~typing.Literal[-1, 1] = 1) Edge[ソース]

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

パラメータ:
  • cls --

  • 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[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) -- vector representing the center of the ellipse

  • dir (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, 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[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) --

戻り値:

an Edge

戻り値の型:

Edge

classmethod makeLine(v1: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], v2: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) Edge[ソース]

Create a line between two points

パラメータ:
  • v1 (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) -- Vector that represents the first point

  • v2 (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) -- Vector that represents the second point

戻り値:

A linear edge between the two provided points

戻り値の型:

Edge

classmethod makeSpline(listOfVector: List[Vector], tangents: Optional[Sequence[Vector]] = None, periodic: bool = False, parameters: Optional[Sequence[float]] = None, scale: bool = True, tol: float = 1e-06) Edge[ソース]

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.)

戻り値:

an Edge

戻り値の型:

Edge

classmethod makeSplineApprox(listOfVector: List[Vector], tol: float = 0.001, smoothing: Optional[Tuple[float, float, float]] = None, minDeg: int = 1, maxDeg: int = 6) Edge[ソース]

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)

戻り値:

an Edge

戻り値の型:

Edge

classmethod makeTangentArc(v1: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], v2: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], v3: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) Edge[ソース]

Makes a tangent arc from point v1, in the direction of v2 and ends at v3.

パラメータ:
  • cls --

  • v1 (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) -- start vector

  • v2 (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) -- tangent vector

  • v3 (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) -- end vector

戻り値:

an edge

戻り値の型:

Edge

classmethod makeThreePointArc(v1: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], v2: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], v3: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) Edge[ソース]

Makes a three point arc through the provided points

パラメータ:
  • cls --

  • v1 (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) -- start vector

  • v2 (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) -- middle vector

  • v3 (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) -- end vector

戻り値:

an edge object through the three points

戻り値の型:

Edge

trim(u0: Union[float, int], u1: Union[float, int]) Edge[ソース]

Trim the edge in the parametric space to (u0, u1).

NB: this operation is done on the base geometry.

パラメータ:
  • u0 (Union[float, int]) --

  • u1 (Union[float, int]) --

戻り値の型:

Edge

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

ベースクラス: Shape

固体の境界の一部を表す有界面

パラメータ:

obj (TopoDS_Shape) --

Center() Vector[ソース]
戻り値:

The point of the center of mass of this Shape

戻り値の型:

Vector

chamfer2D(d: float, vertices: Iterable[Vertex]) Face[ソース]

Apply 2D chamfer to a face

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

  • vertices (Iterable[Vertex]) --

戻り値の型:

Face

fillet2D(radius: float, vertices: Iterable[Vertex]) Face[ソース]

Apply 2D fillet to a face

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

  • vertices (Iterable[Vertex]) --

戻り値の型:

Face

isoline(param: Union[float, int], direction: Literal['u', 'v'] = 'v') Edge[ソース]

Construct an isoline.

パラメータ:
  • param (Union[float, int]) --

  • direction (Literal['u', 'v']) --

戻り値の型:

Edge

isolines(params: Iterable[Union[float, int]], direction: Literal['u', 'v'] = 'v') List[Edge][ソース]

Construct multiple isolines.

パラメータ:
  • params (Iterable[Union[float, int]]) --

  • direction (Literal['u', 'v']) --

戻り値の型:

List[Edge]

classmethod makeFromWires(outerWire: Wire, innerWires: List[Wire] = []) Face[ソース]

Makes a planar face from one or more wires

パラメータ:
  • outerWire (Wire) --

  • innerWires (List[Wire]) --

戻り値の型:

Face

classmethod makeNSidedSurface(edges: ~typing.Iterable[~typing.Union[~cadquery.occ_impl.shapes.Edge, ~cadquery.occ_impl.shapes.Wire]], constraints: ~typing.Iterable[~typing.Union[~cadquery.occ_impl.shapes.Edge, ~cadquery.occ_impl.shapes.Wire, ~cadquery.occ_impl.geom.Vector, ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float]], ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float], ~typing.Union[int, float]], ~OCP.gp.gp_Pnt]], continuity: ~OCP.GeomAbs.GeomAbs_Shape = <GeomAbs_Shape.GeomAbs_C0: 0>, degree: int = 3, nbPtsOnCur: int = 15, nbIter: int = 2, anisotropy: bool = False, tol2d: float = 1e-05, tol3d: float = 0.0001, tolAng: float = 0.01, tolCurv: float = 0.1, maxDeg: int = 8, maxSegments: int = 9) Face[ソース]

Returns a surface enclosed by a closed polygon defined by 'edges' and 'constraints'.

パラメータ:
  • edges (list of edges or wires) -- edges

  • constraints (list of points or edges) -- constraints

  • continuity (GeomAbs_Shape) -- OCC.Core.GeomAbs continuity condition

  • degree (int) -- >=2

  • nbPtsOnCur (int) -- number of points on curve >= 15

  • nbIter (int) -- number of iterations >= 2

  • anisotropy (bool) -- bool Anisotropy

  • tol2d (float) -- 2D tolerance >0

  • tol3d (float) -- 3D tolerance >0

  • tolAng (float) -- angular tolerance

  • tolCurv (float) -- tolerance for curvature >0

  • maxDeg (int) -- highest polynomial degree >= 2

  • maxSegments (int) -- greatest number of segments >= 2

戻り値の型:

Face

classmethod makeRuledSurface(edgeOrWire1: Edge, edgeOrWire2: Edge) Face[ソース]
classmethod makeRuledSurface(edgeOrWire1: Wire, edgeOrWire2: Wire) 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: List[List[Vector]], tol: float = 0.01, smoothing: Optional[Tuple[float, float, float]] = None, minDeg: int = 1, maxDeg: int = 3) Face[ソース]

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)

戻り値の型:

Face

normalAt(u: Union[float, int], v: Union[float, int]) Tuple[Vector, Vector][ソース]
normalAt(locationVector: Optional[Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]] = None) Vector

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

戻り値:

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.

戻り値の型:

Vector

Computes the normal vector at the desired location in the u,v parameter space.

戻り値:

a vector representing the normal direction and the position

パラメータ:
  • u -- the u parametric location to compute the normal at.

  • v -- the v parametric location to compute the normal at.

  • locationVector (Optional[Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]]) --

戻り値の型:

Vector

normals(us: Iterable[Union[float, int]], vs: Iterable[Union[float, int]]) Tuple[List[Vector], List[Vector]][ソース]

Computes the normal vectors at the desired locations in the u,v parameter space.

戻り値:

a tuple of list of vectors representing the normal directions and the positions

パラメータ:
  • us (Iterable[Union[float, int]]) -- the u parametric locations to compute the normal at.

  • vs (Iterable[Union[float, int]]) -- the v parametric locations to compute the normal at.

戻り値の型:

Tuple[List[Vector], List[Vector]]

thicken(thickness: float) Solid[ソース]

Return a thickened face

パラメータ:

thickness (float) --

戻り値の型:

Solid

toArcs(tolerance: float = 0.001) Face[ソース]

Approximate planar face with arcs and straight line segments.

パラメータ:

tolerance (float) -- Approximation tolerance.

戻り値の型:

Face

toPln() gp_Pln[ソース]

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

trim(u0: Union[float, int], u1: Union[float, int], v0: Union[float, int], v1: Union[float, int], tol: Union[float, int] = 1e-06) Face[ソース]

Trim the face in the parametric space to (u0, u1).

NB: this operation is done on the base geometry.

パラメータ:
  • u0 (Union[float, int]) --

  • u1 (Union[float, int]) --

  • v0 (Union[float, int]) --

  • v1 (Union[float, int]) --

  • tol (Union[float, int]) --

戻り値の型:

Face

class cadquery.Location(t: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, 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.

パラメータ:

t (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) --

__init__(T: gp_Trsf) None[ソース]
__init__(t: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], angles: Tuple[Union[int, float], Union[int, float], Union[int, float]]) None
__init__(t: Plane, v: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) None
__init__(t: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], ax: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], angle: Union[int, float]) None
__init__(x: Union[int, float] = 0, y: Union[int, float] = 0, z: Union[int, float] = 0, rx: Union[int, float] = 0, ry: Union[int, float] = 0, rz: Union[int, float] = 0) None
__init__(T: TopLoc_Location) None
__init__(t: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) None
__init__(t: Plane) None

Location with translation t with respect to the original location.

Location with translation (x,y,z) and 3 rotation angles.

Location corresponding to the location of the Plane t.

Location corresponding to the angular location of the Plane t with translation v.

Location wrapping the low-level TopLoc_Location object t

Location wrapping the low-level gp_Trsf object t

Location with translation t and rotation around ax by angle

with respect to the original location.

Location with translation t and 3 rotation angles.

パラメータ:

t (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) --

戻り値の型:

None

__weakref__

list of weak references to the object (if defined)

toTuple() Tuple[Tuple[float, float, float], Tuple[float, float, float]][ソース]

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[gp_GTrsf, gp_Trsf])
class cadquery.Matrix(matrix: Sequence[Sequence[float]])

ベースクラス: object

3d , 4x4 の変換行列。

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: Tuple[int, int]) float[ソース]

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[gp_GTrsf, gp_Trsf]) None
__init__(matrix: Sequence[Sequence[float]]) None
__repr__() str[ソース]

Generate a valid python expression representing this Matrix

戻り値の型:

str

__weakref__

list of weak references to the object (if defined)

transposed_list() Sequence[float][ソース]

Needed by the cqparts gltf exporter

戻り値の型:

Sequence[float]

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

ベースクラス: Selector

指定された点に最も近いオブジェクトを選択します。

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)[ソース]
filter(objectList: Sequence[Shape])[ソース]

Filter the provided list.

The default implementation returns the original list unfiltered.

パラメータ:

objectList (list of OCCT primitives) -- list to filter

戻り値:

filtered list

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

ベースクラス: BaseDirSelector

指定した方向と平行なオブジェクトを選択します。

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: Vector) bool[ソース]

Test a specified vector. Subclasses override to provide other implementations

パラメータ:

vec (Vector) --

戻り値の型:

bool

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

ベースクラス: BaseDirSelector

指定した方向と直交するオブジェクトを選択します。

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: Vector) bool[ソース]

Test a specified vector. Subclasses override to provide other implementations

パラメータ:

vec (Vector) --

戻り値の型:

bool

class cadquery.Plane(origin: Union[Tuple[float, float, float], Vector], xDir: Optional[Union[Tuple[float, float, float], Vector]] = None, normal: Union[Tuple[float, float, float], Vector] = (0, 0, 1))[ソース]

ベースクラス: object

空間における2次元座標系

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 (Vector) --

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

__eq__(other)[ソース]

Return self==value.

__hash__ = None
__init__(origin: Union[Tuple[float, float, float], Vector], xDir: Optional[Union[Tuple[float, float, float], Vector]] = None, normal: Union[Tuple[float, float, float], Vector] = (0, 0, 1))[ソース]

Create a Plane with an arbitrary orientation

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

  • xDir (Optional[Union[Tuple[float, float, float], Vector]]) -- 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.

__repr__()[ソース]

Return repr(self).

__weakref__

list of weak references to the object (if defined)

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

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

戻り値の型:

Plane

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

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) Vector[ソース]

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.

戻り値:

a Vector in global coordinates

戻り値の型:

Vector

class cadquery.Selector[ソース]

ベースクラス: object

オブジェクトのリストにフィルタをかける。

Filters must provide a single method that filters objects.

__weakref__

list of weak references to the object (if defined)

filter(objectList: Sequence[Shape]) List[Shape][ソース]

Filter the provided list.

The default implementation returns the original list unfiltered.

パラメータ:

objectList (list of OCCT primitives) -- list to filter

戻り値:

filtered list

戻り値の型:

List[Shape]

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

ベースクラス: object

Represents a shape in the system. Wraps TopoDS_Shape.

パラメータ:

obj (TopoDS_Shape) --

Area() float[ソース]
戻り値:

The surface area of all faces in this Shape

戻り値の型:

float

BoundingBox(tolerance: Optional[float] = None) BoundBox[ソース]

Create a bounding box for this Shape.

パラメータ:

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

戻り値:

A BoundBox object for this Shape

戻り値の型:

BoundBox

Center() Vector[ソース]
戻り値:

The point of the center of mass of this Shape

戻り値の型:

Vector

CenterOfBoundBox(tolerance: Optional[float] = None) Vector[ソース]
パラメータ:

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

戻り値:

Center of the bounding box of this shape

戻り値の型:

Vector

Closed() bool[ソース]
戻り値:

The closedness flag

戻り値の型:

bool

static CombinedCenter(objects: Iterable[Shape]) Vector[ソース]

Calculates the center of mass of multiple objects.

パラメータ:

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

戻り値の型:

Vector

static CombinedCenterOfBoundBox(objects: List[Shape]) Vector[ソース]

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

戻り値の型:

List[CompSolid]

Compounds() List[Compound][ソース]
戻り値:

All the compounds in this Shape

戻り値の型:

List[Compound]

Edges() List[Edge][ソース]
戻り値:

All the edges in this Shape

戻り値の型:

List[Edge]

Faces() List[Face][ソース]
戻り値:

All the faces in this Shape

戻り値の型:

List[Face]

Shells() List[Shell][ソース]
戻り値:

All the shells in this Shape

戻り値の型:

List[Shell]

Solids() List[Solid][ソース]
戻り値:

All the solids in this Shape

戻り値の型:

List[Solid]

Vertices() List[Vertex][ソース]
戻り値:

All the vertices in this Shape

戻り値の型:

List[Vertex]

Volume() float[ソース]
戻り値:

The volume of this Shape

戻り値の型:

float

Wires() List[Wire][ソース]
戻り値:

All the wires in this Shape

戻り値の型:

List[Wire]

__add__(other: Shape) Shape[ソース]

Fuse self and other.

パラメータ:

other (Shape) --

戻り値の型:

Shape

__eq__(other) bool[ソース]

Return self==value.

戻り値の型:

bool

__hash__() int[ソース]

Return hash(self).

戻り値の型:

int

__init__(obj: TopoDS_Shape)[ソース]
パラメータ:

obj (TopoDS_Shape) --

__iter__() Iterator[Shape][ソース]

Iterate over subshapes.

戻り値の型:

Iterator[Shape]

__mul__(other: Shape) Shape[ソース]

Intersect self and other.

パラメータ:

other (Shape) --

戻り値の型:

Shape

__sub__(other: Shape) Shape[ソース]

Subtract other from self.

パラメータ:

other (Shape) --

戻り値の型:

Shape

__truediv__(other: Shape) Shape[ソース]

Split self with other.

パラメータ:

other (Shape) --

戻り値の型:

Shape

__weakref__

list of weak references to the object (if defined)

ancestors(shape: Shape, kind: Literal['Vertex', 'Edge', 'Wire', 'Face', 'Shell', 'Solid', 'CompSolid', 'Compound']) Compound[ソース]

Iterate over ancestors, i.e. shapes of same kind within shape that contain self.

パラメータ:
  • shape (Shape) --

  • kind (Literal['Vertex', 'Edge', 'Wire', 'Face', 'Shell', 'Solid', 'CompSolid', 'Compound']) --

戻り値の型:

Compound

classmethod cast(obj: TopoDS_Shape, forConstruction: bool = False) Shape[ソース]

Returns the right type of wrapper, given a OCCT object

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

  • forConstruction (bool) --

戻り値の型:

Shape

static centerOfMass(obj: Shape) Vector[ソース]

Calculates the center of 'mass' of an object.

パラメータ:

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

戻り値の型:

Vector

clean() T[ソース]

Experimental clean using ShapeUpgrade

パラメータ:

self (T) --

戻り値の型:

T

static computeMass(obj: Shape) float[ソース]

Calculates the 'mass' of an object.

パラメータ:

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

戻り値の型:

float

copy(mesh: bool = False) T[ソース]

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

パラメータ:
  • mesh (bool) -- should I copy the triangulation too (default: False)

  • self (T) --

戻り値:

a copy of the object

戻り値の型:

T

cut(*toCut: Shape, tol: Optional[float] = None) Shape[ソース]

Remove the positional arguments from this Shape.

パラメータ:
  • tol (Optional[float]) -- Fuzzy mode tolerance

  • toCut (Shape) --

戻り値の型:

Shape

distance(other: Shape) float[ソース]

Minimal distance between two shapes

パラメータ:

other (Shape) --

戻り値の型:

float

distances(*others: Shape) Iterator[float][ソース]

Minimal distances to between self and other shapes

パラメータ:

others (Shape) --

戻り値の型:

Iterator[float]

edges(selector: Optional[Union[str, Selector]] = None) Shape[ソース]

Select edges.

パラメータ:

selector (Optional[Union[str, Selector]]) --

戻り値の型:

Shape

export(fname: str, tolerance: float = 0.1, angularTolerance: float = 0.1, opt: Optional[Dict[str, Any]] = None)[ソース]

Export Shape to file.

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

  • fname (str) --

  • tolerance (float) --

  • angularTolerance (float) --

  • opt (Optional[Dict[str, Any]]) --

exportBin(f: Union[str, BytesIO]) bool[ソース]

Export this shape to a binary BREP file.

パラメータ:

f (Union[str, BytesIO]) --

戻り値の型:

bool

exportBrep(f: Union[str, BytesIO]) bool[ソース]

Export this shape to a BREP file

パラメータ:

f (Union[str, BytesIO]) --

戻り値の型:

bool

exportStep(fileName: str, **kwargs) IFSelect_ReturnStatus[ソース]

Export this shape to a STEP file.

kwargs is used to provide optional keyword arguments to configure the exporter.

パラメータ:
  • fileName (str) -- Path and filename for writing.

  • write_pcurves (bool) --

    Enable or disable writing parametric curves to the STEP file. Default True.

    If False, writes STEP file without pcurves. This decreases the size of the resulting STEP file.

  • precision_mode (int) -- Controls the uncertainty value for STEP entities. Specify -1, 0, or 1. Default 0. See OCCT documentation.

戻り値の型:

IFSelect_ReturnStatus

exportStl(fileName: str, tolerance: float = 0.001, angularTolerance: float = 0.1, ascii: bool = False, relative: bool = True, parallel: bool = True) bool[ソース]

Exports a shape to a specified STL file.

パラメータ:
  • fileName (str) -- 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 1e-3, which is a 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.

  • ascii (bool) -- Export the file as ASCII (True) or binary (False) STL format. Default is binary.

  • relative (bool) -- If True, tolerance will be scaled by the size of the edge being meshed. Default is True. Setting this value to True may cause large features to become faceted, or small features dense.

  • parallel (bool) -- If True, OCCT will use parallel processing to mesh the shape. Default is True.

戻り値の型:

bool

faces(selector: Optional[Union[str, Selector]] = None) Shape[ソース]

Select faces.

パラメータ:

selector (Optional[Union[str, Selector]]) --

戻り値の型:

Shape

facesIntersectedByLine(point: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], axis: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], tol: float = 0.0001, direction: Optional[Literal['AlongAxis', 'Opposite']] = None)[ソース]

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

パラメータ:
  • point (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) -- Base point for defining a line

  • axis (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) -- Axis on which the line rests

  • tol (float) -- Intersection tolerance

  • direction (Optional[Literal['AlongAxis', 'Opposite']]) -- 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

fix() T[ソース]

Try to fix shape if not valid

パラメータ:

self (T) --

戻り値の型:

T

fuse(*toFuse: Shape, glue: bool = False, tol: Optional[float] = None) Shape[ソース]

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]) -- Fuzzy mode tolerance

  • toFuse (Shape) --

戻り値の型:

Shape

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

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, CIRCLE, ELLIPSE, HYPERBOLA, PARABOLA, BEZIER,
BSPLINE, OFFSET, OTHER
Face: PLANE, CYLINDER, CONE, SPHERE, TORUS, BEZIER, BSPLINE,
REVOLUTION, EXTRUSION, OFFSET, OTHER
Solid: 'Solid'
Shell: 'Shell'
Compound: 'Compound'
Wire: 'Wire'
戻り値:

A string according to the geometry type

戻り値の型:

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

hashCode() int[ソース]

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

戻り値の型:

int

classmethod importBin(f: Union[str, BytesIO]) Shape[ソース]

Import shape from a binary BREP file.

パラメータ:

f (Union[str, BytesIO]) --

戻り値の型:

Shape

classmethod importBrep(f: Union[str, BytesIO]) Shape[ソース]

Import shape from a BREP file

パラメータ:

f (Union[str, BytesIO]) --

戻り値の型:

Shape

intersect(*toIntersect: Shape, tol: Optional[float] = None) Shape[ソース]

Intersection of the positional arguments and this Shape.

パラメータ:
  • tol (Optional[float]) -- Fuzzy mode tolerance

  • toIntersect (Shape) --

戻り値の型:

Shape

isEqual(other: Shape) bool[ソース]

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() bool[ソース]

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: Shape) bool[ソース]

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() bool[ソース]

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: Location) T[ソース]

Apply a location in absolute sense to self.

パラメータ:
戻り値の型:

T

located(loc: Location) T[ソース]

Apply a location in absolute sense to a copy of self.

パラメータ:
戻り値の型:

T

location() Location[ソース]

Return the current location

戻り値の型:

Location

static matrixOfInertia(obj: Shape) List[List[float]][ソース]

Calculates the matrix of inertia of an object. Since the part's density is unknown, this result is inertia/density with units of [1/length]. :param obj: Compute the matrix of inertia of this object

パラメータ:

obj (Shape) --

戻り値の型:

List[List[float]]

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

Generate triangulation if none exists.

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

  • angularTolerance (float) --

mirror(mirrorPlane: Union[Literal['XY', 'YX', 'XZ', 'ZX', 'YZ', 'ZY'], Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]] = 'XY', basePointVector: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]] = (0, 0, 0)) Shape[ソース]

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[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) -- The direction of the plane to mirror about - one of 'XY', 'XZ' or 'YZ'

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

戻り値:

The mirrored shape

戻り値の型:

Shape

move(x: Union[float, int] = 0, y: Union[float, int] = 0, z: Union[float, int] = 0, rx: Union[float, int] = 0, ry: Union[float, int] = 0, rz: Union[float, int] = 0) T[ソース]
move(loc: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) T
move(loc: Location) T

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

Apply translation and rotation in relative sense (i.e. update current location) to self.

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

パラメータ:
戻り値の型:

T

moved(loc: Location) T[ソース]
moved(loc1: Location, loc2: Location, *locs: Location) T
moved(loc: Sequence[Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]]) T
moved(x: Union[float, int] = 0, y: Union[float, int] = 0, z: Union[float, int] = 0, rx: Union[float, int] = 0, ry: Union[float, int] = 0, rz: Union[float, int] = 0) T
moved(loc1: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], loc2: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], *locs: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) T
moved(locs: Sequence[Location]) T
moved(loc: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) T

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

Apply multiple locations.

Apply multiple locations.

Apply translation and rotation in relative sense to a copy of self.

Apply a VectorLike in relative sense to a copy of self.

Apply multiple VectorLikes in relative sense to a copy of self.

Apply multiple VectorLikes in relative sense to a copy of self.

パラメータ:
戻り値の型:

T

rotate(startVector: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], endVector: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], angleDegrees: float) T[ソース]

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) --

戻り値:

a copy of the shape, rotated

戻り値の型:

T

scale(factor: float) Shape[ソース]

Scales this shape through a transformation.

パラメータ:

factor (float) --

戻り値の型:

Shape

shells(selector: Optional[Union[str, Selector]] = None) Shape[ソース]

Select shells.

パラメータ:

selector (Optional[Union[str, Selector]]) --

戻り値の型:

Shape

siblings(shape: Shape, kind: Literal['Vertex', 'Edge', 'Wire', 'Face', 'Shell', 'Solid', 'CompSolid', 'Compound'], level: int = 1) Compound[ソース]

Iterate over siblings, i.e. shapes within shape that share subshapes of kind with self.

パラメータ:
  • shape (Shape) --

  • kind (Literal['Vertex', 'Edge', 'Wire', 'Face', 'Shell', 'Solid', 'CompSolid', 'Compound']) --

  • level (int) --

戻り値の型:

Compound

solids(selector: Optional[Union[str, Selector]] = None) Shape[ソース]

Select solids.

パラメータ:

selector (Optional[Union[str, Selector]]) --

戻り値の型:

Shape

split(*splitters: Shape) Shape[ソース]

Split this shape with the positional arguments.

パラメータ:

splitters (Shape) --

戻り値の型:

Shape

toSplines(degree: int = 3, tolerance: float = 0.001, nurbs: bool = False) T[ソース]

Approximate shape with b-splines of the specified degree.

パラメータ:
  • degree (int) -- Maximum degree.

  • tolerance (float) -- Approximation tolerance.

  • nurbs (bool) -- Use rational splines.

  • self (T) --

戻り値の型:

T

toVtkPolyData(tolerance: Optional[float] = None, angularTolerance: Optional[float] = None, normals: bool = False) vtkPolyData[ソース]

Convert shape to vtkPolyData

パラメータ:
  • tolerance (Optional[float]) --

  • angularTolerance (Optional[float]) --

  • normals (bool) --

戻り値の型:

vtkPolyData

transformGeometry(tMatrix: Matrix) Shape[ソース]

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

戻り値:

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

戻り値の型:

Shape

transformShape(tMatrix: Matrix) Shape[ソース]

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

パラメータ:

tMatrix (Matrix) -- The transformation matrix

戻り値:

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

戻り値の型:

Shape

translate(vector: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) T[ソース]

Translates this shape through a transformation.

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

  • vector (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) --

戻り値の型:

T

vertices(selector: Optional[Union[str, Selector]] = None) Shape[ソース]

Select vertices.

パラメータ:

selector (Optional[Union[str, Selector]]) --

戻り値の型:

Shape

wires(selector: Optional[Union[str, Selector]] = None) Shape[ソース]

Select wires.

パラメータ:

selector (Optional[Union[str, Selector]]) --

戻り値の型:

Shape

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

ベースクラス: Shape

サーフェスの外側の境界線

パラメータ:

obj (TopoDS_Shape) --

classmethod makeShell(listOfFaces: Iterable[Face]) Shell[ソース]

Makes a shell from faces.

パラメータ:

listOfFaces (Iterable[Face]) --

戻り値の型:

Shell

class cadquery.Sketch(parent: ~typing.Optional[~typing.Any] = None, locs: ~typing.Iterable[~cadquery.occ_impl.geom.Location] = (<cadquery.occ_impl.geom.Location object>, ), obj: ~typing.Optional[~cadquery.occ_impl.shapes.Compound] = None)[ソース]

ベースクラス: object

2D sketch. Supports faces, edges and edges with constraints based construction.

パラメータ:
__add__(other: Sketch) T[ソース]

Fuse self and other.

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

  • other (Sketch) --

戻り値の型:

T

__init__(parent: ~typing.Optional[~typing.Any] = None, locs: ~typing.Iterable[~cadquery.occ_impl.geom.Location] = (<cadquery.occ_impl.geom.Location object>, ), obj: ~typing.Optional[~cadquery.occ_impl.shapes.Compound] = None)[ソース]

Construct an empty sketch.

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

  • parent (Optional[Any]) --

  • locs (Iterable[Location]) --

  • obj (Optional[Compound]) --

__iter__() Iterator[Face][ソース]

Iterate over faces-locations combinations. If not faces are present iterate over edges:

戻り値の型:

Iterator[Face]

__mul__(other: Sketch) T[ソース]

Intersect self and other.

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

  • other (Sketch) --

戻り値の型:

T

__sub__(other: Sketch) T[ソース]

Subtract other from self.

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

  • other (Sketch) --

戻り値の型:

T

__truediv__(other: Sketch) T[ソース]

Split self with other.

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

  • other (Sketch) --

戻り値の型:

T

__weakref__

list of weak references to the object (if defined)

add() T[ソース]

Add selection to the underlying faces.

パラメータ:

self (T) --

戻り値の型:

T

apply(f: Callable[[Iterable[Union[Shape, Location]]], Iterable[Union[Shape, Location]]])[ソース]

Apply a callable to all items at once.

パラメータ:
戻り値:

Sketch object with f applied to all items.

arc(p1: Union[Vector, Tuple[Union[int, float], Union[int, float]]], p2: Union[Vector, Tuple[Union[int, float], Union[int, float]]], p3: Union[Vector, Tuple[Union[int, float], Union[int, float]]], tag: Optional[str] = None, forConstruction: bool = False) T[ソース]
arc(p2: Union[Vector, Tuple[Union[int, float], Union[int, float]]], p3: Union[Vector, Tuple[Union[int, float], Union[int, float]]], tag: Optional[str] = None, forConstruction: bool = False) T
arc(c: Union[Vector, Tuple[Union[int, float], Union[int, float]]], r: Union[int, float], a: Union[int, float], da: Union[int, float], tag: Optional[str] = None, forConstruction: bool = False) T

Construct an arc.

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

  • p1 (Union[Vector, Tuple[Union[int, float], Union[int, float]]]) --

  • p2 (Union[Vector, Tuple[Union[int, float], Union[int, float]]]) --

  • p3 (Union[Vector, Tuple[Union[int, float], Union[int, float]]]) --

  • tag (Optional[str]) --

  • forConstruction (bool) --

戻り値の型:

T

assemble(mode: Literal['a', 's', 'i', 'c', 'r'] = 'a', tag: Optional[str] = None) T[ソース]

Assemble edges into faces.

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

  • mode (Literal['a', 's', 'i', 'c', 'r']) --

  • tag (Optional[str]) --

戻り値の型:

T

bezier(pts: Iterable[Union[Vector, Tuple[Union[int, float], Union[int, float]]]], tag: Optional[str] = None, forConstruction: bool = False) T[ソース]

Construct an bezier curve.

The edge will pass through the last points, and the inner points are bezier control points.

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

  • pts (Iterable[Union[Vector, Tuple[Union[int, float], Union[int, float]]]]) --

  • tag (Optional[str]) --

  • forConstruction (bool) --

戻り値の型:

T

chamfer(d: Union[int, float]) T[ソース]

Add a chamfer based on current selection.

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

  • d (Union[int, float]) --

戻り値の型:

T

circle(r: Union[int, float], mode: Literal['a', 's', 'i', 'c', 'r'] = 'a', tag: Optional[str] = None) T[ソース]

Construct a circular face.

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

  • r (Union[int, float]) --

  • mode (Literal['a', 's', 'i', 'c', 'r']) --

  • tag (Optional[str]) --

戻り値の型:

T

clean() T[ソース]

Remove internal wires.

パラメータ:

self (T) --

戻り値の型:

T

close(tag: Optional[str] = None) T[ソース]

Connect last edge to the first one.

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

  • tag (Optional[str]) --

戻り値の型:

T

constrain(tag1: str, tag2: str, constraint: Literal['Fixed', 'FixedPoint', 'Coincident', 'Angle', 'Length', 'Distance', 'Radius', 'Orientation', 'ArcAngle'], arg: Any) T[ソース]
constrain(tag: str, constraint: Literal['Fixed', 'FixedPoint', 'Coincident', 'Angle', 'Length', 'Distance', 'Radius', 'Orientation', 'ArcAngle'], arg: Any) T

Add a constraint.

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

  • tag (str) --

  • constraint (Literal['Fixed', 'FixedPoint', 'Coincident', 'Angle', 'Length', 'Distance', 'Radius', 'Orientation', 'ArcAngle']) --

  • arg (Any) --

戻り値の型:

T

copy() T[ソース]

Create a partial copy of the sketch.

パラメータ:

self (T) --

戻り値の型:

T

delete() T[ソース]

Delete selected object.

パラメータ:

self (T) --

戻り値の型:

T

distribute(n: int, start: Union[int, float] = 0, stop: Union[int, float] = 1, rotate: bool = True) T[ソース]

Distribute locations along selected edges or wires.

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

  • n (int) --

  • start (Union[int, float]) --

  • stop (Union[int, float]) --

  • rotate (bool) --

戻り値の型:

T

each(callback: Callable[[Location], Union[Face, Sketch, Compound]], mode: Literal['a', 's', 'i', 'c', 'r'] = 'a', tag: Optional[str] = None, ignore_selection: bool = False) T[ソース]

Apply a callback on all applicable entities.

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

  • callback (Callable[[Location], Union[Face, Sketch, Compound]]) --

  • mode (Literal['a', 's', 'i', 'c', 'r']) --

  • tag (Optional[str]) --

  • ignore_selection (bool) --

戻り値の型:

T

edge(val: Edge, tag: Optional[str] = None, forConstruction: bool = False) T[ソース]

Add an edge to the sketch.

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

  • val (Edge) --

  • tag (Optional[str]) --

  • forConstruction (bool) --

戻り値の型:

T

edges(s: Optional[Union[str, Selector]] = None, tag: Optional[str] = None) T[ソース]

Select edges.

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

  • s (Optional[Union[str, Selector]]) --

  • tag (Optional[str]) --

戻り値の型:

T

ellipse(a1: Union[int, float], a2: Union[int, float], angle: Union[int, float] = 0, mode: Literal['a', 's', 'i', 'c', 'r'] = 'a', tag: Optional[str] = None) T[ソース]

Construct an elliptical face.

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

  • a1 (Union[int, float]) --

  • a2 (Union[int, float]) --

  • angle (Union[int, float]) --

  • mode (Literal['a', 's', 'i', 'c', 'r']) --

  • tag (Optional[str]) --

戻り値の型:

T

export(fname: str, tolerance: float = 0.1, angularTolerance: float = 0.1, opt: Optional[Dict[str, Any]] = None) T[ソース]

Export Sketch to file.

パラメータ:
  • path -- Filename.

  • tolerance (float) -- the deflection tolerance, in model units. Default 0.1.

  • angularTolerance (float) -- the angular tolerance, in radians. Default 0.1.

  • opt (Optional[Dict[str, Any]]) -- additional options passed to the specific exporter. Default None.

  • self (T) --

  • fname (str) --

戻り値:

Self.

戻り値の型:

T

face(b: Union[Wire, Iterable[Edge], Shape, T], angle: Union[int, float] = 0, mode: Literal['a', 's', 'i', 'c', 'r'] = 'a', tag: Optional[str] = None, ignore_selection: bool = False) T[ソース]

Construct a face from a wire or edges.

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

  • b (Union[Wire, Iterable[Edge], Shape, T]) --

  • angle (Union[int, float]) --

  • mode (Literal['a', 's', 'i', 'c', 'r']) --

  • tag (Optional[str]) --

  • ignore_selection (bool) --

戻り値の型:

T

faces(s: Optional[Union[str, Selector]] = None, tag: Optional[str] = None) T[ソース]

Select faces.

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

  • s (Optional[Union[str, Selector]]) --

  • tag (Optional[str]) --

戻り値の型:

T

fillet(d: Union[int, float]) T[ソース]

Add a fillet based on current selection.

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

  • d (Union[int, float]) --

戻り値の型:

T

filter(f: Callable[[Union[Shape, Location]], bool]) T[ソース]

Filter items using a boolean predicate.

パラメータ:
  • f (Callable[[Union[Shape, Location]], bool]) -- Callable to be used for filtering.

  • self (T) --

戻り値:

Sketch object with filtered items.

戻り値の型:

T

finalize() Any[ソース]

Finish sketch construction and return the parent.

戻り値の型:

Any

hull(mode: Literal['a', 's', 'i', 'c', 'r'] = 'a', tag: Optional[str] = None) T[ソース]

Generate a convex hull from current selection or all objects.

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

  • mode (Literal['a', 's', 'i', 'c', 'r']) --

  • tag (Optional[str]) --

戻り値の型:

T

importDXF(filename: str, tol: float = 1e-06, exclude: List[str] = [], include: List[str] = [], angle: Union[int, float] = 0, mode: Literal['a', 's', 'i', 'c', 'r'] = 'a', tag: Optional[str] = None) T[ソース]

Import a DXF file and construct face(s)

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

  • filename (str) --

  • tol (float) --

  • exclude (List[str]) --

  • include (List[str]) --

  • angle (Union[int, float]) --

  • mode (Literal['a', 's', 'i', 'c', 'r']) --

  • tag (Optional[str]) --

戻り値の型:

T

invoke(f: Union[Callable[[T], T], Callable[[T], None], Callable[[], None]])[ソース]

Invoke a callable mapping Sketch to Sketch or None. Supports also callables that take no arguments such as breakpoint. Returns self if callable returns None.

パラメータ:
  • f (Union[Callable[[T], T], Callable[[T], None], Callable[[], None]]) -- Callable to be invoked.

  • self (T) --

戻り値:

Sketch object.

located(loc: Location) T[ソース]

Create a partial copy of the sketch with a new location.

パラメータ:
戻り値の型:

T

map(f: Callable[[Union[Shape, Location]], Union[Shape, Location]])[ソース]

Apply a callable to every item separately.

パラメータ:
戻り値:

Sketch object with f applied to all items.

moved(loc: Location) T[ソース]
moved(loc1: Location, loc2: Location, *locs: Location) T
moved(locs: Sequence[Location]) T
moved(x: Union[int, float] = 0, y: Union[int, float] = 0, z: Union[int, float] = 0, rx: Union[int, float] = 0, ry: Union[int, float] = 0, rz: Union[int, float] = 0) T
moved(loc: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) T
moved(loc1: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], loc2: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], *locs: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) T
moved(loc: Sequence[Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]]) T

Create a partial copy of the sketch with moved _faces.

offset(d: Union[int, float], mode: Literal['a', 's', 'i', 'c', 'r'] = 'a', tag: Optional[str] = None) T[ソース]

Offset selected wires or edges.

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

  • d (Union[int, float]) --

  • mode (Literal['a', 's', 'i', 'c', 'r']) --

  • tag (Optional[str]) --

戻り値の型:

T

parray(r: Union[int, float], a1: Union[int, float], da: Union[int, float], n: int, rotate: bool = True) T[ソース]

Generate a polar array of locations.

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

  • r (Union[int, float]) --

  • a1 (Union[int, float]) --

  • da (Union[int, float]) --

  • n (int) --

  • rotate (bool) --

戻り値の型:

T

polygon(pts: Iterable[Union[Vector, Tuple[Union[int, float], Union[int, float]]]], angle: Union[int, float] = 0, mode: Literal['a', 's', 'i', 'c', 'r'] = 'a', tag: Optional[str] = None) T[ソース]

Construct a polygonal face.

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

  • pts (Iterable[Union[Vector, Tuple[Union[int, float], Union[int, float]]]]) --

  • angle (Union[int, float]) --

  • mode (Literal['a', 's', 'i', 'c', 'r']) --

  • tag (Optional[str]) --

戻り値の型:

T

push(locs: Iterable[Union[Location, Vector, Tuple[Union[int, float], Union[int, float]]]], tag: Optional[str] = None) T[ソース]

Set current selection to given locations or points.

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

  • locs (Iterable[Union[Location, Vector, Tuple[Union[int, float], Union[int, float]]]]) --

  • tag (Optional[str]) --

戻り値の型:

T

rarray(xs: Union[int, float], ys: Union[int, float], nx: int, ny: int) T[ソース]

Generate a rectangular array of locations.

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

  • xs (Union[int, float]) --

  • ys (Union[int, float]) --

  • nx (int) --

  • ny (int) --

戻り値の型:

T

rect(w: Union[int, float], h: Union[int, float], angle: Union[int, float] = 0, mode: Literal['a', 's', 'i', 'c', 'r'] = 'a', tag: Optional[str] = None) T[ソース]

Construct a rectangular face.

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

  • w (Union[int, float]) --

  • h (Union[int, float]) --

  • angle (Union[int, float]) --

  • mode (Literal['a', 's', 'i', 'c', 'r']) --

  • tag (Optional[str]) --

戻り値の型:

T

regularPolygon(r: Union[int, float], n: int, angle: Union[int, float] = 0, mode: Literal['a', 's', 'i', 'c', 'r'] = 'a', tag: Optional[str] = None) T[ソース]

Construct a regular polygonal face.

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

  • r (Union[int, float]) --

  • n (int) --

  • angle (Union[int, float]) --

  • mode (Literal['a', 's', 'i', 'c', 'r']) --

  • tag (Optional[str]) --

戻り値の型:

T

replace() T[ソース]

Replace the underlying faces with the selection.

パラメータ:

self (T) --

戻り値の型:

T

reset() T[ソース]

Reset current selection.

パラメータ:

self (T) --

戻り値の型:

T

segment(p1: Union[Vector, Tuple[Union[int, float], Union[int, float]]], p2: Union[Vector, Tuple[Union[int, float], Union[int, float]]], tag: Optional[str] = None, forConstruction: bool = False) T[ソース]
segment(p2: Union[Vector, Tuple[Union[int, float], Union[int, float]]], tag: Optional[str] = None, forConstruction: bool = False) T
segment(l: Union[int, float], a: Union[int, float], tag: Optional[str] = None, forConstruction: bool = False) T

Construct a segment.

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

  • p1 (Union[Vector, Tuple[Union[int, float], Union[int, float]]]) --

  • p2 (Union[Vector, Tuple[Union[int, float], Union[int, float]]]) --

  • tag (Optional[str]) --

  • forConstruction (bool) --

戻り値の型:

T

select(*tags: str) T[ソース]

Select based on tags.

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

  • tags (str) --

戻り値の型:

T

slot(w: Union[int, float], h: Union[int, float], angle: Union[int, float] = 0, mode: Literal['a', 's', 'i', 'c', 'r'] = 'a', tag: Optional[str] = None) T[ソース]

Construct a slot-shaped face.

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

  • w (Union[int, float]) --

  • h (Union[int, float]) --

  • angle (Union[int, float]) --

  • mode (Literal['a', 's', 'i', 'c', 'r']) --

  • tag (Optional[str]) --

戻り値の型:

T

solve() T[ソース]

Solve current constraints and update edge positions.

パラメータ:

self (T) --

戻り値の型:

T

sort(key: Callable[[Union[Shape, Location]], Any]) T[ソース]

Sort items using a callable.

パラメータ:
  • key (Callable[[Union[Shape, Location]], Any]) -- Callable to be used for sorting.

  • self (T) --

戻り値:

Sketch object with items sorted.

戻り値の型:

T

spline(pts: Iterable[Union[Vector, Tuple[Union[int, float], Union[int, float]]]], tag: Optional[str] = None, forConstruction: bool = False) T[ソース]
spline(pts: Iterable[Union[Vector, Tuple[Union[int, float], Union[int, float]]]], tangents: Optional[Iterable[Union[Vector, Tuple[Union[int, float], Union[int, float]]]]], periodic: bool, tag: Optional[str] = None, forConstruction: bool = False) T

Construct a spline edge.

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

  • pts (Iterable[Union[Vector, Tuple[Union[int, float], Union[int, float]]]]) --

  • tangents (Optional[Iterable[Union[Vector, Tuple[Union[int, float], Union[int, float]]]]]) --

  • periodic (bool) --

  • tag (Optional[str]) --

  • forConstruction (bool) --

戻り値の型:

T

subtract() T[ソース]

Subtract selection from the underlying faces.

パラメータ:

self (T) --

戻り値の型:

T

tag(tag: str) T[ソース]

Tag current selection.

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

  • tag (str) --

戻り値の型:

T

trapezoid(w: Union[int, float], h: Union[int, float], a1: Union[int, float], a2: Optional[float] = None, angle: Union[int, float] = 0, mode: Literal['a', 's', 'i', 'c', 'r'] = 'a', tag: Optional[str] = None) T[ソース]

Construct a trapezoidal face.

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

  • w (Union[int, float]) --

  • h (Union[int, float]) --

  • a1 (Union[int, float]) --

  • a2 (Optional[float]) --

  • angle (Union[int, float]) --

  • mode (Literal['a', 's', 'i', 'c', 'r']) --

  • tag (Optional[str]) --

戻り値の型:

T

val() Union[Shape, Location][ソース]

Return the first selected item, underlying compound or first edge.

パラメータ:

self (T) --

戻り値の型:

Union[Shape, Location]

vals() List[Union[Shape, Location]][ソース]

Return all selected items, underlying compound or all edges.

パラメータ:

self (T) --

戻り値の型:

List[Union[Shape, Location]]

vertices(s: Optional[Union[str, Selector]] = None, tag: Optional[str] = None) T[ソース]

Select vertices.

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

  • s (Optional[Union[str, Selector]]) --

  • tag (Optional[str]) --

戻り値の型:

T

wires(s: Optional[Union[str, Selector]] = None, tag: Optional[str] = None) T[ソース]

Select wires.

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

  • s (Optional[Union[str, Selector]]) --

  • tag (Optional[str]) --

戻り値の型:

T

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

ベースクラス: Shape, Mixin3D

単体

パラメータ:

obj (TopoDS_Shape) --

classmethod extrudeLinear(outerWire: Wire, innerWires: List[Wire], vecNormal: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], taper: Union[float, int] = 0) Solid[ソース]
classmethod extrudeLinear(face: Face, vecNormal: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], taper: Union[float, int] = 0) Solid

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 (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) -- a vector along which to extrude the wires

  • taper (Union[float, int]) -- taper angle, default=0

戻り値:

a Solid object

戻り値の型:

Solid

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.

classmethod extrudeLinearWithRotation(face: Face, vecCenter: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], vecNormal: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], angleDegrees: Union[float, int]) Solid[ソース]
classmethod extrudeLinearWithRotation(outerWire: Wire, innerWires: List[Wire], vecCenter: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], vecNormal: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], angleDegrees: Union[float, int]) Solid

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

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

  • vecCenter (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) -- the center point about which to rotate. the axis of rotation is defined by vecNormal, located at vecCenter.

  • vecNormal (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) -- a vector along which to extrude the wires

  • angleDegrees (Union[float, int]) -- the angle to rotate through while extruding

戻り値:

a Solid object

戻り値の型:

Solid

innerShells() List[Shell][ソース]

Returns inner shells.

戻り値の型:

List[Shell]

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) Union[Solid, Face][ソース]

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

パラメータ:
  • surf_edges -- list of [x,y,z] float ordered coordinates or list of ordered or unordered wires

  • surf_pts -- list of [x,y,z] float coordinates (uses only edges if [])

  • thickness -- thickness may be negative or positive depending on direction, (returns 2D surface if 0)

  • degree -- >=2

  • nbPtsOnCur -- number of points on curve >= 15

  • nbIter -- number of iterations >= 2

  • anisotropy -- bool Anisotropy

  • tol2d -- 2D tolerance >0

  • tol3d -- 3D tolerance >0

  • tolAng -- angular tolerance

  • tolCurv -- tolerance for curvature >0

  • maxDeg -- highest polynomial degree >= 2

  • maxSegments -- greatest number of segments >= 2

戻り値の型:

Union[Solid, Face]

static isSolid(obj: Shape) bool[ソース]

Returns true if the object is a solid, false otherwise

パラメータ:

obj (Shape) --

戻り値の型:

bool

classmethod makeBox(length,width,height,[pnt,dir]) -- Make a box located in pnt with the dimensions (length,width,height)[ソース]

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

パラメータ:
  • length (float) --

  • width (float) --

  • height (float) --

  • pnt (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) --

  • dir (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) --

戻り値の型:

Solid

classmethod makeCone(radius1: float, radius2: float, height: float, pnt: ~typing.Union[~cadquery.occ_impl.geom.Vector, ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float]], ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float], ~typing.Union[int, float]]] = Vector: (0.0, 0.0, 0.0), dir: ~typing.Union[~cadquery.occ_impl.geom.Vector, ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float]], ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float], ~typing.Union[int, float]]] = Vector: (0.0, 0.0, 1.0), angleDegrees: float = 360) Solid[ソース]

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

パラメータ:
  • radius1 (float) --

  • radius2 (float) --

  • height (float) --

  • pnt (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) --

  • dir (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) --

  • angleDegrees (float) --

戻り値の型:

Solid

classmethod makeCylinder(radius: float, height: float, pnt: ~typing.Union[~cadquery.occ_impl.geom.Vector, ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float]], ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float], ~typing.Union[int, float]]] = Vector: (0.0, 0.0, 0.0), dir: ~typing.Union[~cadquery.occ_impl.geom.Vector, ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float]], ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float], ~typing.Union[int, float]]] = Vector: (0.0, 0.0, 1.0), angleDegrees: float = 360) Solid[ソース]

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

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

  • height (float) --

  • pnt (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) --

  • dir (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) --

  • angleDegrees (float) --

戻り値の型:

Solid

classmethod makeLoft(listOfWire: List[Wire], ruled: bool = False) Solid[ソース]

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.

パラメータ:
  • listOfWire (List[Wire]) --

  • ruled (bool) --

戻り値の型:

Solid

classmethod makeSolid(shell: Shell) Solid[ソース]

Makes a solid from a single shell.

パラメータ:

shell (Shell) --

戻り値の型:

Solid

classmethod makeSphere(radius: float, pnt: ~typing.Union[~cadquery.occ_impl.geom.Vector, ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float]], ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float], ~typing.Union[int, float]]] = Vector: (0.0, 0.0, 0.0), dir: ~typing.Union[~cadquery.occ_impl.geom.Vector, ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float]], ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float], ~typing.Union[int, float]]] = Vector: (0.0, 0.0, 1.0), angleDegrees1: float = 0, angleDegrees2: float = 90, angleDegrees3: float = 360) Shape[ソース]

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

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

  • pnt (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) --

  • dir (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) --

  • angleDegrees1 (float) --

  • angleDegrees2 (float) --

  • angleDegrees3 (float) --

戻り値の型:

Shape

classmethod makeTorus(radius1: float, radius2: float, pnt: ~typing.Union[~cadquery.occ_impl.geom.Vector, ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float]], ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float], ~typing.Union[int, float]]] = Vector: (0.0, 0.0, 0.0), dir: ~typing.Union[~cadquery.occ_impl.geom.Vector, ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float]], ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float], ~typing.Union[int, float]]] = Vector: (0.0, 0.0, 1.0), angleDegrees1: float = 0, angleDegrees2: float = 360) Solid[ソース]

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

パラメータ:
  • radius1 (float) --

  • radius2 (float) --

  • pnt (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) --

  • dir (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) --

  • angleDegrees1 (float) --

  • angleDegrees2 (float) --

戻り値の型:

Solid

classmethod makeWedge(dx: float, dy: float, dz: float, xmin: float, zmin: float, xmax: float, zmax: float, pnt: ~typing.Union[~cadquery.occ_impl.geom.Vector, ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float]], ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float], ~typing.Union[int, float]]] = Vector: (0.0, 0.0, 0.0), dir: ~typing.Union[~cadquery.occ_impl.geom.Vector, ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float]], ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float], ~typing.Union[int, float]]] = Vector: (0.0, 0.0, 1.0)) Solid[ソース]

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

パラメータ:
  • dx (float) --

  • dy (float) --

  • dz (float) --

  • xmin (float) --

  • zmin (float) --

  • xmax (float) --

  • zmax (float) --

  • pnt (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) --

  • dir (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) --

戻り値の型:

Solid

outerShell() Shell[ソース]

Returns outer shell.

戻り値の型:

Shell

classmethod revolve(outerWire: Wire, innerWires: List[Wire], angleDegrees: Union[float, int], axisStart: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], axisEnd: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) Solid[ソース]
classmethod revolve(face: Face, angleDegrees: Union[float, int], axisStart: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], axisEnd: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) Solid

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 (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) -- the start point of the axis of rotation

  • axisEnd (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) -- the end point of the axis of rotation

戻り値:

a Solid object

戻り値の型:

Solid

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.

classmethod sweep(face: Face, path: Union[Wire, Edge], makeSolid: bool = True, isFrenet: bool = False, mode: Optional[Union[Vector, Wire, Edge]] = None, transitionMode: Literal['transformed', 'round', 'right'] = 'transformed') Shape[ソース]
classmethod sweep(outerWire: Wire, innerWires: List[Wire], path: Union[Wire, Edge], makeSolid: bool = True, isFrenet: bool = False, mode: Optional[Union[Vector, Wire, Edge]] = None, transitionMode: Literal['transformed', 'round', 'right'] = 'transformed') Shape

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 (Optional[Union[Vector, Wire, Edge]]) -- 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').

戻り値:

a Solid object

戻り値の型:

Shape

classmethod sweep_multi(profiles: Iterable[Union[Wire, Face]], path: Union[Wire, Edge], makeSolid: bool = True, isFrenet: bool = False, mode: Optional[Union[Vector, Wire, Edge]] = None) Solid[ソース]

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

パラメータ:
  • profiles (Iterable[Union[Wire, Face]]) -- list of profiles

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

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

  • makeSolid (bool) --

  • isFrenet (bool) --

戻り値:

a Solid object

戻り値の型:

Solid

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

ベースクラス: Selector

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 Selectors Reference for more information

__init__(selectorString)[ソース]

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

filter(objectList: Sequence[Shape])[ソース]

Filter give object list through th already constructed complex selector object

パラメータ:

objectList (Sequence[Shape]) --

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

ベースクラス: Selector

所定のジオメトリタイプを持つオブジェクトを選択します。

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: str)[ソース]
パラメータ:

typeString (str) --

filter(objectList: Sequence[Shape]) List[Shape][ソース]

Filter the provided list.

The default implementation returns the original list unfiltered.

パラメータ:

objectList (list of OCCT primitives) -- list to filter

戻り値:

filtered list

戻り値の型:

List[Shape]

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

ベースクラス: object

3次元ベクトルを作成する

パラメータ:

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() Vector[ソース]

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: Vector) bool[ソース]

Return self==value.

パラメータ:

other (Vector) --

戻り値の型:

bool

__hash__ = None
__init__(x: float, y: float, z: float) None[ソース]
__init__(x: float, y: float) None
__init__(v: Vector) None
__init__(v: Sequence[float]) None
__init__(v: Union[gp_Vec, gp_Pnt, gp_Dir, gp_XYZ]) None
__init__() None
__repr__() str[ソース]

Return repr(self).

戻り値の型:

str

__str__() str[ソース]

Return str(self).

戻り値の型:

str

__weakref__

list of weak references to the object (if defined)

multiply(scale: float) Vector[ソース]

Return a copy multiplied by the provided scalar

パラメータ:

scale (float) --

戻り値の型:

Vector

normalized() Vector[ソース]

Return a normalized version of this vector

戻り値の型:

Vector

projectToLine(line: Vector) Vector[ソース]

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

パラメータ:
  • args -- Vector

  • line (Vector) --

戻り値の型:

Vector

Returns the projected vector.

projectToPlane(plane: Plane) Vector[ソース]

Vector is projected onto the plane provided as input.

パラメータ:
  • args -- Plane object

  • plane (Plane) --

戻り値の型:

Vector

Returns the projected vector.

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

ベースクラス: Shape

空間の中の一点

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

  • forConstruction (bool) --

Center() Vector[ソース]

The center of a vertex is itself!

戻り値の型:

Vector

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

Create a vertex

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

  • forConstruction (bool) --

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

ベースクラス: Shape, Mixin1D

接続され、順序付けられた一連のEdgeで、通常、Faceを囲みます。

パラメータ:

obj (TopoDS_Shape) --

Vertices() List[Vertex][ソース]

Ordered list of vertices of the wire.

戻り値の型:

List[Vertex]

__iter__() Iterator[Edge][ソース]

Iterate over edges in an ordered way.

戻り値の型:

Iterator[Edge]

classmethod assembleEdges(listOfEdges: Iterable[Edge]) Wire[ソース]

Attempts to build a wire that consists of the edges in the provided list

パラメータ:
  • cls --

  • listOfEdges (Iterable[Edge]) -- a list of Edge objects. The edges are not to be consecutive.

戻り値:

a wire with the edges assembled

戻り値の型:

Wire

BRepBuilderAPI_MakeWire::Error() values:

  • BRepBuilderAPI_WireDone = 0

  • BRepBuilderAPI_EmptyWire = 1

  • BRepBuilderAPI_DisconnectedWire = 2

  • BRepBuilderAPI_NonManifoldWire = 3

chamfer2D(d: float, vertices: Iterable[Vertex]) Wire[ソース]

Apply 2D chamfer to a wire

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

  • vertices (Iterable[Vertex]) --

戻り値の型:

Wire

close() Wire[ソース]

Close a Wire

戻り値の型:

Wire

classmethod combine(listOfWires: Iterable[Union[Wire, Edge]], tol: float = 1e-09) List[Wire][ソース]

Attempt to combine a list of wires and edges into a new wire.

パラメータ:
  • cls --

  • listOfWires (Iterable[Union[Wire, Edge]]) --

  • tol (float) -- default 1e-9

戻り値:

List[Wire]

戻り値の型:

List[Wire]

fillet(radius: float, vertices: Optional[Iterable[Vertex]] = None) Wire[ソース]

Apply 2D or 3D fillet to a wire

パラメータ:
  • radius (float) -- the radius of the fillet, must be > zero

  • vertices (Optional[Iterable[Vertex]]) -- the vertices to delete (where the fillet will be applied). By default all vertices are deleted except ends of open wires.

戻り値:

A wire with filleted corners

戻り値の型:

Wire

fillet2D(radius: float, vertices: Iterable[Vertex]) Wire[ソース]

Apply 2D fillet to a wire

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

  • vertices (Iterable[Vertex]) --

戻り値の型:

Wire

classmethod makeCircle(radius: float, center: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], normal: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) Wire[ソース]

Makes a Circle centered at the provided point, having normal in the provided direction

パラメータ:
  • radius (float) -- floating point radius of the circle, must be > 0

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

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

戻り値の型:

Wire

classmethod makeEllipse(x_radius: float, y_radius: float, center: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], normal: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], xDir: Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]], angle1: float = 360.0, angle2: float = 360.0, rotation_angle: float = 0.0, closed: bool = True) Wire[ソース]

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

パラメータ:
  • x_radius (float) -- floating point major radius of the ellipse (x-axis), must be > 0

  • y_radius (float) -- floating point minor radius of the ellipse (y-axis), must be > 0

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

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

  • angle1 (float) -- start angle of arc

  • angle2 (float) -- end angle of arc

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

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

  • closed (bool) --

戻り値の型:

Wire

classmethod makeHelix(pitch: float, height: float, radius: float, center: ~typing.Union[~cadquery.occ_impl.geom.Vector, ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float]], ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float], ~typing.Union[int, float]]] = Vector: (0.0, 0.0, 0.0), dir: ~typing.Union[~cadquery.occ_impl.geom.Vector, ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float]], ~typing.Tuple[~typing.Union[int, float], ~typing.Union[int, float], ~typing.Union[int, float]]] = Vector: (0.0, 0.0, 1.0), angle: float = 360.0, lefthand: bool = False) Wire[ソース]

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'

パラメータ:
  • pitch (float) --

  • height (float) --

  • radius (float) --

  • center (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) --

  • dir (Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]) --

  • angle (float) --

  • lefthand (bool) --

戻り値の型:

Wire

classmethod makePolygon(listOfVertices: Iterable[Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]], forConstruction: bool = False, close: bool = False) Wire[ソース]

Construct a polygonal wire from points.

パラメータ:
  • listOfVertices (Iterable[Union[Vector, Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float], Union[int, float]]]]) --

  • forConstruction (bool) --

  • close (bool) --

戻り値の型:

Wire

offset2D(d: float, kind: Literal['arc', 'intersection', 'tangent'] = 'arc') List[Wire][ソース]

Offsets a planar wire

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

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

戻り値の型:

List[Wire]

stitch(other: Wire) Wire[ソース]

Attempt to stitch wires

パラメータ:

other (Wire) --

戻り値の型:

Wire

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

ベースクラス: object

2次元座標を使用できる空間上の座標系を定義します。

パラメータ:
  • 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 workplane()

__add__(other: Union[Workplane, Solid, Compound]) T[ソース]

Syntactic sugar for union.

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

パラメータ:
戻り値の型:

T

__and__(other: Union[Workplane, Solid, Compound]) T[ソース]

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
パラメータ:
戻り値の型:

T

__init__(obj: Union[Vector, Location, Shape, Sketch]) None[ソース]
__init__(inPlane: Union[Plane, str] = 'XY', origin: Union[Tuple[float, float], Tuple[float, float, float], Vector] = (0, 0, 0), obj: Optional[Union[Vector, Location, Shape, Sketch]] = 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.

__iter__() Iterator[Shape][ソース]

Special method for iterating over Shapes in objects

パラメータ:

self (T) --

戻り値の型:

Iterator[Shape]

__mul__(other: Union[Workplane, Solid, Compound]) T[ソース]

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
パラメータ:
戻り値の型:

T

__or__(other: Union[Workplane, Solid, Compound]) T[ソース]

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
パラメータ:
戻り値の型:

T

__sub__(other: Union[Workplane, Solid, Compound]) T[ソース]

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
パラメータ:
戻り値の型:

T

__truediv__(other: Union[Workplane, Solid, Compound]) T[ソース]

Syntactic sugar for intersect.

Notice that r = a / b is equivalent to r = a.split(b).

Example:

Box = Workplane("XY").box(1, 1, 1, centered=(False, False, False))
Sphere = Workplane("XY").sphere(1)
result = Box / Sphere
パラメータ:
戻り値の型:

T

__weakref__

list of weak references to the object (if defined)

add(obj: Workplane) T[ソース]
add(obj: Union[Vector, Location, Shape, Sketch]) T
add(obj: Iterable[Union[Vector, Location, Shape, Sketch]]) 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 a 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.

all() List[T][ソース]

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]

ancestors(kind: Literal['Vertex', 'Edge', 'Wire', 'Face', 'Shell', 'Solid', 'CompSolid', 'Compound'], tag: Optional[str] = None) T[ソース]

Select topological ancestors.

パラメータ:
  • kind (Literal['Vertex', 'Edge', 'Wire', 'Face', 'Shell', 'Solid', 'CompSolid', 'Compound']) -- kind of ancestor, e.g. "Face" or "Edge"

  • tag (Optional[str]) -- if set, search the tagged object instead of self

  • self (T) --

戻り値:

a Workplane object whose stack contains selected ancestors.

戻り値の型:

T

apply(f: Callable[[Iterable[Union[Vector, Location, Shape, Sketch]]], Iterable[Union[Vector, Location, Shape, Sketch]]]) T[ソース]

Apply a callable to all items at once.

パラメータ:
戻り値:

Workplane object with f applied to all items.

戻り値の型:

T

bezier(listOfXYTuple: Iterable[Union[Tuple[float, float], Tuple[float, float, float], Vector]], forConstruction: bool = False, includeCurrent: bool = False, makeWire: bool = False) T[ソース]

Make a cubic Bézier curve by the provided points (2D or 3D).

パラメータ:
  • listOfXYTuple (Iterable[Union[Tuple[float, float], Tuple[float, float, float], Vector]]) -- Bezier control points and end point. All points except the last point are Bezier control points, and the last point is the end point

  • includeCurrent (bool) -- Use the current point as a starting point of the curve

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

  • self (T) --

  • forConstruction (bool) --

戻り値:

a Workplane object with the current point at the end of the bezier

戻り値の型:

T

The Bézier Will begin at either current point or the first point of listOfXYTuple, and end with the last point of listOfXYTuple

box(length: float, width: float, height: float, centered: Union[bool, Tuple[bool, bool, bool]] = True, combine: Union[bool, Literal['cut', 'a', 's']] = True, clean: bool = True) T[ソース]

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

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

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

  • height (float) -- 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 (Union[bool, Literal['cut', 'a', 's']]) -- should the results be combined with other solids on the stack (and each other)?

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

  • self (T) --

戻り値の型:

T

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)
)
cboreHole(diameter: float, cboreDiameter: float, cboreDepth: float, depth: Optional[float] = None, clean: bool = True) T[ソース]

Makes a counterbored hole for each item on the stack.

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

  • cboreDiameter (float) -- the diameter of the cbore, must be greater than hole diameter

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

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

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

  • self (T) --

戻り値の型:

T

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()
    .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

center(x: float, y: float) T[ソース]

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

  • self (T) --

戻り値:

the Workplane object, with the center adjusted.

戻り値の型:

T

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

chamfer(length: float, length2: Optional[float] = None) T[ソース]

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 (float) -- the length of the chamfer, must be greater than zero

  • length2 (Optional[float]) -- optional parameter for asymmetrical chamfer

  • self (T) --

例外:
  • ValueError -- if at least one edge is not selected

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

戻り値:

CQ object with the resulting solid selected.

戻り値の型:

T

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)
circle(radius: float, forConstruction: bool = False) T[ソース]

Make a circle for each item on the stack.

パラメータ:
  • radius (float) -- 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?

  • self (T) --

戻り値:

a new CQ object with the created wires on the stack

戻り値の型:

T

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

clean() T[ソース]

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() T[ソース]

End construction, and attempt to build a closed wire.

戻り値:

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

パラメータ:

self (T) --

戻り値の型:

T

After 2D (or 3D) 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)
combine(clean: bool = True, glue: bool = False, tol: Optional[float] = None) T[ソース]

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) --

Raises:

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

戻り値:

a CQ object with the resulting object selected

戻り値の型:

T

combineSolids(otherCQToCombine: Optional[Workplane] = None) Workplane[ソース]

!!!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.

戻り値:

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

戻り値の型:

Workplane

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: Optional[Union[str, Selector]] = None, tag: Optional[str] = None) T[ソース]

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 (Optional[Union[str, Selector]]) -- optional Selector object, or string selector expression (see StringSyntaxSelector)

  • tag (Optional[str]) -- if set, search the tagged object instead of self

  • self (T) --

戻り値:

a CQ object whose stack contains all of the distinct compounds of all objects on the current stack, filtered by the provided selector.

戻り値の型:

T

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.

consolidateWires() T[ソース]

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: T) T[ソース]

Copies the workplane from obj.

パラメータ:

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

戻り値:

a CQ object with obj's workplane

戻り値の型:

T

cskHole(diameter: float, cskDiameter: float, cskAngle: float, depth: Optional[float] = None, clean: bool = True) T[ソース]

Makes a countersunk hole for each item on the stack.

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

  • cskDiameter (float) -- the diameter of the countersink, must be greater than hole diameter

  • 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 (bool) -- call clean() afterwards to have a clean shape

  • self (T) --

戻り値の型:

T

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()
    .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

cut(toCut: Union[Workplane, Solid, Compound], clean: bool = True, tol: Optional[float] = None) T[ソース]

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

パラメータ:
  • toCut (Union[Workplane, Solid, Compound]) -- a solid object, or a Workplane object having a solid

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

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

  • self (T) --

例外:

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

戻り値:

a Workplane object with the resulting object selected

戻り値の型:

T

cutBlind(until: Union[float, Literal['next', 'last'], Face], clean: bool = True, both: bool = False, taper: Optional[float] = None) T[ソース]

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

Specify either a distance value, or one of "next", "last" to indicate a face to cut to.

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 an object of type Face is passed, then the cut will extend until this face.

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

  • both (bool) -- cut in both directions symmetrically

  • taper (Optional[float]) -- angle for optional tapered extrusion

  • self (T) --

例外:

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

戻り値:

a CQ object with the resulting object selected

戻り値の型:

T

see cutThruAll() to cut material from the entire part

cutEach(fcn: Callable[[Location], Shape], useLocalCoords: bool = False, clean: bool = True) T[ソース]

Evaluates the provided function at each point on the stack (ie, eachpoint) and then cuts the result from the context solid.

パラメータ:
  • fcn (Callable[[Location], Shape]) -- a function suitable for use in the eachpoint method: ie, that accepts a vector

  • useLocalCoords (bool) -- same as for eachpoint()

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

  • self (T) --

例外:

ValueError -- if no solids or compounds are found in the stack or parent chain

戻り値:

a CQ object that contains the resulting solid

戻り値の型:

T

cutThruAll(clean: bool = True, taper: float = 0) T[ソース]

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 (bool) -- call clean() afterwards to have a clean shape

  • self (T) --

  • taper (float) --

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

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

戻り値:

a CQ object with the resulting object selected

戻り値の型:

T

see cutBlind() to cut material to a limited depth

cylinder(height: float, radius: float, direct: ~typing.Union[~typing.Tuple[float, float, float], ~cadquery.occ_impl.geom.Vector] = Vector: (0.0, 0.0, 1.0), angle: float = 360, centered: ~typing.Union[bool, ~typing.Tuple[bool, bool, bool]] = True, combine: ~typing.Union[bool, ~typing.Literal['cut', 'a', 's']] = True, clean: bool = True) T[ソース]

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

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

  • radius (float) -- 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

  • self (T) --

戻り値:

A cylinder object for each point on the stack

戻り値の型:

T

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.

each(callback: Callable[[Union[Vector, Location, Shape, Sketch]], Shape], useLocalCoordinates: bool = False, combine: Union[bool, Literal['cut', 'a', 's']] = True, clean: bool = True) T[ソース]

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 (bool) -- should values be converted from local coordinates first?

  • combine (Union[bool, Literal['cut', 'a', 's']]) -- True or "a" to combine the resulting solid with parent solids if found, "cut" or "s" to remove the resulting solid from the parent solids if found. False to keep the resulting solid separated from the parent solids.

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

  • self (T) --

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

戻り値の型:

T

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

eachpoint(arg: Union[Shape, Workplane, Callable[[Location], Shape]], useLocalCoordinates: bool = False, combine: Union[bool, Literal['cut', 'a', 's']] = False, clean: bool = True) T[ソース]

Same as each(), except arg is translated by the positions on the stack. If arg is a callback function, then the function is called for each point on the stack, and the resulting shape is used. :return: CadQuery object which contains a list of vectors (points ) on its stack.

パラメータ:
  • useLocalCoordinates (bool) -- should points be in local or global coordinates

  • combine (Union[bool, Literal['cut', 'a', 's']]) -- True or "a" to combine the resulting solid with parent solids if found, "cut" or "s" to remove the resulting solid from the parent solids if found. False to keep the resulting solid separated from the parent solids.

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

  • self (T) --

  • arg (Union[Shape, Workplane, Callable[[Location], Shape]]) --

戻り値の型:

T

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

edges(selector: Optional[Union[str, Selector]] = None, tag: Optional[str] = None) T[ソース]

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 (Optional[Union[str, Selector]]) -- optional Selector object, or string selector expression (see StringSyntaxSelector)

  • tag (Optional[str]) -- if set, search the tagged object instead of self

  • self (T) --

戻り値:

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

戻り値の型:

T

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:

Workplane().box(1, 1, 1).faces("+Z").edges().size()

returns 4, because the topmost face of a cube will contain four edges. Similarly:

Workplane().box(1, 1, 1).edges().size()

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

Workplane().box(1, 1, 1).edges("|Z").size()

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

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

Make an ellipse for each item on the stack.

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

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

  • rotation_angle (float) -- angle to rotate the ellipse

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

  • self (T) --

戻り値:

a new CQ object with the created wires on the stack

戻り値の型:

T

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)
ellipseArc(x_radius: float, y_radius: float, angle1: float = 360, angle2: float = 360, rotation_angle: float = 0.0, sense: Literal[- 1, 1] = 1, forConstruction: bool = False, startAtCurrent: bool = True, makeWire: bool = False) T[ソース]

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: int = 1) Workplane[ソース]

Return the nth parent of this CQ element

パラメータ:

n (int) -- number of ancestor to return (default: 1)

戻り値の型:

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")
export(fname: str, tolerance: float = 0.1, angularTolerance: float = 0.1, opt: Optional[Dict[str, Any]] = None) T[ソース]

Export Workplane to file.

パラメータ:
  • path -- Filename.

  • tolerance (float) -- the deflection tolerance, in model units. Default 0.1.

  • angularTolerance (float) -- the angular tolerance, in radians. Default 0.1.

  • opt (Optional[Dict[str, Any]]) -- additional options passed to the specific exporter. Default None.

  • self (T) --

  • fname (str) --

戻り値:

Self.

戻り値の型:

T

exportSvg(fileName: str) None