Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/documentation/point_2d.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# point_2d

::: cadwork.point_2d
rendering:
show_root_heading: false
show_source: true
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ nav:
- Element Type: documentation/element_type.md
- Standard Element Type: documentation/standard_element_type.md
- Process Type: documentation/process_type.md
- Point 2D: documentation/point_2d.md
- Point 3D: documentation/point_3d.md
- Enumerations: documentation/enums.md
- Extended Settings: documentation/extended_settings.md
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "cwapi3d"
version = "33.321.0"
version = "33.322.0"
authors = [{ name = "Cadwork", email = "it@cadwork.ca" }]
requires-python = ">= 3.14"
description = 'Python bindings for CwAPI3D'
Expand Down
2 changes: 2 additions & 0 deletions src/cadwork/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ from .layer_settings import layer_settings as layer_settings
from .panel_prefab_element_data import panel_prefab_element_data as panel_prefab_element_data
from .panel_prefab_element_settings import panel_prefab_element_settings as panel_prefab_element_settings
from .point import point as point
from .point_2d import point_2d as point_2d
from .point_3d import point_3d as point_3d
from .polygon_list import polygon_list as polygon_list
from .rhino_options import rhino_options as rhino_options
Expand Down Expand Up @@ -131,6 +132,7 @@ __all__ = [
"panel_prefab_element_data",
"panel_prefab_element_settings",
"point",
"point_2d",
"point_3d",
"polygon_list",
"rhino_options",
Expand Down
59 changes: 59 additions & 0 deletions src/cadwork/point_2d.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
class point_2d:
"""A two-dimensional point or vector with the coordinates u and v.

Wherever a point_2d is expected, a plain ``(u, v)`` tuple of length 2 may be
passed instead: it is implicitly converted to a point_2d.
"""

def __init__(self, u: float = 0., v: float = 0.):
"""
Initialize an instance of a point_2d.

Parameters:
u (float): The u-coordinate of the point.
v (float): The v-coordinate of the point.
"""
self.u = u
self.v = v

def __eq__(self, other: object) -> bool:
"""
Check if two points are equal.

Returns:
bool: True if equal, False otherwise.
"""

def __ne__(self, other: object) -> bool:
"""
Check if two points are not equal.

Returns:
bool: True if not equal, False otherwise.
"""

def __getitem__(self, index: int) -> float:
"""
Get coordinate by index (0: u, 1: v).

Returns:
float: The coordinate value.
Raises:
IndexError: If index is out of range.
"""

def __setitem__(self, index: int, value: float) -> None:
"""
Set coordinate by index (0: u, 1: v).

Raises:
IndexError: If index is out of range.
"""

def __repr__(self) -> str:
"""
Return the string representation of the point.

Returns:
str: The string representation.
"""
60 changes: 60 additions & 0 deletions src/element_controller/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ transforms what exists in the model.
from cadwork.edge_list import edge_list
from cadwork.element_module_properties import element_module_properties
from cadwork.facet_list import facet_list
from cadwork.point_2d import point_2d
from cadwork.point_3d import point_3d
from cadwork.standard_element_type import standard_element_type
from cadwork.text_object_options import text_object_options
Expand Down Expand Up @@ -391,6 +392,35 @@ def create_polygon_beam(polygon_vertices: vertex_list, thickness: float, x_local
The ID of the created polygon beam.
"""


def create_polygon_beam_vectors(polygon_vertices: list[point_2d | tuple[float, float]], thickness: float, starting_point: point_3d, x_local_direction: point_3d, z_local_direction: point_3d) -> ElementId:
"""Creates a polygon beam from a 2D profile using vectors.

The profile is defined in the local uv-plane of the beam and extruded from
the starting point along the x local direction.

Parameters:
polygon_vertices: The vertices of the 2D profile. Each vertex is a point_2d or a (u, v) tuple.
thickness: The thickness (extrusion length) of the beam.
starting_point: The starting point of the beam.
x_local_direction: The x local direction of the beam.
z_local_direction: The z local direction of the beam.

Examples:
>>> # Create a triangular beam from a 2D profile
>>> profile = [cadwork.point_2d(0., 0.), cadwork.point_2d(200., 0.), cadwork.point_2d(100., 173.2)]
>>> beam_thickness = 1000. # Length of the beam
>>> start_point = cadwork.point_3d(0., 0., 0.)
>>> extrusion_vector = cadwork.point_3d(1., 0., 0.) # Direction of extrusion
>>> z_vector = cadwork.point_3d(0., 0., 1.) # Orientation vector
>>> polygon_beam_id = ec.create_polygon_beam_vectors(profile, beam_thickness, start_point, extrusion_vector, z_vector)
>>> # Tuples are implicitly converted to point_2d
>>> polygon_beam_id = ec.create_polygon_beam_vectors([(0., 0.), (200., 0.), (100., 173.2)], beam_thickness, start_point, extrusion_vector, z_vector)

Returns:
The ID of the created polygon beam.
"""

def create_text_object(text: str, position: point_3d, x_local_direction: point_3d, z_local_direction: point_3d, size: float) -> ElementId:
"""Creates a text object.

Expand Down Expand Up @@ -1323,6 +1353,36 @@ def create_polygon_panel(polygon_vertices: vertex_list, thickness: float, x_loca
The ID of the created polygon panel element.
"""


def create_polygon_panel_vectors(polygon_vertices: list[point_2d | tuple[float, float]], thickness: float, starting_point: point_3d, x_local_direction: point_3d, z_local_direction: point_3d) -> ElementId:
"""Creates a polygon panel from a 2D profile using vectors.

The profile is defined in the local uv-plane of the panel and extruded from
the starting point along the x local direction.

Parameters:
polygon_vertices: The vertices of the 2D profile. Each vertex is a point_2d or a (u, v) tuple.
thickness: The thickness (extrusion length) of the panel.
starting_point: The starting point of the panel.
x_local_direction: The X-axis direction of the panel.
z_local_direction: The Z-axis direction of the panel.

Examples:
>>> # Create a hexagonal panel from a 2D profile
>>> import math
>>> radius = 500.
>>> sides = 6
>>> profile = [cadwork.point_2d(radius * math.cos(2 * math.pi * i / sides), radius * math.sin(2 * math.pi * i / sides)) for i in range(sides)]
>>> panel_thickness = 20.
>>> start_point = cadwork.point_3d(0., 0., 0.)
>>> extrusion_vector = cadwork.point_3d(0., 0., 1.) # Normal direction
>>> z_vector = cadwork.point_3d(1., 0., 0.) # Orientation vector
>>> polygon_panel_id = ec.create_polygon_panel_vectors(profile, panel_thickness, start_point, extrusion_vector, z_vector)

Returns:
The ID of the created polygon panel element.
"""

def cut_elements_with_overmeasure(hard_element_id_list: list[ElementId], soft_element_id_list: list[ElementId]) -> None:
"""Cuts elements with overmeasure.

Expand Down
Loading