Skip to content

feat: vertex references #2083

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

Merged
merged 40 commits into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
bfe7779
wip - client side impl of get_vertices
jacobrkerstetter Jun 23, 2025
38a24e5
added GetVertices method to edges
jacobrkerstetter Jun 23, 2025
26d552f
added position property to Point3D
jacobrkerstetter Jun 23, 2025
44c6d85
added functionality for components to be sent to move_translate
jacobrkerstetter Jun 25, 2025
7dbbf00
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Jun 25, 2025
6d05dc3
chore: adding changelog file 2068.added.md [dependabot-skip]
pyansys-ci-bot Jun 25, 2025
5e99f81
added components to NS
jacobrkerstetter Jun 25, 2025
a7429f4
Merge branch 'feat/move_translate_components' of https://github.com/a…
jacobrkerstetter Jun 25, 2025
a28b463
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Jun 25, 2025
d29102a
chore: adding changelog file 2068.added.md [dependabot-skip]
pyansys-ci-bot Jun 25, 2025
d025c32
added components to "get" for named selections
jacobrkerstetter Jun 25, 2025
726434f
Merge branch 'feat/move_translate_components' of https://github.com/a…
jacobrkerstetter Jun 25, 2025
06cd9ec
Merge branch 'main' of https://github.com/ansys/pyansys-geometry into…
jacobrkerstetter Jun 25, 2025
b7e539c
Merge branch 'feat/move_translate_components' of https://github.com/a…
jacobrkerstetter Jun 25, 2025
5c6ce72
wip
jacobrkerstetter Jun 25, 2025
4c58a1d
wrap the components property for calls before 26.1
jacobrkerstetter Jun 25, 2025
8f43784
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Jun 25, 2025
52d2d88
Merge branch 'feat/move_translate_components' of https://github.com/a…
jacobrkerstetter Jun 30, 2025
2ff61ee
added vertices to NS
jacobrkerstetter Jun 30, 2025
e3c0669
added vertices to NS
jacobrkerstetter Jul 1, 2025
53867c4
edited NamedSelectionImport.scdocx to have a few vertices in a new group
jacobrkerstetter Jul 1, 2025
19309a4
add get vertices and test for faces
jacobrkerstetter Jul 1, 2025
5b6974e
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Jul 1, 2025
554b104
Merge branch 'main' into feat/edges_get_vertices
jacobrkerstetter Jul 1, 2025
ca94926
chore: adding changelog file 2083.added.md [dependabot-skip]
pyansys-ci-bot Jul 1, 2025
7b9a8de
Merge branch 'main' of https://github.com/ansys/pyansys-geometry into…
jacobrkerstetter Jul 2, 2025
1d5b696
edited create return statement
jacobrkerstetter Jul 2, 2025
064fb29
Merge branch 'feat/edges_get_vertices' of https://github.com/ansys/py…
jacobrkerstetter Jul 2, 2025
3669c39
fixed missing import
jacobrkerstetter Jul 2, 2025
2c84165
bump protos
jacobrkerstetter Jul 2, 2025
af41a11
Merge branch 'main' into feat/edges_get_vertices
jacobrkerstetter Jul 3, 2025
9458a3a
resolving comments
jacobrkerstetter Jul 7, 2025
753906c
Merge branch 'feat/edges_get_vertices' of https://github.com/ansys/py…
jacobrkerstetter Jul 7, 2025
b519703
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Jul 7, 2025
4b994c1
removing default parameters
jacobrkerstetter Jul 7, 2025
27a1481
Merge branch 'feat/edges_get_vertices' of https://github.com/ansys/py…
jacobrkerstetter Jul 7, 2025
b944eac
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Jul 7, 2025
fe4e733
Update src/ansys/geometry/core/designer/vertex.py
jacobrkerstetter Jul 7, 2025
527f5e9
added test that vertex is immutable
jacobrkerstetter Jul 7, 2025
8be5efc
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Jul 7, 2025
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
1 change: 1 addition & 0 deletions doc/changelog.d/2083.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Vertex references
5 changes: 5 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/base/bodies.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ def get_edges(self, **kwargs) -> dict:
"""Get the edges of a body."""
pass

