Skip to content

Commit bb20cd8

Browse files
committed
Add active_point_result class and getter function
Signed-off-by: Michael Brunner <brunner@cadwork.swiss>
1 parent df3877d commit bb20cd8

File tree

5 files changed

+42
-1
lines changed

5 files changed

+42
-1
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# active_point_result
2+
3+
::: cadwork.active_point_result
4+
rendering:
5+
show_root_heading: false
6+
show_source: true

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ nav:
6464
- Element Map Query: documentation/element_map_query.md
6565
- Hit Result: documentation/hit_result.md
6666
- Coordinate System Data: documentation/coordinate_system_data.md
67+
- Active Point Result: documentation/active_point_result.md
6768
- Connector Axis Controller: documentation/connector_axis_controller.md
6869
- Dimension Controller: documentation/dimension_controller.md
6970
- Element Controller: documentation/element_controller.md

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "cwapi3d"
3-
version = "32.402.0"
3+
version = "32.443.0"
44
authors = [{ name = "Cadwork", email = "it@cadwork.ca" }]
55
requires-python = ">= 3.12"
66
description = 'Python bindings for CwAPI3D'

src/cadwork/active_point_result.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from dataclasses import dataclass
2+
from typing import Optional
3+
from cadwork import point_3d
4+
5+
6+
@dataclass(frozen=True)
7+
class active_point_result:
8+
has_point: bool
9+
point: Optional["point_3d"] = None
10+
11+
def __bool__(self) -> bool:
12+
return self.has_point

src/element_controller/__init__.pyi

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ from cadwork.coordinate_system_data import coordinate_system_data
99
from cadwork.element_map_query import element_map_query
1010
from cadwork.element_filter import element_filter
1111
from cadwork.hit_result import hit_result
12+
from cadwork.active_point_result import active_point_result
1213
from cadwork.vertex_list import vertex_list
1314
from cadwork.shoulder_options import shoulder_options
1415
from cadwork.heel_shoulder_options import heel_shoulder_options
@@ -2278,3 +2279,24 @@ def cast_ray_and_get_element_intersections(element_id_list: List[ElementId], ray
22782279
Returns:
22792280
Contains list of elements that were hit by the ray and list of vertices that are queried via ElementID.
22802281
"""
2282+
2283+
2284+
def get_element_active_point(element_id: ElementId) -> active_point_result:
2285+
"""Gets the active point associated with an element.
2286+
2287+
Parameters:
2288+
element_id: The element id.
2289+
2290+
Examples:
2291+
>>> import cadwork
2292+
>>> import element_controller as ec
2293+
>>> [element_id] = ec.get_active_identifiable_element_ids()
2294+
>>> result = ec.get_element_active_point(element_id)
2295+
>>> if result:
2296+
... ec.create_node(result.point)
2297+
... else:
2298+
... print("No active point set for element.")
2299+
2300+
Returns:
2301+
True/False plus point data when available.
2302+
"""

0 commit comments

Comments
 (0)