Geometry#
2D and 3D geometry types used internally by OpenVCAD. You may not need to use these directly, but they are useful for creating custom geometry.
- class pyvcad.Point2#
- __init__(*args, **kwargs)#
Overloaded function.
__init__(self: pyvcad.pyvcad.Point2) -> None
Default constructor creating a point at origin (0,0)
Example
>>> p = Point2() >>> print(f'({p.x()}, {p.y()})') (0.0, 0.0)
__init__(self: pyvcad.pyvcad.Point2, arg0: typing.SupportsFloat, arg1: typing.SupportsFloat) -> None
Create a 2D point with given x and y coordinates
- Parameters:
x (float) – X coordinate
y (float) – Y coordinate
Example
>>> p = Point2(1.0, 2.0) >>> print(f'({p.x()}, {p.y()})') (1.0, 2.0)
- x(self: pyvcad.pyvcad.Point2) float#
Get the x coordinate of the point
- Returns:
X coordinate
- Return type:
float
- y(self: pyvcad.pyvcad.Point2) float#
Get the y coordinate of the point
- Returns:
Y coordinate
- Return type:
float
- class pyvcad.Segment2#
- __init__(self: pyvcad.pyvcad.Segment2, arg0: pyvcad.pyvcad.Point2, arg1: pyvcad.pyvcad.Point2) None#
Create a 2D line segment between two points
- Parameters:
Example
>>> p1 = Point2(0.0, 0.0) >>> p2 = Point2(1.0, 1.0) >>> segment = Segment2(p1, p2) >>> source = segment.source() >>> target = segment.target() >>> print(f'From ({source.x()}, {source.y()}) to ({target.x()}, {target.y()})') From (0.0, 0.0) to (1.0, 1.0)
- source(self: pyvcad.pyvcad.Segment2) pyvcad.pyvcad.Point2#
Returns the source point of the segment
- Returns:
The starting point of the segment
- Return type:
- target(self: pyvcad.pyvcad.Segment2) pyvcad.pyvcad.Point2#
Returns the target point of the segment
- Returns:
The ending point of the segment
- Return type:
- class pyvcad.Vec2#
- __init__(*args, **kwargs)#
Overloaded function.
__init__(self: pyvcad.pyvcad.Vec2) -> None
Default constructor creating a zero vector (0,0)
Example
>>> v = Vec2() >>> print(f'({v.x}, {v.y})') (0.0, 0.0)
__init__(self: pyvcad.pyvcad.Vec2, arg0: typing.SupportsFloat, arg1: typing.SupportsFloat) -> None
Create a 2D vector with given x and y components
- Parameters:
x (float) – X component
y (float) – Y component
Example
>>> v = Vec2(1.0, 2.0) >>> print(f'({v.x}, {v.y})') (1.0, 2.0)
- property x#
X component of the vector
- property y#
Y component of the vector
- class pyvcad.Vec3#
- __init__(*args, **kwargs)#
Overloaded function.
__init__(self: pyvcad.pyvcad.Vec3) -> None
Default constructor creating a zero vector (0,0,0)
Example
>>> v = Vec3() >>> print(f'({v.x}, {v.y}, {v.z})') (0.0, 0.0, 0.0)
__init__(self: pyvcad.pyvcad.Vec3, arg0: typing.SupportsFloat, arg1: typing.SupportsFloat, arg2: typing.SupportsFloat) -> None
Create a 3D vector with given x, y, and z components
- Parameters:
x (float) – X component
y (float) – Y component
z (float) – Z component
Example
>>> v = Vec3(1.0, 2.0, 3.0) >>> print(f'({v.x}, {v.y}, {v.z})') (1.0, 2.0, 3.0)
__init__(self: pyvcad.pyvcad.Vec3, arg0: collections.abc.Sequence[typing.SupportsFloat]) -> None
Create a 3D vector from a list or tuple of 3 floats
Example
>>> v = Vec3([1.0, 2.0, 3.0]) >>> print(f'({v.x}, {v.y}, {v.z})') (1.0, 2.0, 3.0)
- property x#
X component of the vector
- property y#
Y component of the vector
- property z#
Z component of the vector
- class pyvcad.Vec4#
- __init__(*args, **kwargs)#
Overloaded function.
__init__(self: pyvcad.pyvcad.Vec4) -> None
Default constructor creating a zero vector (0,0,0,0)
Example
>>> v = Vec4() >>> print(f'({v.r}, {v.g}, {v.b}, {v.a})') (0.0, 0.0, 0.0, 0.0)
__init__(self: pyvcad.pyvcad.Vec4, arg0: typing.SupportsFloat, arg1: typing.SupportsFloat, arg2: typing.SupportsFloat, arg3: typing.SupportsFloat) -> None
Create a 4D vector with given r, g, b, and a components
- Parameters:
r (float) – Red component
g (float) – Green component
b (float) – Blue component
a (float) – Alpha component
Example
>>> v = Vec4(1.0, 0.0, 0.0, 1.0) # Red color with full opacity >>> print(f'({v.r}, {v.g}, {v.b}, {v.a})') (1.0, 0.0, 0.0, 1.0)
- property a#
Alpha component of the vector
- property b#
Blue component of the vector
- property g#
Green component of the vector
- property r#
Red component of the vector
- class pyvcad.Polygon2#
- static Clip(arg0: collections.abc.Sequence[pyvcad.pyvcad.Polygon2], arg1: collections.abc.Sequence[Polyline2]) tuple[list[pyvcad.pyvcad.Polygon2], list[Polyline2]]#
- static Difference(arg0: collections.abc.Sequence[pyvcad.pyvcad.Polygon2], arg1: collections.abc.Sequence[pyvcad.pyvcad.Polygon2]) list[pyvcad.pyvcad.Polygon2]#
- static Intersection(arg0: collections.abc.Sequence[pyvcad.pyvcad.Polygon2], arg1: collections.abc.Sequence[pyvcad.pyvcad.Polygon2]) list[pyvcad.pyvcad.Polygon2]#
- static Offset(arg0: collections.abc.Sequence[pyvcad.pyvcad.Polygon2], arg1: SupportsFloat) list[pyvcad.pyvcad.Polygon2]#
- static Union(arg0: collections.abc.Sequence[pyvcad.pyvcad.Polygon2], arg1: collections.abc.Sequence[pyvcad.pyvcad.Polygon2]) list[pyvcad.pyvcad.Polygon2]#
- __init__(*args, **kwargs)#
Overloaded function.
__init__(self: pyvcad.pyvcad.Polygon2) -> None
__init__(self: pyvcad.pyvcad.Polygon2, arg0: collections.abc.Sequence[pyvcad.pyvcad.Point2]) -> None
__init__(self: pyvcad.pyvcad.Polygon2, arg0: collections.abc.Sequence[pyvcad.pyvcad.Vec2]) -> None
- bounding_box(self: pyvcad.pyvcad.Polygon2) tuple[pyvcad.pyvcad.Point2, pyvcad.pyvcad.Point2]#
- diff(self: pyvcad.pyvcad.Polygon2, arg0: pyvcad.pyvcad.Polygon2) list[pyvcad.pyvcad.Polygon2]#
- do_clip(self: pyvcad.pyvcad.Polygon2, arg0: collections.abc.Sequence[Polyline2]) tuple[list[pyvcad.pyvcad.Polygon2], list[Polyline2]]#
- do_union(*args, **kwargs)#
Overloaded function.
do_union(self: pyvcad.pyvcad.Polygon2, arg0: pyvcad.pyvcad.Polygon2) -> list[pyvcad.pyvcad.Polygon2]
do_union(self: pyvcad.pyvcad.Polygon2, arg0: collections.abc.Sequence[pyvcad.pyvcad.Polygon2]) -> list[pyvcad.pyvcad.Polygon2]
- double_area(self: pyvcad.pyvcad.Polygon2) float#
- draw(self: pyvcad.pyvcad.Polygon2) None#
- holes(self: pyvcad.pyvcad.Polygon2) list[pyvcad.pyvcad.Polygon2]#
- inside(self: pyvcad.pyvcad.Polygon2, arg0: pyvcad.pyvcad.Point2) bool#
- intersect(*args, **kwargs)#
Overloaded function.
intersect(self: pyvcad.pyvcad.Polygon2, arg0: pyvcad.pyvcad.Polygon2) -> list[pyvcad.pyvcad.Polygon2]
intersect(self: pyvcad.pyvcad.Polygon2, arg0: collections.abc.Sequence[pyvcad.pyvcad.Polygon2]) -> list[pyvcad.pyvcad.Polygon2]
- is_ccw(self: pyvcad.pyvcad.Polygon2) bool#
- offset(self: pyvcad.pyvcad.Polygon2, arg0: SupportsFloat) list[pyvcad.pyvcad.Polygon2]#
- on_boundary(self: pyvcad.pyvcad.Polygon2, arg0: pyvcad.pyvcad.Point2) bool#
- reverse(self: pyvcad.pyvcad.Polygon2) None#
- set_holes(self: pyvcad.pyvcad.Polygon2, arg0: collections.abc.Sequence[pyvcad.pyvcad.Polygon2]) None#
- simplify(self: pyvcad.pyvcad.Polygon2, tolerance: SupportsFloat = 0.001) None#
- to_polyline(self: pyvcad.pyvcad.Polygon2) Polyline2#
- class pyvcad.Polyline2#
- __init__(*args, **kwargs)#
Overloaded function.
__init__(self: pyvcad.pyvcad.Polyline2) -> None
__init__(self: pyvcad.pyvcad.Polyline2, arg0: collections.abc.Sequence[pyvcad.pyvcad.Point2]) -> None
__init__(self: pyvcad.pyvcad.Polyline2, arg0: collections.abc.Sequence[pyvcad.pyvcad.Vec2]) -> None
- append(self: pyvcad.pyvcad.Polyline2, arg0: pyvcad.pyvcad.Polyline2) None#
- length(self: pyvcad.pyvcad.Polyline2) float#
- points(self: pyvcad.pyvcad.Polyline2) list[pyvcad.pyvcad.Point2]#
- prepend(self: pyvcad.pyvcad.Polyline2, arg0: pyvcad.pyvcad.Polyline2) None#
- reverse(self: pyvcad.pyvcad.Polyline2) None#
- segments(self: pyvcad.pyvcad.Polyline2) list[pyvcad.pyvcad.Segment2]#
- simplify(self: pyvcad.pyvcad.Polyline2, tolerance: SupportsFloat = 0.001) None#
- translate(self: pyvcad.pyvcad.Polyline2, arg0: pyvcad.pyvcad.Point2) None#
- class pyvcad.Arrangement2#
A class representing a 2D arrangement of polygons and polylines. When polygons and polylines are inserted into the arrangement, they are split by each other and the resulting faces are stored in the arrangement.
- __init__(self: pyvcad.pyvcad.Arrangement2) None#
Default constructor. Creates an Arrangement2 object.
- getBoundedFaces(self: pyvcad.pyvcad.Arrangement2) list[pyvcad.pyvcad.Polygon2]#
Returns a list of all bounded faces in the arrangement.
- getUnboundedFaces(self: pyvcad.pyvcad.Arrangement2) list[pyvcad.pyvcad.Polygon2]#
Returns a list of all unbounded faces in the arrangement.
- insert(*args, **kwargs)#
Overloaded function.
insert(self: pyvcad.pyvcad.Arrangement2, polygon: pyvcad.pyvcad.Polygon2) -> None
Inserts a Polygon2 into the arrangement.
- Parameters:
polygon (Polygon2) – The polygon to insert.
insert(self: pyvcad.pyvcad.Arrangement2, polyline: pyvcad.pyvcad.Polyline2) -> None
Inserts a Polyline2 into the arrangement.
- Parameters:
polyline (Polyline2) – The polyline to insert.
- class pyvcad.HexahedralMesh#
Structured geometric hexahedral mesh.
- __init__(self: pyvcad.pyvcad.HexahedralMesh) None#
- bounding_box(self: pyvcad.pyvcad.HexahedralMesh) tuple[pyvcad.pyvcad.Vec3, pyvcad.pyvcad.Vec3]#
Returns the mesh bounding box.
- property cell_centroids#
Centroid of each element.
- property elements#
Hexahedral element connectivity.
- static from_tree(root: pyvcad.pyvcad.Node, settings: pyvcad.pyvcad.HexahedralMeshSettings) pyvcad.pyvcad.HexahedralMesh#
Build a structured hexahedral mesh from a tree.
- property nodes#
Mesh node coordinates.
- number_of_elements(self: pyvcad.pyvcad.HexahedralMesh) int#
Returns the number of elements.
- number_of_nodes(self: pyvcad.pyvcad.HexahedralMesh) int#
Returns the number of nodes.
- voxel_size(self: pyvcad.pyvcad.HexahedralMesh) pyvcad.pyvcad.Vec3#
Returns the voxel size used to build the mesh.