@abstractmethod
def get_vertices(self, **kwargs) -> dict:
"""Get the vertices of a body."""
pass

@abstractmethod
def get_volume(self, **kwargs) -> dict:
"""Get the volume of a body."""
Expand Down
5 changes: 5 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/base/edges.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ def get_faces(self, **kwargs) -> dict:
"""Get the faces that are connected to the edge."""
pass

@abstractmethod
def get_vertices(self, **kwargs) -> dict:
"""Get the vertices that are connected to the edge."""
pass

@abstractmethod
def get_bounding_box(self, **kwargs) -> dict:
"""Get the bounding box of the edge."""
Expand Down
5 changes: 5 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/base/faces.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ def get_edges(self, **kwargs) -> dict:
"""Get the edges of a face."""
pass

@abstractmethod
def get_vertices(self, **kwargs) -> dict:
"""Get the vertices of a face."""
pass

@abstractmethod
def get_loops(self, **kwargs) -> dict:
"""Get the loops of a face."""
Expand Down
16 changes: 16 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/v0/bodies.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,22 @@ def get_edges(self, **kwargs) -> dict: # noqa: D102
]
}

@protect_grpc
def get_vertices(self, **kwargs) -> dict: # noqa: D102
# Call the gRPC service
resp = self.stub.GetVertices(request=build_grpc_id(kwargs["id"]))

# Return the response - formatted as a dictionary
return {
"vertices": [
{
"id": vertex.id.id,
"position": from_grpc_point_to_point3d(vertex.position),
}
for vertex in resp.vertices
]
}

@protect_grpc
def get_volume(self, **kwargs) -> dict: # noqa: D102
# Call the gRPC service
Expand Down
21 changes: 21 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/v0/edges.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,27 @@ def get_faces(self, **kwargs) -> dict: # noqa: D102
],
}

@protect_grpc
def get_vertices(self, **kwargs) -> dict: # noqa: D102
from ansys.api.geometry.v0.edges_pb2 import GetVerticesRequest

# Create the request - assumes all inputs are valid and of proper type
request = GetVerticesRequest(edge=build_grpc_id(kwargs["id"]))

# Call the gRPC service
response = self.stub.GetVertices(request=request)

# Return the response - formatted as a dictionary
return {
"vertices": [
{
"id": vertex.id.id,
"position": from_grpc_point_to_point3d(vertex.position),
}
for vertex in response.vertices
],
}

@protect_grpc
def get_bounding_box(self, **kwargs) -> dict: # noqa: D102
# Create the request - assumes all inputs are valid and of the proper type
Expand Down
21 changes: 21 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/v0/faces.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,27 @@ def get_edges(self, **kwargs) -> dict: # noqa: D102
]
}

@protect_grpc
def get_vertices(self, **kwargs) -> dict: # noqa: D102
# Create the request - assumes all inputs are valid and of the proper type
from ansys.api.geometry.v0.faces_pb2 import GetVerticesRequest

request = GetVerticesRequest(face_id=build_grpc_id(kwargs["id"]))

# Call the gRPC service
response = self.stub.GetVertices(request=request)

# Return the response - formatted as a dictionary
return {
"vertices": [
{
"id": vertex.id.id,
"position": from_grpc_point_to_point3d(vertex.position),
}
for vertex in response.vertices
]
}

@protect_grpc
def get_loops(self, **kwargs) -> dict: # noqa: D102
# Create the request - assumes all inputs are valid and of the proper type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def get_named_selection(self, **kwargs): # noqa: D102
"beams": [beam.id.id for beam in response.beams],
"design_points": [(dp.id, dp.points[0]) for dp in response.design_points],
"components": [comp.id for comp in response.components],
"vertices": [vertex.id.id for vertex in response.vertices],
}

