|
67 | 67 | from pyvista import MultiBlock, PolyData |
68 | 68 |
|
69 | 69 | from ansys.geometry.core.designer.component import Component |
| 70 | + from ansys.geometry.core.designer.selection import NamedSelection |
70 | 71 |
|
71 | 72 | # TODO: Temporary fix for boolean operations |
72 | 73 | # This is a temporary fix for the boolean operations issue. The issue is that the |
@@ -572,6 +573,17 @@ def copy(self, parent: "Component", name: str = None) -> "Body": |
572 | 573 | """ |
573 | 574 | return |
574 | 575 |
|
| 576 | + @abstractmethod |
| 577 | + def get_named_selections(self) -> list["NamedSelection"]: |
| 578 | + """Get the named selections associated with the body. |
| 579 | +
|
| 580 | + Returns |
| 581 | + ------- |
| 582 | + list[NamedSelection] |
| 583 | + List of named selections associated with the body. |
| 584 | + """ |
| 585 | + return |
| 586 | + |
575 | 587 | @abstractmethod |
576 | 588 | def get_raw_tessellation( |
577 | 589 | self, |
@@ -1052,6 +1064,7 @@ def _get_vertices_from_id(self, body: Union["Body", "MasterBody"]) -> list[Verte |
1052 | 1064 | Vertex( |
1053 | 1065 | vertex_resp.get("id"), |
1054 | 1066 | vertex_resp.get("position"), |
| 1067 | + body, |
1055 | 1068 | ) |
1056 | 1069 | for vertex_resp in response.get("vertices") |
1057 | 1070 | ] |
@@ -1279,6 +1292,14 @@ def copy(self, parent: "Component", name: str = None) -> "Body": # noqa: D102 |
1279 | 1292 | "Copy method is not implemented on the MasterBody. Call this method on a body instead." |
1280 | 1293 | ) |
1281 | 1294 |
|
| 1295 | + def get_named_selections(self) -> list["NamedSelection"]: # noqa: D102 |
| 1296 | + raise NotImplementedError( |
| 1297 | + """ |
| 1298 | + get_named_selections is not implemented at the MasterBody level. |
| 1299 | + Instead, call this method on a body. |
| 1300 | + """ |
| 1301 | + ) |
| 1302 | + |
1282 | 1303 | @min_backend_version(26, 1, 0) |
1283 | 1304 | def get_raw_tessellation( # noqa: D102 |
1284 | 1305 | self, |
@@ -1880,6 +1901,15 @@ def copy(self, parent: "Component", name: str = None) -> "Body": # noqa: D102 |
1880 | 1901 | body_id = f"{parent.id}/{tb.id}" if parent.parent_component else tb.id |
1881 | 1902 | return Body(body_id, response.get("name"), parent, tb) |
1882 | 1903 |
|
| 1904 | + @ensure_design_is_active |
| 1905 | + def get_named_selections(self) -> list["NamedSelection"]: # noqa: D102 |
| 1906 | + included_ns = [] |
| 1907 | + for ns in get_design_from_body(self).named_selections: |
| 1908 | + if any(body.id == self.id for body in ns.bodies): |
| 1909 | + included_ns.append(ns) |
| 1910 | + |
| 1911 | + return included_ns |
| 1912 | + |
1883 | 1913 | @ensure_design_is_active |
1884 | 1914 | def get_raw_tessellation( # noqa: D102 |
1885 | 1915 | self, |
|
0 commit comments