diff --git a/doc/changelog.d/1176.fixed.md b/doc/changelog.d/1176.fixed.md new file mode 100644 index 0000000000..60d2bde040 --- /dev/null +++ b/doc/changelog.d/1176.fixed.md @@ -0,0 +1 @@ +fix: start and end points for edge \ No newline at end of file diff --git a/src/ansys/geometry/core/designer/edge.py b/src/ansys/geometry/core/designer/edge.py index 8d7927ea05..993591dce1 100644 --- a/src/ansys/geometry/core/designer/edge.py +++ b/src/ansys/geometry/core/designer/edge.py @@ -107,6 +107,8 @@ def is_reversed(self) -> bool: return self._is_reversed @property + @protect_grpc + @ensure_design_is_active @min_backend_version(24, 2, 0) def shape(self) -> TrimmedCurve: """ @@ -175,3 +177,29 @@ def faces(self) -> List["Face"]: ) for grpc_face in grpc_faces ] + + @property + @protect_grpc + @ensure_design_is_active + def start(self) -> Point3D: + """Start point of the edge.""" + try: + return self.shape.start + except GeometryRuntimeError: # pragma: no cover + # Only for versions earlier than 24.2.0 (before the introduction of the shape property) + self._grpc_client.log.debug("Requesting edge start point from server.") + response = self._edges_stub.GetStartAndEndPoints(self._grpc_id) + return Point3D([response.start.x, response.start.y, response.start.z]) + + @property + @protect_grpc + @ensure_design_is_active + def end(self) -> Point3D: + """End point of the edge.""" + try: + return self.shape.end + except GeometryRuntimeError: # pragma: no cover + # Only for versions earlier than 24.2.0 (before the introduction of the shape property) + self._grpc_client.log.debug("Requesting edge end point from server.") + response = self._edges_stub.GetStartAndEndPoints(self._grpc_id) + return Point3D([response.end.x, response.end.y, response.end.z]) diff --git a/src/ansys/geometry/core/designer/face.py b/src/ansys/geometry/core/designer/face.py index 901f2435d1..c45537b797 100644 --- a/src/ansys/geometry/core/designer/face.py +++ b/src/ansys/geometry/core/designer/face.py @@ -200,6 +200,8 @@ def body(self) -> "Body": return self._body @property + @protect_grpc + @ensure_design_is_active @min_backend_version(24, 2, 0) def shape(self) -> TrimmedSurface: """ @@ -284,6 +286,7 @@ def loops(self) -> List[FaceLoop]: return loops @protect_grpc + @ensure_design_is_active def normal(self, u: float = 0.5, v: float = 0.5) -> UnitVector3D: """ Get the normal direction to the face at certain proportional UV coordinates. @@ -319,6 +322,7 @@ def normal(self, u: float = 0.5, v: float = 0.5) -> UnitVector3D: return UnitVector3D([response.x, response.y, response.z]) @protect_grpc + @ensure_design_is_active def point(self, u: float = 0.5, v: float = 0.5) -> Point3D: """ Get a point of the face evaluated at certain proportional UV coordinates. @@ -381,6 +385,8 @@ def __grpc_edges_to_edges(self, edges_grpc: List[GRPCEdge]) -> List[Edge]: ) return edges + @protect_grpc + @ensure_design_is_active def create_isoparametric_curves( self, use_u_param: bool, parameter: float ) -> List[TrimmedCurve]: diff --git a/src/ansys/geometry/core/plotting/plotter.py b/src/ansys/geometry/core/plotting/plotter.py index 4f32a1d485..edbc2340ae 100644 --- a/src/ansys/geometry/core/plotting/plotter.py +++ b/src/ansys/geometry/core/plotting/plotter.py @@ -256,7 +256,7 @@ def add_body_edges(self, body_plot: GeomObjectPlot, **plotting_options: Optional """ edge_plot_list = [] for edge in body_plot.object.edges: - line = pv.Line(edge.shape.start, edge.shape.start) + line = pv.Line(edge.start, edge.end) edge_actor = self.scene.add_mesh( line, line_width=10, color=EDGE_COLOR, **plotting_options )