@protect_grpc
Expand All @@ -92,6 +93,7 @@ def create_named_selection(self, **kwargs): # noqa: D102
"beams": [beam.id.id for beam in response.beams],
"design_points": [dp.id for dp in response.design_points],
"components": [comp.id for comp in response.components],
"vertices": [vertex.id.id for vertex in response.vertices],
}

@protect_grpc
Expand Down
4 changes: 4 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/v1/bodies.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ def get_faces(self, **kwargs) -> dict: # noqa: D102
def get_edges(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError

@protect_grpc
def get_vertices(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError

@protect_grpc
def get_volume(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError
Expand Down
4 changes: 4 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/v1/edges.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ def get_interval(self, **kwargs) -> dict: # noqa: D102
def get_faces(self, **kwargs) -> dict: # noqa: D102
return NotImplementedError

@protect_grpc
def get_vertices(self, **kwargs) -> dict: # noqa: D102
return NotImplementedError

@protect_grpc
def get_bounding_box(self, **kwargs) -> dict: # noqa: D102
return NotImplementedError
4 changes: 4 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/v1/faces.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ def get_area(self, **kwargs) -> dict: # noqa: D102
def get_edges(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError

@protect_grpc
def get_vertices(self, **kwargs): # noqa: D102
raise NotImplementedError

@protect_grpc
def get_loops(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError
Expand Down
34 changes: 34 additions & 0 deletions src/ansys/geometry/core/designer/body.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
)
from ansys.geometry.core.designer.edge import CurveType, Edge
from ansys.geometry.core.designer.face import Face, SurfaceType
from ansys.geometry.core.designer.vertex import Vertex
from ansys.geometry.core.errors import protect_grpc
from ansys.geometry.core.materials.material import Material
from ansys.geometry.core.math.bbox import BoundingBox
Expand Down Expand Up @@ -239,6 +240,16 @@ def edges(self) -> list[Edge]:
"""
return

@abstractmethod
def vertices(self) -> list[Vertex]:
"""Get a list of all vertices within the body.

Returns
-------
list[Vertex]
"""
return

@abstractmethod
def is_alive(self) -> bool:
"""Check if the body is still alive and has not been deleted."""
Expand Down Expand Up @@ -989,6 +1000,24 @@ def _get_edges_from_id(self, body: Union["Body", "MasterBody"]) -> list[Edge]:
for edge_resp in response.get("edges")
]

@property
@min_backend_version(26, 1, 0)
def vertices(self) -> list[Vertex]: # noqa: D102
return self._get_vertices_from_id(self)

def _get_vertices_from_id(self, body: Union["Body", "MasterBody"]) -> list[Vertex]:
"""Retrieve vertices from a body ID."""
self._grpc_client.log.debug(f"Retrieving vertices for body {body.id} from server.")
response = self._grpc_client.services.bodies.get_vertices(id=body.id)

return [
Vertex(
vertex_resp.get("id"),
vertex_resp.get("position"),
)
for vertex_resp in response.get("vertices")
]

@property
def is_alive(self) -> bool: # noqa: D102
return self._is_alive
Expand Down Expand Up @@ -1485,6 +1514,11 @@ def faces(self) -> list[Face]: # noqa: D102
def edges(self) -> list[Edge]: # noqa: D102
return self._template._get_edges_from_id(self)

@property
@ensure_design_is_active
def vertices(self) -> list[Vertex]: # noqa: D102
return self._template._get_vertices_from_id(self)

@property
def _is_alive(self) -> bool: # noqa: D102
return self._template.is_alive
Expand Down
9 changes: 7 additions & 2 deletions src/ansys/geometry/core/designer/design.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
from ansys.geometry.core.designer.face import Face
from ansys.geometry.core.designer.part import MasterComponent, Part
from ansys.geometry.core.designer.selection import NamedSelection
from ansys.geometry.core.designer.vertex import Vertex
from ansys.geometry.core.errors import protect_grpc
from ansys.geometry.core.materials.material import Material
from ansys.geometry.core.materials.property import MaterialProperty, MaterialPropertyType
Expand Down Expand Up @@ -608,6 +609,7 @@ def create_named_selection(
beams: list[Beam] | None = None,
design_points: list[DesignPoint] | None = None,
components: list[Component] | None = None,
vertices: list[Vertex] | None = None,
) -> NamedSelection:
"""Create a named selection on the active Geometry server instance.

Expand All @@ -627,6 +629,8 @@ def create_named_selection(
All design points to include in the named selection.
components : list[Component], default: None
All components to include in the named selection.
vertices : list[Vertex], default: None
All vertices to include in the named selection.

Returns
-------
Expand All @@ -640,10 +644,10 @@ def create_named_selection(
one of the optional parameters must be provided.
"""
# Verify that at least one entity is provided
if not any([bodies, faces, edges, beams, design_points, components]):
if not any([bodies, faces, edges, beams, design_points, components, vertices]):
raise ValueError(
"At least one of the following must be provided: "
"bodies, faces, edges, beams, design_points, or components."
"bodies, faces, edges, beams, design_points, components, or vertices."
)

named_selection = NamedSelection(
Expand All @@ -656,6 +660,7 @@ def create_named_selection(
beams=beams,
design_points=design_points,
components=components,
vertices=vertices,
)

self._named_selections[named_selection.name] = named_selection
Expand Down
19 changes: 19 additions & 0 deletions src/ansys/geometry/core/designer/edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
if TYPE_CHECKING: # pragma: no cover
from ansys.geometry.core.designer.body import Body
from ansys.geometry.core.designer.face import Face
from ansys.geometry.core.designer.vertex import Vertex


@unique
Expand Down Expand Up @@ -176,6 +177,24 @@ def faces(self) -> list["Face"]:
for face_resp in response.get("faces")
]

@property
@ensure_design_is_active
@min_backend_version(26, 1, 0)
def vertices(self) -> list["Vertex"]:
"""Vertices that define the edge."""
from ansys.geometry.core.designer.vertex import Vertex

self._grpc_client.log.debug("Requesting edge vertices from server.")
response = self._grpc_client.services.edges.get_vertices(id=self._id)

return [
Vertex(
vertex_resp.get("id"),
vertex_resp.get("position"),
)
for vertex_resp in response.get("vertices")
]

@property
@ensure_design_is_active
def start(self) -> Point3D:
Expand Down
17 changes: 17 additions & 0 deletions src/ansys/geometry/core/designer/face.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from ansys.api.geometry.v0.commands_pb2_grpc import CommandsStub
from ansys.geometry.core.connection.client import GrpcClient
from ansys.geometry.core.designer.edge import Edge
from ansys.geometry.core.designer.vertex import Vertex
from ansys.geometry.core.errors import GeometryRuntimeError, protect_grpc
from ansys.geometry.core.math.bbox import BoundingBox
from ansys.geometry.core.math.point import Point3D
Expand Down Expand Up @@ -263,6 +264,22 @@ def edges(self) -> list[Edge]:
for edge in response.get("edges")
]

@property
@ensure_design_is_active
@min_backend_version(26, 1, 0)
def vertices(self) -> list[Vertex]:
"""List of all vertices of the face."""
self._grpc_client.log.debug("Requesting face vertices from server.")
response = self._grpc_client.services.faces.get_vertices(id=self.id)

return [
Vertex(
vertex_resp.get("id"),
vertex_resp.get("position"),
)
for vertex_resp in response.get("vertices")
]

@property
@ensure_design_is_active
def loops(self) -> list[FaceLoop]:
Expand Down
Loading