-
Notifications
You must be signed in to change notification settings - Fork 22
feat: add Named Selections query to geometric entities #2356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
bb2d14b
cba074d
f5c5581
f661026
40a65cf
ca0e812
2e0c925
a22c4d2
7f1358f
038d2e7
323b6dc
c87f8be
843cf03
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add Named Selections query to geometric entities |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -67,6 +67,7 @@ | |||||||||||||
| from pyvista import MultiBlock, PolyData | ||||||||||||||
|
|
||||||||||||||
| from ansys.geometry.core.designer.component import Component | ||||||||||||||
| from ansys.geometry.core.designer.selection import NamedSelection | ||||||||||||||
|
|
||||||||||||||
| # TODO: Temporary fix for boolean operations | ||||||||||||||
| # 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": | |||||||||||||
| """ | ||||||||||||||
| return | ||||||||||||||
|
|
||||||||||||||
| @abstractmethod | ||||||||||||||
| def get_named_selections(self) -> list["NamedSelection"]: | ||||||||||||||
| """Get the named selections associated with the body. | ||||||||||||||
|
|
||||||||||||||
| Returns | ||||||||||||||
| ------- | ||||||||||||||
| list[NamedSelection] | ||||||||||||||
| List of named selections associated with the body. | ||||||||||||||
| """ | ||||||||||||||
| return | ||||||||||||||
|
|
||||||||||||||
| @abstractmethod | ||||||||||||||
| def get_raw_tessellation( | ||||||||||||||
| self, | ||||||||||||||
|
|
@@ -1052,6 +1064,7 @@ def _get_vertices_from_id(self, body: Union["Body", "MasterBody"]) -> list[Verte | |||||||||||||
| Vertex( | ||||||||||||||
| vertex_resp.get("id"), | ||||||||||||||
| vertex_resp.get("position"), | ||||||||||||||
| body, | ||||||||||||||
| ) | ||||||||||||||
| for vertex_resp in response.get("vertices") | ||||||||||||||
| ] | ||||||||||||||
|
|
@@ -1279,6 +1292,16 @@ def copy(self, parent: "Component", name: str = None) -> "Body": # noqa: D102 | |||||||||||||
| "Copy method is not implemented on the MasterBody. Call this method on a body instead." | ||||||||||||||
| ) | ||||||||||||||
|
|
||||||||||||||
| def get_named_selections(self, body: "Body") -> list["NamedSelection"]: # noqa: D102 | ||||||||||||||
| named_selections = get_design_from_body(body).named_selections | ||||||||||||||
|
|
||||||||||||||
| included_ns = [] | ||||||||||||||
| for ns in named_selections: | ||||||||||||||
|
Comment on lines
+1296
to
+1299
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| if body.id in [body.id for body in ns.bodies]: | ||||||||||||||
| included_ns.append(ns) | ||||||||||||||
|
|
||||||||||||||
| return included_ns | ||||||||||||||
|
|
||||||||||||||
| @min_backend_version(26, 1, 0) | ||||||||||||||
| def get_raw_tessellation( # noqa: D102 | ||||||||||||||
| self, | ||||||||||||||
|
|
@@ -1880,6 +1903,10 @@ def copy(self, parent: "Component", name: str = None) -> "Body": # noqa: D102 | |||||||||||||
| body_id = f"{parent.id}/{tb.id}" if parent.parent_component else tb.id | ||||||||||||||
| return Body(body_id, response.get("name"), parent, tb) | ||||||||||||||
|
|
||||||||||||||
| @ensure_design_is_active | ||||||||||||||
| def get_named_selections(self) -> list["NamedSelection"]: # noqa: D102 | ||||||||||||||
| return self._template.get_named_selections(self) | ||||||||||||||
|
Comment on lines
+1906
to
+1908
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should probably be done at the body level. I will change this |
||||||||||||||
|
|
||||||||||||||
| @ensure_design_is_active | ||||||||||||||
| def get_raw_tessellation( # noqa: D102 | ||||||||||||||
| self, | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,13 +24,15 @@ | |||||||||||||
| from typing import TYPE_CHECKING, Union | ||||||||||||||
|
|
||||||||||||||
| from ansys.geometry.core.math.point import Point3D | ||||||||||||||
| from ansys.geometry.core.misc.auxiliary import get_design_from_component | ||||||||||||||
| from ansys.geometry.core.misc.checks import graphics_required | ||||||||||||||
| from ansys.geometry.core.misc.units import UNITS | ||||||||||||||
|
|
||||||||||||||
| if TYPE_CHECKING: # pragma: no cover | ||||||||||||||
| import pyvista as pv | ||||||||||||||
|
|
||||||||||||||
| from ansys.geometry.core.designer.component import Component | ||||||||||||||
| from ansys.geometry.core.designer.selection import NamedSelection | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| class DesignPoint: | ||||||||||||||
|
|
@@ -78,6 +80,26 @@ def parent_component(self) -> "Component": | |||||||||||||
| """Component node that the design point is under.""" | ||||||||||||||
| return self._parent_component | ||||||||||||||
|
|
||||||||||||||
| def get_named_selections(self) -> list["NamedSelection"]: | ||||||||||||||
| """Get named selections that contain this design point. | ||||||||||||||
|
|
||||||||||||||
| Returns | ||||||||||||||
| ------- | ||||||||||||||
| list[NamedSelection] | ||||||||||||||
| List of named selections that contain this design point. | ||||||||||||||
| """ | ||||||||||||||
| if self.parent_component is None: | ||||||||||||||
| raise ValueError("Design point does not have a parent component.") | ||||||||||||||
|
|
||||||||||||||
|
Comment on lines
+91
to
+93
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this even possible? Shouldn't it only be created from a modeling perspective? What's the case when a DesignPoint gets created without parent component? |
||||||||||||||
| named_selections = get_design_from_component(self.parent_component).named_selections | ||||||||||||||
|
|
||||||||||||||
| included_ns = [] | ||||||||||||||
| for ns in named_selections: | ||||||||||||||
|
Comment on lines
+94
to
+97
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Let's align all these =) |
||||||||||||||
| if self.id in [dp.id for dp in ns.design_points]: | ||||||||||||||
| included_ns.append(ns) | ||||||||||||||
|
|
||||||||||||||
| return included_ns | ||||||||||||||
|
|
||||||||||||||
| def __repr__(self) -> str: | ||||||||||||||
| """Represent the design points as a string.""" | ||||||||||||||
| lines = [f"ansys.geometry.core.designer.DesignPoints {hex(id(self))}"] | ||||||||||||||
|
|
||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.