From 97eb31adfd9dde4f1ecfa364d7408b09d17bfafd Mon Sep 17 00:00:00 2001 From: PyAnsys CI Bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Mon, 17 Feb 2025 15:31:37 +0100 Subject: [PATCH 01/33] chore: update CHANGELOG for v0.9.0 (#1753) --- doc/changelog.d/1258.test.md | 1 - doc/changelog.d/1706.maintenance.md | 1 - doc/changelog.d/1707.added.md | 1 - doc/changelog.d/1708.added.md | 1 - doc/changelog.d/1709.dependencies.md | 1 - doc/changelog.d/1711.fixed.md | 1 - doc/changelog.d/1712.added.md | 1 - doc/changelog.d/1713.test.md | 1 - doc/changelog.d/1714.fixed.md | 1 - doc/changelog.d/1715.fixed.md | 1 - doc/changelog.d/1716.added.md | 1 - doc/changelog.d/1717.maintenance.md | 1 - doc/changelog.d/1719.dependencies.md | 1 - doc/changelog.d/1720.dependencies.md | 1 - doc/changelog.d/1722.maintenance.md | 1 - doc/changelog.d/1723.added.md | 1 - doc/changelog.d/1725.fixed.md | 1 - doc/changelog.d/1726.dependencies.md | 1 - doc/changelog.d/1727.test.md | 1 - doc/changelog.d/1728.dependencies.md | 1 - doc/changelog.d/1729.dependencies.md | 1 - doc/changelog.d/1730.documentation.md | 1 - doc/changelog.d/1732.added.md | 1 - doc/changelog.d/1736.dependencies.md | 1 - doc/changelog.d/1737.maintenance.md | 1 - doc/changelog.d/1739.maintenance.md | 1 - doc/changelog.d/1740.added.md | 1 - doc/changelog.d/1741.added.md | 1 - doc/changelog.d/1742.dependencies.md | 1 - doc/changelog.d/1743.dependencies.md | 1 - doc/changelog.d/1744.dependencies.md | 1 - doc/changelog.d/1745.test.md | 1 - doc/changelog.d/1746.dependencies.md | 1 - doc/changelog.d/1747.dependencies.md | 1 - doc/changelog.d/1749.dependencies.md | 1 - doc/changelog.d/1750.maintenance.md | 1 - doc/changelog.d/1753.maintenance.md | 1 + doc/source/changelog.rst | 67 +++++++++++++++++++++++++++ 38 files changed, 68 insertions(+), 36 deletions(-) delete mode 100644 doc/changelog.d/1258.test.md delete mode 100644 doc/changelog.d/1706.maintenance.md delete mode 100644 doc/changelog.d/1707.added.md delete mode 100644 doc/changelog.d/1708.added.md delete mode 100644 doc/changelog.d/1709.dependencies.md delete mode 100644 doc/changelog.d/1711.fixed.md delete mode 100644 doc/changelog.d/1712.added.md delete mode 100644 doc/changelog.d/1713.test.md delete mode 100644 doc/changelog.d/1714.fixed.md delete mode 100644 doc/changelog.d/1715.fixed.md delete mode 100644 doc/changelog.d/1716.added.md delete mode 100644 doc/changelog.d/1717.maintenance.md delete mode 100644 doc/changelog.d/1719.dependencies.md delete mode 100644 doc/changelog.d/1720.dependencies.md delete mode 100644 doc/changelog.d/1722.maintenance.md delete mode 100644 doc/changelog.d/1723.added.md delete mode 100644 doc/changelog.d/1725.fixed.md delete mode 100644 doc/changelog.d/1726.dependencies.md delete mode 100644 doc/changelog.d/1727.test.md delete mode 100644 doc/changelog.d/1728.dependencies.md delete mode 100644 doc/changelog.d/1729.dependencies.md delete mode 100644 doc/changelog.d/1730.documentation.md delete mode 100644 doc/changelog.d/1732.added.md delete mode 100644 doc/changelog.d/1736.dependencies.md delete mode 100644 doc/changelog.d/1737.maintenance.md delete mode 100644 doc/changelog.d/1739.maintenance.md delete mode 100644 doc/changelog.d/1740.added.md delete mode 100644 doc/changelog.d/1741.added.md delete mode 100644 doc/changelog.d/1742.dependencies.md delete mode 100644 doc/changelog.d/1743.dependencies.md delete mode 100644 doc/changelog.d/1744.dependencies.md delete mode 100644 doc/changelog.d/1745.test.md delete mode 100644 doc/changelog.d/1746.dependencies.md delete mode 100644 doc/changelog.d/1747.dependencies.md delete mode 100644 doc/changelog.d/1749.dependencies.md delete mode 100644 doc/changelog.d/1750.maintenance.md create mode 100644 doc/changelog.d/1753.maintenance.md diff --git a/doc/changelog.d/1258.test.md b/doc/changelog.d/1258.test.md deleted file mode 100644 index 7cde69eb55..0000000000 --- a/doc/changelog.d/1258.test.md +++ /dev/null @@ -1 +0,0 @@ -verifying issue with empty intersect and temporal body creation \ No newline at end of file diff --git a/doc/changelog.d/1706.maintenance.md b/doc/changelog.d/1706.maintenance.md deleted file mode 100644 index 6f4c1c0089..0000000000 --- a/doc/changelog.d/1706.maintenance.md +++ /dev/null @@ -1 +0,0 @@ -update CHANGELOG for v0.8.2 \ No newline at end of file diff --git a/doc/changelog.d/1707.added.md b/doc/changelog.d/1707.added.md deleted file mode 100644 index 2602f1720f..0000000000 --- a/doc/changelog.d/1707.added.md +++ /dev/null @@ -1 +0,0 @@ -design activation changes \ No newline at end of file diff --git a/doc/changelog.d/1708.added.md b/doc/changelog.d/1708.added.md deleted file mode 100644 index 52cde5ead5..0000000000 --- a/doc/changelog.d/1708.added.md +++ /dev/null @@ -1 +0,0 @@ -add contributors \ No newline at end of file diff --git a/doc/changelog.d/1709.dependencies.md b/doc/changelog.d/1709.dependencies.md deleted file mode 100644 index 3c05c97bf8..0000000000 --- a/doc/changelog.d/1709.dependencies.md +++ /dev/null @@ -1 +0,0 @@ -bump ansys-api-geometry from 0.4.33 to 0.4.34 \ No newline at end of file diff --git a/doc/changelog.d/1711.fixed.md b/doc/changelog.d/1711.fixed.md deleted file mode 100644 index 277af98686..0000000000 --- a/doc/changelog.d/1711.fixed.md +++ /dev/null @@ -1 +0,0 @@ -re enable fmd tests \ No newline at end of file diff --git a/doc/changelog.d/1712.added.md b/doc/changelog.d/1712.added.md deleted file mode 100644 index 0d2f01063a..0000000000 --- a/doc/changelog.d/1712.added.md +++ /dev/null @@ -1 +0,0 @@ -Implementation of inspect & repair geometry \ No newline at end of file diff --git a/doc/changelog.d/1713.test.md b/doc/changelog.d/1713.test.md deleted file mode 100644 index 4c10d27211..0000000000 --- a/doc/changelog.d/1713.test.md +++ /dev/null @@ -1 +0,0 @@ -Expand pattern tests \ No newline at end of file diff --git a/doc/changelog.d/1714.fixed.md b/doc/changelog.d/1714.fixed.md deleted file mode 100644 index e58c41f4d9..0000000000 --- a/doc/changelog.d/1714.fixed.md +++ /dev/null @@ -1 +0,0 @@ -support body mirror on linux \ No newline at end of file diff --git a/doc/changelog.d/1715.fixed.md b/doc/changelog.d/1715.fixed.md deleted file mode 100644 index 9af9372ee1..0000000000 --- a/doc/changelog.d/1715.fixed.md +++ /dev/null @@ -1 +0,0 @@ -use sketch plane for imprint/project curves \ No newline at end of file diff --git a/doc/changelog.d/1716.added.md b/doc/changelog.d/1716.added.md deleted file mode 100644 index e90bde071a..0000000000 --- a/doc/changelog.d/1716.added.md +++ /dev/null @@ -1 +0,0 @@ -launch core service from envar \ No newline at end of file diff --git a/doc/changelog.d/1717.maintenance.md b/doc/changelog.d/1717.maintenance.md deleted file mode 100644 index c655a0905a..0000000000 --- a/doc/changelog.d/1717.maintenance.md +++ /dev/null @@ -1 +0,0 @@ -pre-commit automatic update \ No newline at end of file diff --git a/doc/changelog.d/1719.dependencies.md b/doc/changelog.d/1719.dependencies.md deleted file mode 100644 index 883bfafc7c..0000000000 --- a/doc/changelog.d/1719.dependencies.md +++ /dev/null @@ -1 +0,0 @@ -bump ansys-sphinx-theme[autoapi] from 1.2.6 to 1.2.7 in the docs-deps group \ No newline at end of file diff --git a/doc/changelog.d/1720.dependencies.md b/doc/changelog.d/1720.dependencies.md deleted file mode 100644 index 0f3ca21a1e..0000000000 --- a/doc/changelog.d/1720.dependencies.md +++ /dev/null @@ -1 +0,0 @@ -bump ansys-api-geometry from 0.4.34 to 0.4.35 \ No newline at end of file diff --git a/doc/changelog.d/1722.maintenance.md b/doc/changelog.d/1722.maintenance.md deleted file mode 100644 index 61a75a0ef5..0000000000 --- a/doc/changelog.d/1722.maintenance.md +++ /dev/null @@ -1 +0,0 @@ -update SECURITY.md versions supported \ No newline at end of file diff --git a/doc/changelog.d/1723.added.md b/doc/changelog.d/1723.added.md deleted file mode 100644 index 27a925f003..0000000000 --- a/doc/changelog.d/1723.added.md +++ /dev/null @@ -1 +0,0 @@ -workflow enhancements for better tool results \ No newline at end of file diff --git a/doc/changelog.d/1725.fixed.md b/doc/changelog.d/1725.fixed.md deleted file mode 100644 index 5bec5d4ba9..0000000000 --- a/doc/changelog.d/1725.fixed.md +++ /dev/null @@ -1 +0,0 @@ -revert boolean ops logic and hold-off on commands-based implementation (temporarily) \ No newline at end of file diff --git a/doc/changelog.d/1726.dependencies.md b/doc/changelog.d/1726.dependencies.md deleted file mode 100644 index aae2364dc8..0000000000 --- a/doc/changelog.d/1726.dependencies.md +++ /dev/null @@ -1 +0,0 @@ -bump ansys-sphinx-theme[autoapi] from 1.2.7 to 1.3.0 in the docs-deps group \ No newline at end of file diff --git a/doc/changelog.d/1727.test.md b/doc/changelog.d/1727.test.md deleted file mode 100644 index d4caa81efc..0000000000 --- a/doc/changelog.d/1727.test.md +++ /dev/null @@ -1 +0,0 @@ -set body name \ No newline at end of file diff --git a/doc/changelog.d/1728.dependencies.md b/doc/changelog.d/1728.dependencies.md deleted file mode 100644 index 16cad54f2c..0000000000 --- a/doc/changelog.d/1728.dependencies.md +++ /dev/null @@ -1 +0,0 @@ -bump ansys-sphinx-theme[autoapi] from 1.3.0 to 1.3.1 in the docs-deps group \ No newline at end of file diff --git a/doc/changelog.d/1729.dependencies.md b/doc/changelog.d/1729.dependencies.md deleted file mode 100644 index 7cfa83a813..0000000000 --- a/doc/changelog.d/1729.dependencies.md +++ /dev/null @@ -1 +0,0 @@ -bump ansys-api-geometry from 0.4.35 to 0.4.36 \ No newline at end of file diff --git a/doc/changelog.d/1730.documentation.md b/doc/changelog.d/1730.documentation.md deleted file mode 100644 index deb88451eb..0000000000 --- a/doc/changelog.d/1730.documentation.md +++ /dev/null @@ -1 +0,0 @@ -update CONTRIBUTING.md \ No newline at end of file diff --git a/doc/changelog.d/1732.added.md b/doc/changelog.d/1732.added.md deleted file mode 100644 index 07b49458c3..0000000000 --- a/doc/changelog.d/1732.added.md +++ /dev/null @@ -1 +0,0 @@ -add face color, round info, bring measure tools to linux \ No newline at end of file diff --git a/doc/changelog.d/1736.dependencies.md b/doc/changelog.d/1736.dependencies.md deleted file mode 100644 index 5c12517a19..0000000000 --- a/doc/changelog.d/1736.dependencies.md +++ /dev/null @@ -1 +0,0 @@ -bump trame-vtk from 2.8.14 to 2.8.15 \ No newline at end of file diff --git a/doc/changelog.d/1737.maintenance.md b/doc/changelog.d/1737.maintenance.md deleted file mode 100644 index c655a0905a..0000000000 --- a/doc/changelog.d/1737.maintenance.md +++ /dev/null @@ -1 +0,0 @@ -pre-commit automatic update \ No newline at end of file diff --git a/doc/changelog.d/1739.maintenance.md b/doc/changelog.d/1739.maintenance.md deleted file mode 100644 index 9e32bd93f9..0000000000 --- a/doc/changelog.d/1739.maintenance.md +++ /dev/null @@ -1 +0,0 @@ -keep simba-plugin-geometry tag \ No newline at end of file diff --git a/doc/changelog.d/1740.added.md b/doc/changelog.d/1740.added.md deleted file mode 100644 index c7191a660d..0000000000 --- a/doc/changelog.d/1740.added.md +++ /dev/null @@ -1 +0,0 @@ -conservative approach to single design per modeler \ No newline at end of file diff --git a/doc/changelog.d/1741.added.md b/doc/changelog.d/1741.added.md deleted file mode 100644 index bdcedd10cd..0000000000 --- a/doc/changelog.d/1741.added.md +++ /dev/null @@ -1 +0,0 @@ -export glb \ No newline at end of file diff --git a/doc/changelog.d/1742.dependencies.md b/doc/changelog.d/1742.dependencies.md deleted file mode 100644 index 14c7ab84ee..0000000000 --- a/doc/changelog.d/1742.dependencies.md +++ /dev/null @@ -1 +0,0 @@ -bump jupytext from 1.16.6 to 1.16.7 in the docs-deps group \ No newline at end of file diff --git a/doc/changelog.d/1743.dependencies.md b/doc/changelog.d/1743.dependencies.md deleted file mode 100644 index d499e54ae5..0000000000 --- a/doc/changelog.d/1743.dependencies.md +++ /dev/null @@ -1 +0,0 @@ -bump ansys-api-geometry from 0.4.36 to 0.4.37 \ No newline at end of file diff --git a/doc/changelog.d/1744.dependencies.md b/doc/changelog.d/1744.dependencies.md deleted file mode 100644 index 184bfb5bf9..0000000000 --- a/doc/changelog.d/1744.dependencies.md +++ /dev/null @@ -1 +0,0 @@ -bump myst-parser from 4.0.0 to 4.0.1 in the docs-deps group \ No newline at end of file diff --git a/doc/changelog.d/1745.test.md b/doc/changelog.d/1745.test.md deleted file mode 100644 index 5a737e92ac..0000000000 --- a/doc/changelog.d/1745.test.md +++ /dev/null @@ -1 +0,0 @@ -activate 8 linux tests \ No newline at end of file diff --git a/doc/changelog.d/1746.dependencies.md b/doc/changelog.d/1746.dependencies.md deleted file mode 100644 index d9c564d265..0000000000 --- a/doc/changelog.d/1746.dependencies.md +++ /dev/null @@ -1 +0,0 @@ -bump ansys-api-geometry from 0.4.37 to 0.4.38 \ No newline at end of file diff --git a/doc/changelog.d/1747.dependencies.md b/doc/changelog.d/1747.dependencies.md deleted file mode 100644 index 186365ae6f..0000000000 --- a/doc/changelog.d/1747.dependencies.md +++ /dev/null @@ -1 +0,0 @@ -bump numpy from 2.2.2 to 2.2.3 \ No newline at end of file diff --git a/doc/changelog.d/1749.dependencies.md b/doc/changelog.d/1749.dependencies.md deleted file mode 100644 index daaa01a760..0000000000 --- a/doc/changelog.d/1749.dependencies.md +++ /dev/null @@ -1 +0,0 @@ -bump panel from 1.6.0 to 1.6.1 \ No newline at end of file diff --git a/doc/changelog.d/1750.maintenance.md b/doc/changelog.d/1750.maintenance.md deleted file mode 100644 index ed0a9ae502..0000000000 --- a/doc/changelog.d/1750.maintenance.md +++ /dev/null @@ -1 +0,0 @@ -enhancements to GLB export and object ``plot()`` methods \ No newline at end of file diff --git a/doc/changelog.d/1753.maintenance.md b/doc/changelog.d/1753.maintenance.md new file mode 100644 index 0000000000..97e5671828 --- /dev/null +++ b/doc/changelog.d/1753.maintenance.md @@ -0,0 +1 @@ +update CHANGELOG for v0.9.0 \ No newline at end of file diff --git a/doc/source/changelog.rst b/doc/source/changelog.rst index 3583da64d4..cabf5ee6b2 100644 --- a/doc/source/changelog.rst +++ b/doc/source/changelog.rst @@ -9,6 +9,73 @@ This document contains the release notes for the PyAnsys Geometry project. .. towncrier release notes start +`0.9.0 `_ - 2025-02-17 +===================================================================================== + +Added +^^^^^ + +- design activation changes `#1707 `_ +- add contributors `#1708 `_ +- Implementation of inspect & repair geometry `#1712 `_ +- launch core service from envar `#1716 `_ +- workflow enhancements for better tool results `#1723 `_ +- add face color, round info, bring measure tools to linux `#1732 `_ +- conservative approach to single design per modeler `#1740 `_ +- export glb `#1741 `_ + + +Dependencies +^^^^^^^^^^^^ + +- bump ansys-api-geometry from 0.4.33 to 0.4.34 `#1709 `_ +- bump ansys-sphinx-theme[autoapi] from 1.2.6 to 1.2.7 in the docs-deps group `#1719 `_ +- bump ansys-api-geometry from 0.4.34 to 0.4.35 `#1720 `_ +- bump ansys-sphinx-theme[autoapi] from 1.2.7 to 1.3.0 in the docs-deps group `#1726 `_ +- bump ansys-sphinx-theme[autoapi] from 1.3.0 to 1.3.1 in the docs-deps group `#1728 `_ +- bump ansys-api-geometry from 0.4.35 to 0.4.36 `#1729 `_ +- bump trame-vtk from 2.8.14 to 2.8.15 `#1736 `_ +- bump jupytext from 1.16.6 to 1.16.7 in the docs-deps group `#1742 `_ +- bump ansys-api-geometry from 0.4.36 to 0.4.37 `#1743 `_ +- bump myst-parser from 4.0.0 to 4.0.1 in the docs-deps group `#1744 `_ +- bump ansys-api-geometry from 0.4.37 to 0.4.38 `#1746 `_ +- bump numpy from 2.2.2 to 2.2.3 `#1747 `_ +- bump panel from 1.6.0 to 1.6.1 `#1749 `_ + + +Documentation +^^^^^^^^^^^^^ + +- update CONTRIBUTING.md `#1730 `_ + + +Fixed +^^^^^ + +- re enable fmd tests `#1711 `_ +- support body mirror on linux `#1714 `_ +- use sketch plane for imprint/project curves `#1715 `_ +- revert boolean ops logic and hold-off on commands-based implementation (temporarily) `#1725 `_ + + +Maintenance +^^^^^^^^^^^ + +- update CHANGELOG for v0.8.2 `#1706 `_ +- pre-commit automatic update `#1717 `_, `#1737 `_ +- update SECURITY.md versions supported `#1722 `_ +- keep simba-plugin-geometry tag `#1739 `_ +- enhancements to GLB export and object ``plot()`` methods `#1750 `_ + + +Test +^^^^ + +- verifying issue with empty intersect and temporal body creation `#1258 `_ +- Expand pattern tests `#1713 `_ +- set body name `#1727 `_ +- activate 8 linux tests `#1745 `_ + `0.8.2 `_ - 2025-01-29 ===================================================================================== From 2952b14adde91b8b33e94d586e0fe361e0dfda3f Mon Sep 17 00:00:00 2001 From: smereu Date: Tue, 5 Aug 2025 12:02:18 -0500 Subject: [PATCH 02/33] finalize tracker changes for boolean and update from response This PR contains the following changes - Client side change for boolean to remove delete on the python side (now done in the SC API) and update from response - Changes to add and delete body logic for proper dealing with @cached_property implementation of the function that get bodies - Small refactoring to avoid multiple definition of the function _serialize_tracker_command_response --- .../core/_grpc/_services/v0/bodies.py | 27 ++++--- .../core/_grpc/_services/v0/repair_tools.py | 10 +-- src/ansys/geometry/core/designer/body.py | 35 +++++--- src/ansys/geometry/core/designer/component.py | 11 ++- src/ansys/geometry/core/designer/design.py | 81 +++++++++++++++++-- .../geometry/core/tools/problem_areas.py | 80 +++++------------- src/ansys/geometry/core/tools/repair_tools.py | 20 ++--- 7 files changed, 156 insertions(+), 108 deletions(-) diff --git a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py index 03b08e8d21..84cb44f7a4 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py @@ -24,7 +24,9 @@ import grpc import pint +from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN from ansys.geometry.core.errors import protect_grpc +from ansys.geometry.core.misc.auxiliary import get_design_from_body from ansys.geometry.core.misc.measurements import DEFAULT_UNITS from ..base.bodies import GRPCBodyService @@ -658,14 +660,21 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service and build the requests accordingly resp = 0 + serialized_tracker_response = {} try: - resp = self.stub.Boolean( - request=BooleanRequest( - body1=kwargs["target"].id, - tool_bodies=[other.id for other in kwargs["other"]], - method=kwargs["method"], + request = BooleanRequest( + body1=kwargs["target"].id, + tool_bodies=[other.id for other in kwargs["other"]], + method=kwargs["method"], + ) + if USE_TRACKER_TO_UPDATE_DESIGN: + request.keep_other = kwargs["keep_other"] + resp = self.stub.Boolean(request=request) + if USE_TRACKER_TO_UPDATE_DESIGN: + parent_design = get_design_from_body(kwargs["target"]) + serialized_tracker_response = parent_design._serialize_tracker_command_response( + resp.response ) - ).empty_result except grpc.RpcError as err: # pragma: no cover # TODO: to be deleted - old versions did not have "tool_bodies" in the request # This is a temporary fix to support old versions of the server - should be deleted @@ -692,15 +701,15 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 body2=kwargs["other"][0].id, method=kwargs["method"], ) - ).empty_result + ) else: raise err - if resp == 1: + if resp.empty_result == 1: raise ValueError( f"Boolean operation of type '{kwargs['method']}' failed: {kwargs['err_msg']}.\n" f"Involving bodies:{kwargs['target']}, {kwargs['other']}" ) # Return the response - formatted as a dictionary - return {} + return {"complete_command_response": serialized_tracker_response} diff --git a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py index 8c25d5c7f8..e88684f90f 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py @@ -344,7 +344,7 @@ def find_and_fix_simplify(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FindAndSimplify(request) - serialized_tracker_response = self._serialize_tracker_command_response( + serialized_tracker_response = kwargs["parent_design"]._serialize_tracker_command_response( response.complete_command_response ) @@ -383,7 +383,7 @@ def find_and_fix_stitch_faces(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FindAndFixStitchFaces(request) - serialized_tracker_response = self._serialize_tracker_command_response( + serialized_tracker_response = kwargs["parent_design"]._serialize_tracker_command_response( response.complete_command_response ) @@ -467,7 +467,7 @@ def find_and_fix_short_edges(self, **kwargs): # noqa: D102 # Call the gRPC service response = self.stub.FindAndFixShortEdges(request) - serialized_tracker_response = self._serialize_tracker_command_response( + serialized_tracker_response = kwargs["parent_design"]._serialize_tracker_command_response( response.complete_command_response ) @@ -494,7 +494,7 @@ def find_and_fix_extra_edges(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FindAndFixExtraEdges(request) - serialized_tracker_response = self._serialize_tracker_command_response( + serialized_tracker_response = kwargs["parent_design"]._serialize_tracker_command_response( response.complete_command_response ) @@ -525,7 +525,7 @@ def find_and_fix_split_edges(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FindAndFixSplitEdges(request) - serialized_tracker_response = self._serialize_tracker_command_response( + serialized_tracker_response = kwargs["parent_design"]._serialize_tracker_command_response( response.complete_command_response ) diff --git a/src/ansys/geometry/core/designer/body.py b/src/ansys/geometry/core/designer/body.py index c40589f5fd..2fb1ffd77c 100644 --- a/src/ansys/geometry/core/designer/body.py +++ b/src/ansys/geometry/core/designer/body.py @@ -43,6 +43,7 @@ ShellRequest, ) from ansys.api.geometry.v0.commands_pb2_grpc import CommandsStub +from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN from ansys.geometry.core.connection.client import GrpcClient from ansys.geometry.core.connection.conversions import ( plane_to_grpc_plane, @@ -1948,7 +1949,9 @@ def __generic_boolean_command( # If USE_TRACKER_TO_UPDATE_DESIGN is True, we serialize the response # and update the parent design with the serialized response. tracker_response = response.result.complete_command_response - serialized_response = self._serialize_tracker_command_response(tracker_response) + serialized_response = parent_design._serialize_tracker_command_response( + tracker_response + ) parent_design._update_from_tracker(serialized_response) @reset_tessellation_cache @@ -1962,20 +1965,26 @@ def __generic_boolean_op( err_msg: str, ) -> None: grpc_other = other if isinstance(other, Iterable) else [other] - if keep_other: - # Make a copy of the other body to keep it... - # stored temporarily in the parent component - since it will be deleted - grpc_other = [b.copy(self.parent_component, f"BoolOpCopy_{b.name}") for b in grpc_other] - - self._template._grpc_client.services.bodies.boolean( - target=self, - other=grpc_other, - method=method, - err_msg=err_msg, + if not USE_TRACKER_TO_UPDATE_DESIGN: + if keep_other: + # Make a copy of the other body to keep it... + # stored temporarily in the parent component - since it will be deleted + grpc_other = [ + b.copy(self.parent_component, f"BoolOpCopy_{b.name}") for b in grpc_other + ] + + response = self._template._grpc_client.services.bodies.boolean( + target=self, other=grpc_other, method=method, err_msg=err_msg, keep_other=keep_other ) - for b in grpc_other: - b.parent_component.delete_body(b) + if not USE_TRACKER_TO_UPDATE_DESIGN: + for b in grpc_other: + b.parent_component.delete_body(b) + else: + # If USE_TRACKER_TO_UPDATE_DESIGN is True, we serialize the response + # and update the parent design with the serialized response. + parent_design = get_design_from_body(self) + parent_design._update_from_tracker(response["complete_command_response"]) def __repr__(self) -> str: """Represent the ``Body`` as a string.""" diff --git a/src/ansys/geometry/core/designer/component.py b/src/ansys/geometry/core/designer/component.py index 4c7d8d6086..f8e85af216 100644 --- a/src/ansys/geometry/core/designer/component.py +++ b/src/ansys/geometry/core/designer/component.py @@ -216,6 +216,7 @@ def __init__( self._name = new_component.component.name self._instance_name = new_component.component.instance_name else: + new_component = None self._name = name self._id = None self._instance_name = instance_name @@ -248,8 +249,14 @@ def __init__( elif not read_existing_comp: # This is an independent Component - Create new Part and MasterComponent - p = Part(uuid.uuid4(), f"p_{name}", [], []) - master = MasterComponent(uuid.uuid4(), f"master_{name}", p) + p = Part( + uuid.uuid4() if not new_component else new_component.template, f"p_{name}", [], [] + ) + master = MasterComponent( + uuid.uuid4() if not new_component else new_component.component.master_id, + f"master_{name}", + p, + ) self._master_component = master self._master_component.occurrences.append(self) diff --git a/src/ansys/geometry/core/designer/design.py b/src/ansys/geometry/core/designer/design.py index 74f6f59f77..975aeeb9bb 100644 --- a/src/ansys/geometry/core/designer/design.py +++ b/src/ansys/geometry/core/designer/design.py @@ -1000,6 +1000,55 @@ def __repr__(self) -> str: lines.append(f" N Design Points : {len(self.design_points)}") return "\n".join(lines) + def _serialize_tracker_command_response(self, response) -> dict: + """Serialize a TrackerCommandResponse object into a dictionary. + + Parameters + ---------- + response : TrackerCommandResponse + The gRPC TrackerCommandResponse object to serialize. + + Returns + ------- + dict + A dictionary representation of the TrackerCommandResponse object. + """ + + def serialize_body(body): + return { + "id": body.id, + "name": body.name, + "can_suppress": body.can_suppress, + "transform_to_master": { + "m00": body.transform_to_master.m00, + "m11": body.transform_to_master.m11, + "m22": body.transform_to_master.m22, + "m33": body.transform_to_master.m33, + }, + "master_id": body.master_id, + "parent_id": body.parent_id, + } + + def serialize_entity_identifier(entity): + """Serialize an EntityIdentifier object into a dictionary.""" + return { + "id": entity.id, + } + + return { + "success": response.success, + "created_bodies": [ + serialize_body(body) for body in getattr(response, "created_bodies", []) + ], + "modified_bodies": [ + serialize_body(body) for body in getattr(response, "modified_bodies", []) + ], + "deleted_bodies": [ + serialize_entity_identifier(entity) + for entity in getattr(response, "deleted_bodies", []) + ], + } + def __read_existing_design(self) -> None: """Read an existing ``Design`` located on the server.""" # @@ -1298,7 +1347,12 @@ def _handle_deleted_bodies(self, deleted_bodies): for body in self.bodies: if body.id == body_id: body._is_alive = False - self.bodies.remove(body) + # self.bodies.remove(body) + for bd in self._master_component.part.bodies: + if bd.id == body_id: + self._master_component.part.bodies.remove(bd) + break + self._clear_cached_bodies() removed = True self._grpc_client.log.info( f"Deleted body (ID: {body_id}) removed from root level." @@ -1325,10 +1379,12 @@ def _handle_created_bodies(self, created_bodies): ) continue - added = any(self._find_and_add_body(body_info, self.components)) + added = self._find_and_add_body(body_info, self.components) if not added: new_body = MasterBody(body_id, body_name, self._grpc_client, is_surface=is_surface) - self.bodies.append(new_body) + # self.bodies.append(new_body) + self._master_component.part.bodies.append(new_body) + self._clear_cached_bodies() self._grpc_client.log.debug( f"Added new body '{body_name}' (ID: {body_id}) to root level." ) @@ -1343,14 +1399,17 @@ def _update_body(self, existing_body, body_info): def _find_and_add_body(self, body_info, components): for component in components: - if component.id == body_info["parent_id"]: + parent_id_for_body = component._master_component.part.id + if parent_id_for_body == body_info["parent_id"]: new_body = MasterBody( body_info["id"], body_info["name"], self._grpc_client, is_surface=body_info.get("is_surface", False), ) - component.bodies.append(new_body) + # component.bodies.append(new_body) + component._master_component.part.bodies.append(new_body) + component._clear_cached_bodies() self._grpc_client.log.debug( f"Added new body '{new_body.name}' (ID: {new_body.id}) " f"to component '{component.name}' (ID: {component.id})" @@ -1380,11 +1439,17 @@ def _find_and_update_body(self, body_info, component): def _find_and_remove_body(self, body_info, component): for body in component.bodies: - if body.id == body_info["id"]: + body_info_id = body_info["id"] + if body.id == f"{component.id}/{body_info_id}": body._is_alive = False - component.bodies.remove(body) + # component.bodies.remove(body) + for bd in component._master_component.part.bodies: + if bd.id == body_info_id: + component._master_component.part.bodies.remove(bd) + break + component._clear_cached_bodies() self._grpc_client.log.debug( - f"Removed body '{body_info['name']}' (ID: {body_info['id']}) from component " + f"Removed body (ID: {body_info['id']}) from component " f"'{component.name}' (ID: {component.id})" ) return True diff --git a/src/ansys/geometry/core/tools/problem_areas.py b/src/ansys/geometry/core/tools/problem_areas.py index cac2d552c5..11cf85a01d 100644 --- a/src/ansys/geometry/core/tools/problem_areas.py +++ b/src/ansys/geometry/core/tools/problem_areas.py @@ -83,58 +83,6 @@ def fix(self): """Fix problem area.""" raise NotImplementedError("Fix method is not implemented in the base class.") - def _serialize_tracker_command_response(self, response) -> dict: - """Serialize a TrackerCommandResponse object into a dictionary. - - Parameters - ---------- - response : TrackerCommandResponse - The gRPC TrackerCommandResponse object to serialize. - - Returns - ------- - dict - A dictionary representation of the TrackerCommandResponse object. - """ - - def serialize_body(body): - """Serialize a Body object into a dictionary.""" - return { - "id": body.id, - "name": body.name, - "can_suppress": body.can_suppress, - "transform_to_master": { - "m00": body.transform_to_master.m00, - "m11": body.transform_to_master.m11, - "m22": body.transform_to_master.m22, - "m33": body.transform_to_master.m33, - }, - "master_id": body.master_id, - "parent_id": body.parent_id, - "is_surface": body.is_surface, - } - - def serialize_entity_identifier(entity): - """Serialize an EntityIdentifier object into a dictionary.""" - return { - "id": entity.id, - } - - # Safely serialize each field, defaulting to an empty list if the field is missing - return { - "success": response.success, - "created_bodies": [ - serialize_body(body) for body in getattr(response, "created_bodies", []) - ], - "modified_bodies": [ - serialize_body(body) for body in getattr(response, "modified_bodies", []) - ], - "deleted_bodies": [ - serialize_entity_identifier(entity) - for entity in getattr(response, "deleted_bodies", []) - ], - } - class DuplicateFaceProblemAreas(ProblemArea): """Provides duplicate face problem area definition. @@ -189,7 +137,9 @@ def fix(self) -> RepairToolMessage: parent_design._update_design_inplace() else: tracker_response = response.result.complete_command_response - serialized_response = self._serialize_tracker_command_response(tracker_response) + serialized_response = parent_design._serialize_tracker_command_response( + tracker_response + ) parent_design._update_from_tracker(serialized_response) message = RepairToolMessage( @@ -247,7 +197,7 @@ def fix(self) -> RepairToolMessage: FixMissingFacesRequest(missing_face_problem_area_id=self._grpc_id) ) - serialized_response = self._serialize_tracker_command_response( + serialized_response = parent_design._serialize_tracker_command_response( response.result.complete_command_response ) @@ -319,7 +269,9 @@ def fix(self) -> RepairToolMessage: parent_design._update_design_inplace() else: tracker_response = response.result.complete_command_response - serialized_response = self._serialize_tracker_command_response(tracker_response) + serialized_response = parent_design._serialize_tracker_command_response( + tracker_response + ) parent_design._update_from_tracker(serialized_response) message = RepairToolMessage( @@ -381,7 +333,9 @@ def fix(self) -> RepairToolMessage: parent_design._update_design_inplace() else: tracker_response = response.result.complete_command_response - serialized_response = self._serialize_tracker_command_response(tracker_response) + serialized_response = parent_design._serialize_tracker_command_response( + tracker_response + ) parent_design._update_from_tracker(serialized_response) message = RepairToolMessage( @@ -444,7 +398,9 @@ def fix(self) -> RepairToolMessage: parent_design._update_design_inplace() else: tracker_response = response.result.complete_command_response - serialized_response = self._serialize_tracker_command_response(tracker_response) + serialized_response = parent_design._serialize_tracker_command_response( + tracker_response + ) parent_design._update_from_tracker(serialized_response) message = RepairToolMessage( @@ -510,7 +466,9 @@ def fix(self) -> RepairToolMessage: # If USE_TRACKER_TO_UPDATE_DESIGN is True, we serialize the response # and update the parent design with the serialized response. tracker_response = response.result.complete_command_response - serialized_response = self._serialize_tracker_command_response(tracker_response) + serialized_response = parent_design._serialize_tracker_command_response( + tracker_response + ) parent_design._update_from_tracker(serialized_response) message = RepairToolMessage( @@ -572,7 +530,7 @@ def fix(self) -> RepairToolMessage: parent_design._update_design_inplace() else: tracker_respone = response.result.complete_command_response - serialized_response = self._serialize_tracker_command_response(tracker_respone) + serialized_response = parent_design._serialize_tracker_command_response(tracker_respone) parent_design._update_from_tracker(serialized_response) message = RepairToolMessage( @@ -635,7 +593,7 @@ def fix(self) -> RepairToolMessage: parent_design._update_design_inplace() else: tracker_respone = response.result.complete_command_response - serialized_response = self._serialize_tracker_command_response(tracker_respone) + serialized_response = parent_design._serialize_tracker_command_response(tracker_respone) parent_design._update_from_tracker(serialized_response) message = RepairToolMessage( @@ -692,7 +650,7 @@ def fix(self) -> RepairToolMessage: parent_design._update_design_inplace() else: tracker_respone = response.result.complete_command_response - serialized_response = self._serialize_tracker_command_response(tracker_respone) + serialized_response = parent_design._serialize_tracker_command_response(tracker_respone) parent_design._update_from_tracker(serialized_response) message = RepairToolMessage( diff --git a/src/ansys/geometry/core/tools/repair_tools.py b/src/ansys/geometry/core/tools/repair_tools.py index 5742c97754..a5b4206350 100644 --- a/src/ansys/geometry/core/tools/repair_tools.py +++ b/src/ansys/geometry/core/tools/repair_tools.py @@ -523,16 +523,16 @@ def find_and_fix_short_edges( ) body_ids = [body.id for body in bodies] + parent_design = get_design_from_body(bodies[0]) response = self._grpc_client.services.repair_tools.find_and_fix_short_edges( selection=body_ids, + parent_design=parent_design, length=length, comprehensive_result=comprehensive_result, ) # Update existing design - parent_design = get_design_from_body(bodies[0]) - if not pyansys_geometry.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: @@ -579,14 +579,14 @@ def find_and_fix_extra_edges( ) body_ids = [body.id for body in bodies] + parent_design = get_design_from_body(bodies[0]) response = self._grpc_client.services.repair_tools.find_and_fix_extra_edges( selection=body_ids, + parent_design=parent_design, comprehensive_result=comprehensive_result, ) # Update existing design - parent_design = get_design_from_body(bodies[0]) - if not pyansys_geometry.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: @@ -641,17 +641,17 @@ def find_and_fix_split_edges( ) body_ids = [body.id for body in bodies] + parent_design = get_design_from_body(bodies[0]) response = self._grpc_client.services.repair_tools.find_and_fix_split_edges( bodies_or_faces=body_ids, + parent_design=parent_design, angle=angle, length=length, comprehensive_result=comprehensive_result, ) # Update existing design - parent_design = get_design_from_body(bodies[0]) - if not pyansys_geometry.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: @@ -696,15 +696,15 @@ def find_and_fix_simplify( ) body_ids = [body.id for body in bodies] + parent_design = get_design_from_body(bodies[0]) response = self._grpc_client.services.repair_tools.find_and_fix_simplify( selection=body_ids, + parent_design=parent_design, comprehensive_result=comprehensive_result, ) # Update existing design - parent_design = get_design_from_body(bodies[0]) - if not pyansys_geometry.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: @@ -766,9 +766,11 @@ def find_and_fix_stitch_faces( ) body_ids = [body.id for body in bodies] + parent_design = get_design_from_body(bodies[0]) response = self._grpc_client.services.repair_tools.find_and_fix_stitch_faces( body_ids=body_ids, + parent_design=parent_design, max_distance=max_distance, allow_multiple_bodies=allow_multiple_bodies, maintain_components=maintain_components, @@ -777,8 +779,6 @@ def find_and_fix_stitch_faces( ) # Update existing design - parent_design = get_design_from_body(bodies[0]) - if not pyansys_geometry.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: From aacd11a8640c9109a25af719f501f0ac77d7c9a5 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Mon, 11 Aug 2025 08:52:17 +0000 Subject: [PATCH 03/33] chore: adding changelog file 2153.added.md [dependabot-skip] --- doc/changelog.d/2153.added.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/2153.added.md diff --git a/doc/changelog.d/2153.added.md b/doc/changelog.d/2153.added.md new file mode 100644 index 0000000000..55e84868f3 --- /dev/null +++ b/doc/changelog.d/2153.added.md @@ -0,0 +1 @@ +Tracking boolean operations \ No newline at end of file From 8344d414f2bcf2f1ad74472b8a2d085862f05712 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Wed, 20 Aug 2025 13:56:06 +0000 Subject: [PATCH 04/33] chore: adding changelog file 2153.added.md [dependabot-skip] --- doc/changelog.d/2153.added.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changelog.d/2153.added.md b/doc/changelog.d/2153.added.md index 55e84868f3..f4ff49de0c 100644 --- a/doc/changelog.d/2153.added.md +++ b/doc/changelog.d/2153.added.md @@ -1 +1 @@ -Tracking boolean operations \ No newline at end of file +Tracking boolean operations From e172e452ff831b73225ced4573831be55d230349 Mon Sep 17 00:00:00 2001 From: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Date: Wed, 3 Sep 2025 14:22:58 +0200 Subject: [PATCH 05/33] Delete doc/changelog.d/1753.maintenance.md --- doc/changelog.d/1753.maintenance.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 doc/changelog.d/1753.maintenance.md diff --git a/doc/changelog.d/1753.maintenance.md b/doc/changelog.d/1753.maintenance.md deleted file mode 100644 index 97e5671828..0000000000 --- a/doc/changelog.d/1753.maintenance.md +++ /dev/null @@ -1 +0,0 @@ -update CHANGELOG for v0.9.0 \ No newline at end of file From 1e711f6e68a35993f8492add682787373ebe54ce Mon Sep 17 00:00:00 2001 From: Jacob Kerstetter Date: Wed, 3 Sep 2025 11:05:36 -0400 Subject: [PATCH 06/33] fixing some comments --- src/ansys/geometry/core/_grpc/_services/v0/bodies.py | 6 +++--- src/ansys/geometry/core/designer/design.py | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py index 31818e5e78..f9a04afefc 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py @@ -24,7 +24,7 @@ import grpc import pint -from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN +import ansys.geometry.core as pyansys_geom from ansys.geometry.core.errors import protect_grpc from ansys.geometry.core.misc.auxiliary import get_design_from_body from ansys.geometry.core.misc.measurements import DEFAULT_UNITS @@ -722,10 +722,10 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 tool_bodies=[other.id for other in kwargs["other"]], method=kwargs["method"], ) - if USE_TRACKER_TO_UPDATE_DESIGN: + if pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: request.keep_other = kwargs["keep_other"] resp = self.stub.Boolean(request=request) - if USE_TRACKER_TO_UPDATE_DESIGN: + if pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design = get_design_from_body(kwargs["target"]) serialized_tracker_response = parent_design._serialize_tracker_command_response( resp.response diff --git a/src/ansys/geometry/core/designer/design.py b/src/ansys/geometry/core/designer/design.py index 12913b54f2..c943be7196 100644 --- a/src/ansys/geometry/core/designer/design.py +++ b/src/ansys/geometry/core/designer/design.py @@ -1392,7 +1392,6 @@ def _handle_deleted_bodies(self, deleted_bodies): for body in self.bodies: if body.id == body_id: body._is_alive = False - # self.bodies.remove(body) for bd in self._master_component.part.bodies: if bd.id == body_id: self._master_component.part.bodies.remove(bd) @@ -1427,7 +1426,6 @@ def _handle_created_bodies(self, created_bodies): added = self._find_and_add_body(body_info, self.components) if not added: new_body = MasterBody(body_id, body_name, self._grpc_client, is_surface=is_surface) - # self.bodies.append(new_body) self._master_component.part.bodies.append(new_body) self._clear_cached_bodies() self._grpc_client.log.debug( From 9260268803b67024cf9787019d2fd331c9b755b3 Mon Sep 17 00:00:00 2001 From: smereu Date: Fri, 12 Sep 2025 22:27:37 -0500 Subject: [PATCH 07/33] address some issues with tracking and steps toward complete clean-up This Pr addresses a couple of missing items in handling the return argument of the tracker and makes steps toward consolidating in the proper place the tracker code. More clean-up to come in follow-up PRs --- .../core/_grpc/_services/base/bodies.py | 5 ++ .../core/_grpc/_services/base/designs.py | 6 ++ .../core/_grpc/_services/v0/bodies.py | 58 ++++++++++++++++- .../core/_grpc/_services/v0/designs.py | 51 +++++++++++++++ .../core/_grpc/_services/v0/repair_tools.py | 62 ++----------------- .../core/_grpc/_services/v1/bodies.py | 4 ++ .../core/_grpc/_services/v1/designs.py | 4 ++ src/ansys/geometry/core/designer/body.py | 47 ++------------ src/ansys/geometry/core/designer/design.py | 39 +----------- .../geometry/core/tools/problem_areas.py | 18 +++--- 10 files changed, 151 insertions(+), 143 deletions(-) diff --git a/src/ansys/geometry/core/_grpc/_services/base/bodies.py b/src/ansys/geometry/core/_grpc/_services/base/bodies.py index 957e17f260..8938337a3e 100644 --- a/src/ansys/geometry/core/_grpc/_services/base/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/base/bodies.py @@ -218,3 +218,8 @@ def get_tesellation_with_options(self, **kwargs) -> dict: def boolean(self, **kwargs) -> dict: """Boolean operation.""" pass + + @abstractmethod + def combine(self, **kwargs) -> dict: + """Boolean operation.""" + pass diff --git a/src/ansys/geometry/core/_grpc/_services/base/designs.py b/src/ansys/geometry/core/_grpc/_services/base/designs.py index 3c8a810432..23330d1df5 100644 --- a/src/ansys/geometry/core/_grpc/_services/base/designs.py +++ b/src/ansys/geometry/core/_grpc/_services/base/designs.py @@ -83,3 +83,9 @@ def insert(self, **kwargs) -> dict: def get_active(self, **kwargs) -> dict: """Get the active design on the service.""" pass + + @abstractmethod + def _serialize_tracker_command_response(self, **kwargs) -> dict: + """Get a serialized response from the tracker.""" + pass + diff --git a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py index f9a04afefc..4267a0aef0 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py @@ -728,7 +728,7 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 if pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design = get_design_from_body(kwargs["target"]) serialized_tracker_response = parent_design._serialize_tracker_command_response( - resp.response + response=resp.response ) except grpc.RpcError as err: # pragma: no cover # TODO: to be deleted - old versions did not have "tool_bodies" in the request @@ -768,3 +768,59 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 # Return the response - formatted as a dictionary return {"complete_command_response": serialized_tracker_response} + + @protect_grpc + def combine(self, **kwargs) -> dict: # noqa: D102): + from ansys.api.geometry.v0.bodies_pb2 import CombineIntersectBodiesRequest + from ansys.api.geometry.v0.bodies_pb2 import CombineMergeBodiesRequest + + parent_design = get_design_from_body(self) + other_bodies = kwargs["other"] + type_bool_op = kwargs["type_bool_op"] + keep_other = kwargs["keep_other"] + + if type_bool_op == "intersect": + body_ids = [body._grpc_id for body in other_bodies] + target_ids = [self._grpc_id] + request = CombineIntersectBodiesRequest( + target_selection=target_ids, + tool_selection=body_ids, + subtract_from_target=False, + keep_cutter=keep_other, + ) + response = self._template._commands_stub.CombineIntersectBodies(request) + elif type_bool_op == "subtract": + body_ids = [body._grpc_id for body in other_bodies] + target_ids = [self._grpc_id] + request = CombineIntersectBodiesRequest( + target_selection=target_ids, + tool_selection=body_ids, + subtract_from_target=True, + keep_cutter=keep_other, + ) + response = self._template._commands_stub.CombineIntersectBodies(request) + elif type_bool_op == "unite": + bodies = [self] + bodies.extend(other_bodies) + body_ids = [body._grpc_id for body in bodies] + request = CombineMergeBodiesRequest(target_selection=body_ids) + response = self._template._commands_stub.CombineMergeBodies(request) + else: + raise ValueError("Unknown operation requested") + if not response.success: + raise ValueError( + f"Operation of type '{type_bool_op}' failed: {kwargs['err_msg']}.\n" + f"Involving bodies:{self}, {other_bodies}" + ) + + if not keep_other: + for b in other_bodies: + b.parent_component.delete_body(b) + + tracker_response = response.result.complete_command_response + serialized_tracker_response = parent_design._serialize_tracker_command_response( + response=tracker_response) + + # Return the response - formatted as a dictionary + return {"complete_command_response": serialized_tracker_response} + diff --git a/src/ansys/geometry/core/_grpc/_services/v0/designs.py b/src/ansys/geometry/core/_grpc/_services/v0/designs.py index fa1a370cee..e9853d497c 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/designs.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/designs.py @@ -194,3 +194,54 @@ def get_active(self, **kwargs) -> dict: # noqa: D102 "main_part_id": response.main_part.id, "name": response.name, } + + def _serialize_tracker_command_response(self, **kwargs) -> dict: + """Serialize a TrackerCommandResponse object into a dictionary. + + Parameters + ---------- + response : TrackerCommandResponse + The gRPC TrackerCommandResponse object to serialize. + + Returns + ------- + dict + A dictionary representation of the TrackerCommandResponse object. + """ + + def serialize_body(body): + return { + "id": body.id, + "name": body.name, + "can_suppress": body.can_suppress, + "transform_to_master": { + "m00": body.transform_to_master.m00, + "m11": body.transform_to_master.m11, + "m22": body.transform_to_master.m22, + "m33": body.transform_to_master.m33, + }, + "master_id": body.master_id, + "parent_id": body.parent_id, + "is_surface": body.is_surface, + } + + def serialize_entity_identifier(entity): + """Serialize an EntityIdentifier object into a dictionary.""" + return { + "id": entity.id, + } + + response = kwargs["response"] + return { + "success": response.success, + "created_bodies": [ + serialize_body(body) for body in getattr(response, "created_bodies", []) + ], + "modified_bodies": [ + serialize_body(body) for body in getattr(response, "modified_bodies", []) + ], + "deleted_bodies": [ + serialize_entity_identifier(entity) + for entity in getattr(response, "deleted_bodies", []) + ], + } diff --git a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py index e88684f90f..bfd93dc6e9 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py @@ -345,7 +345,7 @@ def find_and_fix_simplify(self, **kwargs) -> dict: # noqa: D102 response = self.stub.FindAndSimplify(request) serialized_tracker_response = kwargs["parent_design"]._serialize_tracker_command_response( - response.complete_command_response + response=response.complete_command_response ) # Return the response - formatted as a dictionary @@ -384,7 +384,7 @@ def find_and_fix_stitch_faces(self, **kwargs) -> dict: # noqa: D102 response = self.stub.FindAndFixStitchFaces(request) serialized_tracker_response = kwargs["parent_design"]._serialize_tracker_command_response( - response.complete_command_response + response=response.complete_command_response ) # Return the response - formatted as a dictionary @@ -468,7 +468,7 @@ def find_and_fix_short_edges(self, **kwargs): # noqa: D102 response = self.stub.FindAndFixShortEdges(request) serialized_tracker_response = kwargs["parent_design"]._serialize_tracker_command_response( - response.complete_command_response + response=response.complete_command_response ) # Return the response - formatted as a dictionary @@ -495,7 +495,7 @@ def find_and_fix_extra_edges(self, **kwargs) -> dict: # noqa: D102 response = self.stub.FindAndFixExtraEdges(request) serialized_tracker_response = kwargs["parent_design"]._serialize_tracker_command_response( - response.complete_command_response + response = response.complete_command_response ) # Return the response - formatted as a dictionary @@ -526,7 +526,7 @@ def find_and_fix_split_edges(self, **kwargs) -> dict: # noqa: D102 response = self.stub.FindAndFixSplitEdges(request) serialized_tracker_response = kwargs["parent_design"]._serialize_tracker_command_response( - response.complete_command_response + response = response.complete_command_response ) # Return the response - formatted as a dictionary @@ -591,54 +591,4 @@ def serialize_issue(issue): } for body_issues in response.issues_by_body ] - } - - def _serialize_tracker_command_response(self, response) -> dict: - """Serialize a TrackerCommandResponse object into a dictionary. - - Parameters - ---------- - response : TrackerCommandResponse - The gRPC TrackerCommandResponse object to serialize. - - Returns - ------- - dict - A dictionary representation of the TrackerCommandResponse object. - """ - - def serialize_body(body): - return { - "id": body.id, - "name": body.name, - "can_suppress": body.can_suppress, - "transform_to_master": { - "m00": body.transform_to_master.m00, - "m11": body.transform_to_master.m11, - "m22": body.transform_to_master.m22, - "m33": body.transform_to_master.m33, - }, - "master_id": body.master_id, - "parent_id": body.parent_id, - "is_surface": body.is_surface, - } - - def serialize_entity_identifier(entity): - """Serialize an EntityIdentifier object into a dictionary.""" - return { - "id": entity.id, - } - - return { - "success": response.success, - "created_bodies": [ - serialize_body(body) for body in getattr(response, "created_bodies", []) - ], - "modified_bodies": [ - serialize_body(body) for body in getattr(response, "modified_bodies", []) - ], - "deleted_bodies": [ - serialize_entity_identifier(entity) - for entity in getattr(response, "deleted_bodies", []) - ], - } + } \ No newline at end of file diff --git a/src/ansys/geometry/core/_grpc/_services/v1/bodies.py b/src/ansys/geometry/core/_grpc/_services/v1/bodies.py index 40f6b6d50c..dac044401a 100644 --- a/src/ansys/geometry/core/_grpc/_services/v1/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/v1/bodies.py @@ -191,3 +191,7 @@ def get_tesellation_with_options(self, **kwargs) -> dict: # noqa: D102 @protect_grpc def boolean(self, **kwargs) -> dict: # noqa: D102 raise NotImplementedError + + @protect_grpc + def combine(self, **kwargs) -> dict: # noqa: D102 + raise NotImplementedError diff --git a/src/ansys/geometry/core/_grpc/_services/v1/designs.py b/src/ansys/geometry/core/_grpc/_services/v1/designs.py index ab9967a145..a49459a477 100644 --- a/src/ansys/geometry/core/_grpc/_services/v1/designs.py +++ b/src/ansys/geometry/core/_grpc/_services/v1/designs.py @@ -82,3 +82,7 @@ def insert(self, **kwargs) -> dict: # noqa: D102 @protect_grpc def get_active(self, **kwargs) -> dict: # noqa: D102 raise NotImplementedError + + def _serialize_tracker_command_response(self, **kwargs) -> dict: # noqa: D102 + """Get a serialized response from the tracker.""" + raise NotImplementedError diff --git a/src/ansys/geometry/core/designer/body.py b/src/ansys/geometry/core/designer/body.py index 8be4dac570..c0f5b6a741 100644 --- a/src/ansys/geometry/core/designer/body.py +++ b/src/ansys/geometry/core/designer/body.py @@ -1904,7 +1904,6 @@ def unite(self, other: Union["Body", Iterable["Body"]], keep_other: bool = False else: self.__generic_boolean_command(other, False, "unite", "union operation failed") - @protect_grpc @reset_tessellation_cache @ensure_design_is_active @check_input_types @@ -1912,48 +1911,14 @@ def __generic_boolean_command( self, other: Union["Body", Iterable["Body"]], keep_other: bool, - type_bool_op: str, - err_bool_op: str, + method: str, + err_msg: str, ) -> None: parent_design = get_design_from_body(self) - other_bodies = other if isinstance(other, Iterable) else [other] - if type_bool_op == "intersect": - body_ids = [body._grpc_id for body in other_bodies] - target_ids = [self._grpc_id] - request = CombineIntersectBodiesRequest( - target_selection=target_ids, - tool_selection=body_ids, - subtract_from_target=False, - keep_cutter=keep_other, - ) - response = self._template._commands_stub.CombineIntersectBodies(request) - elif type_bool_op == "subtract": - body_ids = [body._grpc_id for body in other_bodies] - target_ids = [self._grpc_id] - request = CombineIntersectBodiesRequest( - target_selection=target_ids, - tool_selection=body_ids, - subtract_from_target=True, - keep_cutter=keep_other, - ) - response = self._template._commands_stub.CombineIntersectBodies(request) - elif type_bool_op == "unite": - bodies = [self] - bodies.extend(other_bodies) - body_ids = [body._grpc_id for body in bodies] - request = CombineMergeBodiesRequest(target_selection=body_ids) - response = self._template._commands_stub.CombineMergeBodies(request) - else: - raise ValueError("Unknown operation requested") - if not response.success: - raise ValueError( - f"Operation of type '{type_bool_op}' failed: {err_bool_op}.\n" - f"Involving bodies:{self}, {other_bodies}" - ) - - if not keep_other: - for b in other_bodies: - b.parent_component.delete_body(b) + other = other if isinstance(other, Iterable) else [other] + + response = self._template._grpc_client.services.bodies.combine( + target=self, other=other, type_bool_op=method, err_msg=err_msg, keep_other=keep_other) from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN diff --git a/src/ansys/geometry/core/designer/design.py b/src/ansys/geometry/core/designer/design.py index c943be7196..4c8f7333dd 100644 --- a/src/ansys/geometry/core/designer/design.py +++ b/src/ansys/geometry/core/designer/design.py @@ -1044,8 +1044,9 @@ def __repr__(self) -> str: lines.append(f" N Beam Profiles : {len(self.beam_profiles)}") lines.append(f" N Design Points : {len(self.design_points)}") return "\n".join(lines) + - def _serialize_tracker_command_response(self, response) -> dict: + def _serialize_tracker_command_response(self, **kwargs) -> dict: """Serialize a TrackerCommandResponse object into a dictionary. Parameters @@ -1058,41 +1059,7 @@ def _serialize_tracker_command_response(self, response) -> dict: dict A dictionary representation of the TrackerCommandResponse object. """ - - def serialize_body(body): - return { - "id": body.id, - "name": body.name, - "can_suppress": body.can_suppress, - "transform_to_master": { - "m00": body.transform_to_master.m00, - "m11": body.transform_to_master.m11, - "m22": body.transform_to_master.m22, - "m33": body.transform_to_master.m33, - }, - "master_id": body.master_id, - "parent_id": body.parent_id, - } - - def serialize_entity_identifier(entity): - """Serialize an EntityIdentifier object into a dictionary.""" - return { - "id": entity.id, - } - - return { - "success": response.success, - "created_bodies": [ - serialize_body(body) for body in getattr(response, "created_bodies", []) - ], - "modified_bodies": [ - serialize_body(body) for body in getattr(response, "modified_bodies", []) - ], - "deleted_bodies": [ - serialize_entity_identifier(entity) - for entity in getattr(response, "deleted_bodies", []) - ], - } + return self._grpc_client.services.designs._serialize_tracker_command_response(response=kwargs["response"]) def __read_existing_design(self) -> None: """Read an existing ``Design`` located on the server.""" diff --git a/src/ansys/geometry/core/tools/problem_areas.py b/src/ansys/geometry/core/tools/problem_areas.py index 11cf85a01d..07e226b533 100644 --- a/src/ansys/geometry/core/tools/problem_areas.py +++ b/src/ansys/geometry/core/tools/problem_areas.py @@ -138,7 +138,7 @@ def fix(self) -> RepairToolMessage: else: tracker_response = response.result.complete_command_response serialized_response = parent_design._serialize_tracker_command_response( - tracker_response + response = tracker_response ) parent_design._update_from_tracker(serialized_response) @@ -198,7 +198,7 @@ def fix(self) -> RepairToolMessage: ) serialized_response = parent_design._serialize_tracker_command_response( - response.result.complete_command_response + response = response.result.complete_command_response ) from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN @@ -270,7 +270,7 @@ def fix(self) -> RepairToolMessage: else: tracker_response = response.result.complete_command_response serialized_response = parent_design._serialize_tracker_command_response( - tracker_response + response = tracker_response ) parent_design._update_from_tracker(serialized_response) @@ -334,7 +334,7 @@ def fix(self) -> RepairToolMessage: else: tracker_response = response.result.complete_command_response serialized_response = parent_design._serialize_tracker_command_response( - tracker_response + response = tracker_response ) parent_design._update_from_tracker(serialized_response) @@ -399,7 +399,7 @@ def fix(self) -> RepairToolMessage: else: tracker_response = response.result.complete_command_response serialized_response = parent_design._serialize_tracker_command_response( - tracker_response + response = tracker_response ) parent_design._update_from_tracker(serialized_response) @@ -467,7 +467,7 @@ def fix(self) -> RepairToolMessage: # and update the parent design with the serialized response. tracker_response = response.result.complete_command_response serialized_response = parent_design._serialize_tracker_command_response( - tracker_response + response = tracker_response ) parent_design._update_from_tracker(serialized_response) @@ -530,7 +530,7 @@ def fix(self) -> RepairToolMessage: parent_design._update_design_inplace() else: tracker_respone = response.result.complete_command_response - serialized_response = parent_design._serialize_tracker_command_response(tracker_respone) + serialized_response = parent_design._serialize_tracker_command_response(response = tracker_respone) parent_design._update_from_tracker(serialized_response) message = RepairToolMessage( @@ -593,7 +593,7 @@ def fix(self) -> RepairToolMessage: parent_design._update_design_inplace() else: tracker_respone = response.result.complete_command_response - serialized_response = parent_design._serialize_tracker_command_response(tracker_respone) + serialized_response = parent_design._serialize_tracker_command_response(response = tracker_respone) parent_design._update_from_tracker(serialized_response) message = RepairToolMessage( @@ -650,7 +650,7 @@ def fix(self) -> RepairToolMessage: parent_design._update_design_inplace() else: tracker_respone = response.result.complete_command_response - serialized_response = parent_design._serialize_tracker_command_response(tracker_respone) + serialized_response = parent_design._serialize_tracker_command_response(response = tracker_respone) parent_design._update_from_tracker(serialized_response) message = RepairToolMessage( From cbc95621f62d14983bf95accd663435d4229424e Mon Sep 17 00:00:00 2001 From: smereu Date: Mon, 22 Sep 2025 21:06:42 -0500 Subject: [PATCH 08/33] resolve merge conflict + style changes from pre-commit --- .../core/_grpc/_services/base/designs.py | 1 - .../geometry/core/_grpc/_services/v0/bodies.py | 16 +++++++++------- .../geometry/core/_grpc/_services/v0/designs.py | 4 ++-- .../core/_grpc/_services/v0/repair_tools.py | 6 +++--- .../geometry/core/_grpc/_services/v1/bodies.py | 4 ++-- .../geometry/core/_grpc/_services/v1/designs.py | 4 ++-- src/ansys/geometry/core/designer/body.py | 8 ++++---- src/ansys/geometry/core/designer/design.py | 5 +++-- 8 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/ansys/geometry/core/_grpc/_services/base/designs.py b/src/ansys/geometry/core/_grpc/_services/base/designs.py index 23330d1df5..1a269a0708 100644 --- a/src/ansys/geometry/core/_grpc/_services/base/designs.py +++ b/src/ansys/geometry/core/_grpc/_services/base/designs.py @@ -88,4 +88,3 @@ def get_active(self, **kwargs) -> dict: def _serialize_tracker_command_response(self, **kwargs) -> dict: """Get a serialized response from the tracker.""" pass - diff --git a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py index 4267a0aef0..c4778a4a21 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py @@ -768,11 +768,13 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 # Return the response - formatted as a dictionary return {"complete_command_response": serialized_tracker_response} - + @protect_grpc def combine(self, **kwargs) -> dict: # noqa: D102): - from ansys.api.geometry.v0.bodies_pb2 import CombineIntersectBodiesRequest - from ansys.api.geometry.v0.bodies_pb2 import CombineMergeBodiesRequest + from ansys.api.geometry.v0.bodies_pb2 import ( + CombineIntersectBodiesRequest, + CombineMergeBodiesRequest, + ) parent_design = get_design_from_body(self) other_bodies = kwargs["other"] @@ -819,8 +821,8 @@ def combine(self, **kwargs) -> dict: # noqa: D102): tracker_response = response.result.complete_command_response serialized_tracker_response = parent_design._serialize_tracker_command_response( - response=tracker_response) - - # Return the response - formatted as a dictionary + response=tracker_response + ) + + # Return the response - formatted as a dictionary return {"complete_command_response": serialized_tracker_response} - diff --git a/src/ansys/geometry/core/_grpc/_services/v0/designs.py b/src/ansys/geometry/core/_grpc/_services/v0/designs.py index e9853d497c..515805706a 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/designs.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/designs.py @@ -194,7 +194,7 @@ def get_active(self, **kwargs) -> dict: # noqa: D102 "main_part_id": response.main_part.id, "name": response.name, } - + def _serialize_tracker_command_response(self, **kwargs) -> dict: """Serialize a TrackerCommandResponse object into a dictionary. @@ -244,4 +244,4 @@ def serialize_entity_identifier(entity): serialize_entity_identifier(entity) for entity in getattr(response, "deleted_bodies", []) ], - } + } diff --git a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py index 19d6314a4b..0cc0d03c94 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py @@ -490,7 +490,7 @@ def find_and_fix_extra_edges(self, **kwargs) -> dict: # noqa: D102 response = self.stub.FindAndFixExtraEdges(request) serialized_tracker_response = kwargs["parent_design"]._serialize_tracker_command_response( - response = response.complete_command_response + response=response.complete_command_response ) # Return the response - formatted as a dictionary @@ -520,7 +520,7 @@ def find_and_fix_split_edges(self, **kwargs) -> dict: # noqa: D102 response = self.stub.FindAndFixSplitEdges(request) serialized_tracker_response = kwargs["parent_design"]._serialize_tracker_command_response( - response = response.complete_command_response + response=response.complete_command_response ) # Return the response - formatted as a dictionary @@ -585,4 +585,4 @@ def serialize_issue(issue): } for body_issues in response.issues_by_body ] - } \ No newline at end of file + } diff --git a/src/ansys/geometry/core/_grpc/_services/v1/bodies.py b/src/ansys/geometry/core/_grpc/_services/v1/bodies.py index dac044401a..5cf38cfa8b 100644 --- a/src/ansys/geometry/core/_grpc/_services/v1/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/v1/bodies.py @@ -191,7 +191,7 @@ def get_tesellation_with_options(self, **kwargs) -> dict: # noqa: D102 @protect_grpc def boolean(self, **kwargs) -> dict: # noqa: D102 raise NotImplementedError - + @protect_grpc def combine(self, **kwargs) -> dict: # noqa: D102 - raise NotImplementedError + raise NotImplementedError diff --git a/src/ansys/geometry/core/_grpc/_services/v1/designs.py b/src/ansys/geometry/core/_grpc/_services/v1/designs.py index a49459a477..53f4d85874 100644 --- a/src/ansys/geometry/core/_grpc/_services/v1/designs.py +++ b/src/ansys/geometry/core/_grpc/_services/v1/designs.py @@ -82,7 +82,7 @@ def insert(self, **kwargs) -> dict: # noqa: D102 @protect_grpc def get_active(self, **kwargs) -> dict: # noqa: D102 raise NotImplementedError - - def _serialize_tracker_command_response(self, **kwargs) -> dict: # noqa: D102 + + def _serialize_tracker_command_response(self, **kwargs) -> dict: # noqa: D102 """Get a serialized response from the tracker.""" raise NotImplementedError diff --git a/src/ansys/geometry/core/designer/body.py b/src/ansys/geometry/core/designer/body.py index 718a9ce4eb..f6e57160b0 100644 --- a/src/ansys/geometry/core/designer/body.py +++ b/src/ansys/geometry/core/designer/body.py @@ -31,8 +31,6 @@ from ansys.api.geometry.v0.commands_pb2 import ( AssignMidSurfaceOffsetTypeRequest, AssignMidSurfaceThicknessRequest, - CombineIntersectBodiesRequest, - CombineMergeBodiesRequest, ImprintCurvesRequest, ProjectCurvesRequest, RemoveFacesRequest, @@ -43,6 +41,7 @@ import matplotlib.colors as mcolors from pint import Quantity +from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN from ansys.geometry.core.connection.client import GrpcClient from ansys.geometry.core.connection.conversions import ( plane_to_grpc_plane, @@ -1916,9 +1915,10 @@ def __generic_boolean_command( ) -> None: parent_design = get_design_from_body(self) other = other if isinstance(other, Iterable) else [other] - + response = self._template._grpc_client.services.bodies.combine( - target=self, other=other, type_bool_op=method, err_msg=err_msg, keep_other=keep_other) + target=self, other=other, type_bool_op=method, err_msg=err_msg, keep_other=keep_other + ) from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN diff --git a/src/ansys/geometry/core/designer/design.py b/src/ansys/geometry/core/designer/design.py index 41c7eeec92..807ddcd5d5 100644 --- a/src/ansys/geometry/core/designer/design.py +++ b/src/ansys/geometry/core/designer/design.py @@ -1044,7 +1044,6 @@ def __repr__(self) -> str: lines.append(f" N Beam Profiles : {len(self.beam_profiles)}") lines.append(f" N Design Points : {len(self.design_points)}") return "\n".join(lines) - def _serialize_tracker_command_response(self, **kwargs) -> dict: """Serialize a TrackerCommandResponse object into a dictionary. @@ -1059,7 +1058,9 @@ def _serialize_tracker_command_response(self, **kwargs) -> dict: dict A dictionary representation of the TrackerCommandResponse object. """ - return self._grpc_client.services.designs._serialize_tracker_command_response(response=kwargs["response"]) + return self._grpc_client.services.designs._serialize_tracker_command_response( + response=kwargs["response"] + ) def __read_existing_design(self) -> None: """Read an existing ``Design`` located on the server.""" From 652d21d8afb02fac7913c2efea354e75f27bfa23 Mon Sep 17 00:00:00 2001 From: smereu Date: Tue, 23 Sep 2025 22:15:01 -0500 Subject: [PATCH 09/33] misc changes for tracker implementation Move the calls from problem_area to service/v0[1] Fix usage of tracker flag Move serialize tracker to be version dependent --- .../core/_grpc/_services/base/bodies.py | 2 +- .../core/_grpc/_services/base/designs.py | 5 - .../core/_grpc/_services/base/repair_tools.py | 50 ++++ .../core/_grpc/_services/v0/designs.py | 2 +- .../core/_grpc/_services/v0/repair_tools.py | 221 +++++++++++++++- .../core/_grpc/_services/v1/designs.py | 4 - .../core/_grpc/_services/v1/repair_tools.py | 40 +++ src/ansys/geometry/core/designer/body.py | 10 +- src/ansys/geometry/core/designer/design.py | 17 -- .../geometry/core/tools/problem_areas.py | 236 ++++++------------ .../core/tools/repair_tool_message.py | 6 + 11 files changed, 400 insertions(+), 193 deletions(-) diff --git a/src/ansys/geometry/core/_grpc/_services/base/bodies.py b/src/ansys/geometry/core/_grpc/_services/base/bodies.py index 8938337a3e..463616b5df 100644 --- a/src/ansys/geometry/core/_grpc/_services/base/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/base/bodies.py @@ -221,5 +221,5 @@ def boolean(self, **kwargs) -> dict: @abstractmethod def combine(self, **kwargs) -> dict: - """Boolean operation.""" + """Boolean operation through command.""" pass diff --git a/src/ansys/geometry/core/_grpc/_services/base/designs.py b/src/ansys/geometry/core/_grpc/_services/base/designs.py index 1a269a0708..3c8a810432 100644 --- a/src/ansys/geometry/core/_grpc/_services/base/designs.py +++ b/src/ansys/geometry/core/_grpc/_services/base/designs.py @@ -83,8 +83,3 @@ def insert(self, **kwargs) -> dict: def get_active(self, **kwargs) -> dict: """Get the active design on the service.""" pass - - @abstractmethod - def _serialize_tracker_command_response(self, **kwargs) -> dict: - """Get a serialized response from the tracker.""" - pass diff --git a/src/ansys/geometry/core/_grpc/_services/base/repair_tools.py b/src/ansys/geometry/core/_grpc/_services/base/repair_tools.py index 4d2ac4cfde..620e69f72c 100644 --- a/src/ansys/geometry/core/_grpc/_services/base/repair_tools.py +++ b/src/ansys/geometry/core/_grpc/_services/base/repair_tools.py @@ -128,3 +128,53 @@ def inspect_geometry(self, **kwargs) -> dict: def repair_geometry(self, **kwargs) -> dict: """Repair the geometry by addressing identified issues.""" pass + + @abstractmethod + def fix_duplicate_faces(self, **kwargs) -> dict: # noqa: D102 + """Fix duplicate faces in the geometry.""" + pass + + @abstractmethod + def fix_missing_faces(self, **kwargs) -> dict: # noqa: D102 + """Fix missing faces in the geometry.""" + pass + + @abstractmethod + def fix_inexact_edges(self, **kwargs) -> dict: # noqa: D102 + """Fix inexact edges in the geometry.""" + pass + + @abstractmethod + def fix_extra_edges(self, **kwargs) -> dict: # noqa: D102 + """Fix extra edges in the geometry.""" + pass + + @abstractmethod + def fix_short_edges(self, **kwargs) -> dict: # noqa: D102 + """Fix short edges in the geometry.""" + pass + + @abstractmethod + def fix_small_faces(self, **kwargs) -> dict: # noqa: D102 + """Fix small faces in the geometry.""" + pass + + @abstractmethod + def fix_split_edges(self, **kwargs) -> dict: # noqa: D102 + """Fix split edges in the geometry.""" + pass + + @abstractmethod + def fix_stitch_faces(self, **kwargs) -> dict: # noqa: D102 + """Fix stitch faces in the geometry.""" + pass + + @abstractmethod + def fix_unsimplified_faces(self, **kwargs) -> dict: # noqa: D102 + """Fix areas to simplify in the geometry.""" + pass + + @abstractmethod + def fix_interference(self, **kwargs) -> dict: # noqa: D102 + """Fix interferences in the geometry.""" + pass diff --git a/src/ansys/geometry/core/_grpc/_services/v0/designs.py b/src/ansys/geometry/core/_grpc/_services/v0/designs.py index 515805706a..48f9dd6d51 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/designs.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/designs.py @@ -195,7 +195,7 @@ def get_active(self, **kwargs) -> dict: # noqa: D102 "name": response.name, } - def _serialize_tracker_command_response(self, **kwargs) -> dict: + def _serialize_tracker_command_response(**kwargs) -> dict: """Serialize a TrackerCommandResponse object into a dictionary. Parameters diff --git a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py index 0cc0d03c94..971d1237ea 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py @@ -28,6 +28,7 @@ import grpc +from ansys.geometry.core._grpc._services.v0.designs import GRPCDesignsServiceV0 as designV0 from ansys.geometry.core.errors import protect_grpc from ..base.repair_tools import GRPCRepairToolsService @@ -342,7 +343,7 @@ def find_and_fix_simplify(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FindAndSimplify(request) - serialized_tracker_response = kwargs["parent_design"]._serialize_tracker_command_response( + serialized_tracker_response = designV0._serialize_tracker_command_response( response=response.complete_command_response ) @@ -380,7 +381,7 @@ def find_and_fix_stitch_faces(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FindAndFixStitchFaces(request) - serialized_tracker_response = kwargs["parent_design"]._serialize_tracker_command_response( + serialized_tracker_response = designV0._serialize_tracker_command_response( response=response.complete_command_response ) @@ -462,7 +463,7 @@ def find_and_fix_short_edges(self, **kwargs): # noqa: D102 # Call the gRPC service response = self.stub.FindAndFixShortEdges(request) - serialized_tracker_response = kwargs["parent_design"]._serialize_tracker_command_response( + serialized_tracker_response = designV0._serialize_tracker_command_response( response=response.complete_command_response ) @@ -489,7 +490,7 @@ def find_and_fix_extra_edges(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FindAndFixExtraEdges(request) - serialized_tracker_response = kwargs["parent_design"]._serialize_tracker_command_response( + serialized_tracker_response = designV0._serialize_tracker_command_response( response=response.complete_command_response ) @@ -519,7 +520,7 @@ def find_and_fix_split_edges(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FindAndFixSplitEdges(request) - serialized_tracker_response = kwargs["parent_design"]._serialize_tracker_command_response( + serialized_tracker_response = designV0._serialize_tracker_command_response( response=response.complete_command_response ) @@ -533,6 +534,216 @@ def find_and_fix_split_edges(self, **kwargs) -> dict: # noqa: D102 "complete_command_response": serialized_tracker_response, } + @protect_grpc + def fix_duplicate_faces(self, **kwargs) -> dict: # noqa: D102 + from ansys.api.geometry.v0.repairtools_pb2 import FixDuplicateFacesRequest + + # Create the request - assumes all inputs are valid and of the proper type + request = FixDuplicateFacesRequest( + duplicate_face_problem_area_id=kwargs["duplicate_face_problem_area_id"], + ) + + # Call the gRPC service + response = self.stub.FixDuplicateFaces(request) + + serialized_tracker_response = designV0._serialize_tracker_command_response( + response=response.result.complete_command_response + ) + + # Return the response - formatted as a dictionary + return { + "tracker_response": serialized_tracker_response, + } + + @protect_grpc + def fix_missing_faces(self, **kwargs) -> dict: # noqa: D102 + from ansys.api.geometry.v0.repairtools_pb2 import FixMissingFacesRequest + + # Create the request - assumes all inputs are valid and of the proper type + request = FixMissingFacesRequest( + missing_face_problem_area_id=kwargs["missing_face_problem_area_id"], + ) + + # Call the gRPC service + response = self.stub.FixMissingFaces(request) + + serialized_tracker_response = designV0._serialize_tracker_command_response( + response=response.result.complete_command_response + ) + + # Return the response - formatted as a dictionary + return { + "tracker_response": serialized_tracker_response, + } + + @protect_grpc + def fix_inexact_edges(self, **kwargs) -> dict: # noqa: D102 + from ansys.api.geometry.v0.repairtools_pb2 import FixInexactEdgesRequest + + # Create the request - assumes all inputs are valid and of the proper type + request = FixInexactEdgesRequest( + inexact_edge_problem_area_id=kwargs["inexact_edge_problem_area_id"], + ) + + # Call the gRPC service + response = self.stub.FixInexactEdges(request) + + serialized_tracker_response = designV0._serialize_tracker_command_response( + response=response.result.complete_command_response + ) + + # Return the response - formatted as a dictionary + return { + "tracker_response": serialized_tracker_response, + } + + @protect_grpc + def fix_extra_edges(self, **kwargs) -> dict: # noqa: D102 + from ansys.api.geometry.v0.repairtools_pb2 import FixExtraEdgesRequest + + # Create the request - assumes all inputs are valid and of the proper type + request = FixExtraEdgesRequest( + extra_edge_problem_area_id=kwargs["extra_edge_problem_area_id"], + ) + + # Call the gRPC service + response = self.stub.FixExtraEdges(request) + + serialized_tracker_response = designV0._serialize_tracker_command_response( + response=response.result.complete_command_response + ) + + # Return the response - formatted as a dictionary + return { + "tracker_response": serialized_tracker_response, + } + + @protect_grpc + def fix_short_edges(self, **kwargs) -> dict: # noqa: D102 + from ansys.api.geometry.v0.repairtools_pb2 import FixShortEdgesRequest + + # Create the request - assumes all inputs are valid and of the proper type + request = FixShortEdgesRequest( + short_edge_problem_area_id=kwargs["short_edge_problem_area_id"], + ) + + # Call the gRPC service + response = self.stub.FixShortEdges(request) + + serialized_tracker_response = designV0._serialize_tracker_command_response( + response=response.result.complete_command_response + ) + + # Return the response - formatted as a dictionary + return { + "tracker_response": serialized_tracker_response, + } + + @protect_grpc + def fix_small_faces(self, **kwargs) -> dict: # noqa: D102 + from ansys.api.geometry.v0.repairtools_pb2 import FixSmallFacesRequest + + # Create the request - assumes all inputs are valid and of the proper type + request = FixSmallFacesRequest( + small_face_problem_area_id=kwargs["small_face_problem_area_id"], + ) + + # Call the gRPC service + response = self.stub.FixSmallFaces(request) + + serialized_tracker_response = designV0._serialize_tracker_command_response( + response=response.result.complete_command_response + ) + + # Return the response - formatted as a dictionary + return { + "tracker_response": serialized_tracker_response, + } + + @protect_grpc + def fix_split_edges(self, **kwargs) -> dict: # noqa: D102 + from ansys.api.geometry.v0.repairtools_pb2 import FixSplitEdgesRequest + + # Create the request - assumes all inputs are valid and of the proper type + request = FixSplitEdgesRequest( + split_edge_problem_area_id=kwargs["split_edge_problem_area_id"], + ) + + # Call the gRPC service + response = self.stub.FixSplitEdges(request) + + serialized_tracker_response = designV0._serialize_tracker_command_response( + response=response.result.complete_command_response + ) + + # Return the response - formatted as a dictionary + return { + "tracker_response": serialized_tracker_response, + } + + @protect_grpc + def fix_stitch_faces(self, **kwargs) -> dict: # noqa: D102 + from ansys.api.geometry.v0.repairtools_pb2 import FixStitchFacesRequest + + # Create the request - assumes all inputs are valid and of the proper type + request = FixStitchFacesRequest( + stitch_face_problem_area_id=kwargs["stitch_face_problem_area_id"], + ) + + # Call the gRPC service + response = self.stub.FixStitchFaces(request) + + serialized_tracker_response = designV0._serialize_tracker_command_response( + response=response.result.complete_command_response + ) + + # Return the response - formatted as a dictionary + return { + "tracker_response": serialized_tracker_response, + } + + @protect_grpc + def fix_unsimplified_faces(self, **kwargs) -> dict: # noqa: D102 + from ansys.api.geometry.v0.repairtools_pb2 import FixAdjustSimplifyRequest + + # Create the request - assumes all inputs are valid and of the proper type + request = FixAdjustSimplifyRequest( + adjust_simplify_problem_area_id=kwargs["adjust_simplify_problem_area_id"], + ) + + # Call the gRPC service + response = self.stub.FixAdjustSimplify(request) + + serialized_tracker_response = designV0._serialize_tracker_command_response( + response=response.result.complete_command_response + ) + + # Return the response - formatted as a dictionary + return { + "tracker_response": serialized_tracker_response, + } + + @protect_grpc + def fix_interference(self, **kwargs) -> dict: # noqa: D102 + from ansys.api.geometry.v0.repairtools_pb2 import FixInterferenceRequest + + # Create the request - assumes all inputs are valid and of the proper type + request = FixInterferenceRequest( + interference_problem_area_id=kwargs["interference_problem_area_id"], + ) + + # Call the gRPC service + response = self.stub.FixInterference(request) + + serialized_tracker_response = designV0._serialize_tracker_command_response( + response=response.result.complete_command_response + ) + + # Return the response - formatted as a dictionary + return { + "tracker_response": serialized_tracker_response, + } + def __serialize_inspect_result_response(self, response) -> dict: # noqa: D102 def serialize_body(body): return { diff --git a/src/ansys/geometry/core/_grpc/_services/v1/designs.py b/src/ansys/geometry/core/_grpc/_services/v1/designs.py index 53f4d85874..ab9967a145 100644 --- a/src/ansys/geometry/core/_grpc/_services/v1/designs.py +++ b/src/ansys/geometry/core/_grpc/_services/v1/designs.py @@ -82,7 +82,3 @@ def insert(self, **kwargs) -> dict: # noqa: D102 @protect_grpc def get_active(self, **kwargs) -> dict: # noqa: D102 raise NotImplementedError - - def _serialize_tracker_command_response(self, **kwargs) -> dict: # noqa: D102 - """Get a serialized response from the tracker.""" - raise NotImplementedError diff --git a/src/ansys/geometry/core/_grpc/_services/v1/repair_tools.py b/src/ansys/geometry/core/_grpc/_services/v1/repair_tools.py index 3a53f3c2f5..4c95a9a041 100644 --- a/src/ansys/geometry/core/_grpc/_services/v1/repair_tools.py +++ b/src/ansys/geometry/core/_grpc/_services/v1/repair_tools.py @@ -110,3 +110,43 @@ def inspect_geometry(self, **kwargs) -> dict: # noqa: D102 @protect_grpc def repair_geometry(self, **kwargs) -> dict: # noqa: D102 raise NotImplementedError + + @protect_grpc + def fix_duplicate_faces(self, **kwargs) -> dict: # noqa: D102 + raise NotImplementedError + + @protect_grpc + def fix_missing_faces(self, **kwargs) -> dict: # noqa: D102 + raise NotImplementedError + + @protect_grpc + def fix_inexact_edges(self, **kwargs) -> dict: # noqa: D102 + raise NotImplementedError + + @protect_grpc + def fix_extra_edges(self, **kwargs) -> dict: # noqa: D102 + raise NotImplementedError + + @protect_grpc + def fix_short_edges(self, **kwargs) -> dict: # noqa: D102 + raise NotImplementedError + + @protect_grpc + def fix_small_faces(self, **kwargs) -> dict: # noqa: D102 + raise NotImplementedError + + @protect_grpc + def fix_split_edges(self, **kwargs) -> dict: # noqa: D102 + raise NotImplementedError + + @protect_grpc + def fix_stitch_faces(self, **kwargs) -> dict: # noqa: D102 + raise NotImplementedError + + @protect_grpc + def fix_unsimplified_faces(self, **kwargs) -> dict: # noqa: D102 + raise NotImplementedError + + @protect_grpc + def fix_interference(self, **kwargs) -> dict: # noqa: D102 + raise NotImplementedError diff --git a/src/ansys/geometry/core/designer/body.py b/src/ansys/geometry/core/designer/body.py index f6e57160b0..711e0d0b82 100644 --- a/src/ansys/geometry/core/designer/body.py +++ b/src/ansys/geometry/core/designer/body.py @@ -41,7 +41,7 @@ import matplotlib.colors as mcolors from pint import Quantity -from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN +import ansys.geometry.core as pyansys_geom from ansys.geometry.core.connection.client import GrpcClient from ansys.geometry.core.connection.conversions import ( plane_to_grpc_plane, @@ -1920,9 +1920,7 @@ def __generic_boolean_command( target=self, other=other, type_bool_op=method, err_msg=err_msg, keep_other=keep_other ) - from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN - - if not USE_TRACKER_TO_UPDATE_DESIGN: + if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: # If USE_TRACKER_TO_UPDATE_DESIGN is True, we serialize the response @@ -1944,7 +1942,7 @@ def __generic_boolean_op( err_msg: str, ) -> None: grpc_other = other if isinstance(other, Iterable) else [other] - if not USE_TRACKER_TO_UPDATE_DESIGN: + if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: if keep_other: # Make a copy of the other body to keep it... # stored temporarily in the parent component - since it will be deleted @@ -1956,7 +1954,7 @@ def __generic_boolean_op( target=self, other=grpc_other, method=method, err_msg=err_msg, keep_other=keep_other ) - if not USE_TRACKER_TO_UPDATE_DESIGN: + if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: for b in grpc_other: b.parent_component.delete_body(b) else: diff --git a/src/ansys/geometry/core/designer/design.py b/src/ansys/geometry/core/designer/design.py index 807ddcd5d5..de3d364387 100644 --- a/src/ansys/geometry/core/designer/design.py +++ b/src/ansys/geometry/core/designer/design.py @@ -1045,23 +1045,6 @@ def __repr__(self) -> str: lines.append(f" N Design Points : {len(self.design_points)}") return "\n".join(lines) - def _serialize_tracker_command_response(self, **kwargs) -> dict: - """Serialize a TrackerCommandResponse object into a dictionary. - - Parameters - ---------- - response : TrackerCommandResponse - The gRPC TrackerCommandResponse object to serialize. - - Returns - ------- - dict - A dictionary representation of the TrackerCommandResponse object. - """ - return self._grpc_client.services.designs._serialize_tracker_command_response( - response=kwargs["response"] - ) - def __read_existing_design(self) -> None: """Read an existing ``Design`` located on the server.""" # diff --git a/src/ansys/geometry/core/tools/problem_areas.py b/src/ansys/geometry/core/tools/problem_areas.py index b5d6ec5712..8ac6f8f5a7 100644 --- a/src/ansys/geometry/core/tools/problem_areas.py +++ b/src/ansys/geometry/core/tools/problem_areas.py @@ -25,22 +25,13 @@ from typing import TYPE_CHECKING from ansys.api.geometry.v0.repairtools_pb2 import ( - FixAdjustSimplifyRequest, - FixDuplicateFacesRequest, - FixExtraEdgesRequest, - FixInexactEdgesRequest, FixInterferenceRequest, - FixMissingFacesRequest, - FixShortEdgesRequest, - FixSmallFacesRequest, - FixSplitEdgesRequest, - FixStitchFacesRequest, ) from ansys.api.geometry.v0.repairtools_pb2_grpc import RepairToolsStub from google.protobuf.wrappers_pb2 import Int32Value +import ansys.geometry.core as pyansys_geom from ansys.geometry.core.connection import GrpcClient -from ansys.geometry.core.errors import protect_grpc from ansys.geometry.core.misc.auxiliary import ( get_design_from_body, get_design_from_edge, @@ -83,6 +74,29 @@ def fix(self): """Fix problem area.""" raise NotImplementedError("Fix method is not implemented in the base class.") + def build_repair_tool_message_from_tracker(self, response: dict) -> RepairToolMessage: + """Build a repair tool message from tracker response. + + Parameters + ---------- + response : dict + The response from the tracker containing information about changes + + Returns + ------- + RepairToolMessage + A message containing the success status, created, modified, deleted bodies, + number of found problem areas, and number of repaired problem areas. + """ + return RepairToolMessage( + success=response.get("success"), + created_bodies=response.get("created_bodies", []), + modified_bodies=response.get("modified_bodies", []), + deleted_bodies=response.get("deleted_bodies", []), + found=response.get("found", -1), + repaired=response.get("repaired", -1), + ) + class DuplicateFaceProblemAreas(ProblemArea): """Provides duplicate face problem area definition. @@ -115,7 +129,6 @@ def faces(self) -> list["Face"]: """The list of faces connected to this problem area.""" return self._faces - @protect_grpc def fix(self) -> RepairToolMessage: """Fix the problem area. @@ -128,26 +141,17 @@ def fix(self) -> RepairToolMessage: return RepairToolMessage(False, [], []) parent_design = get_design_from_face(self.faces[0]) - response = self._repair_stub.FixDuplicateFaces( - FixDuplicateFacesRequest(duplicate_face_problem_area_id=self._grpc_id) + response = self._grpc_client.services.repair_tools.fix_duplicate_faces( + duplicate_face_problem_area_id=self._grpc_id ) - from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN + tracker_response = response.get("tracker_response") - if not USE_TRACKER_TO_UPDATE_DESIGN: + if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: - tracker_response = response.result.complete_command_response - serialized_response = parent_design._serialize_tracker_command_response( - response = tracker_response - ) - parent_design._update_from_tracker(serialized_response) - - message = RepairToolMessage( - success=response.result.success, - created_bodies=response.result.created_bodies_monikers, - modified_bodies=response.result.modified_bodies_monikers, - ) + parent_design._update_from_tracker(tracker_response) + message = self.build_repair_tool_message_from_tracker(tracker_response) return message @@ -180,7 +184,6 @@ def edges(self) -> list["Edge"]: """The list of edges connected to this problem area.""" return self._edges - @protect_grpc def fix(self) -> RepairToolMessage: """Fix the problem area. @@ -193,26 +196,17 @@ def fix(self) -> RepairToolMessage: return RepairToolMessage(False, [], []) parent_design = get_design_from_edge(self.edges[0]) - response = self._repair_stub.FixMissingFaces( - FixMissingFacesRequest(missing_face_problem_area_id=self._grpc_id) - ) - - serialized_response = parent_design._serialize_tracker_command_response( - response = response.result.complete_command_response + response = self._grpc_client.services.repair_tools.fix_missing_faces( + missing_face_problem_area_id=self._grpc_id ) + tracker_response = response.get("tracker_response") - from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN - - if not USE_TRACKER_TO_UPDATE_DESIGN: + if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: - parent_design._update_from_tracker(serialized_response) + parent_design._update_from_tracker(tracker_response) - message = RepairToolMessage( - success=response.result.success, - created_bodies=response.result.created_bodies_monikers, - modified_bodies=response.result.modified_bodies_monikers, - ) + message = self.build_repair_tool_message_from_tracker(tracker_response) return message @@ -245,7 +239,6 @@ def edges(self) -> list["Edge"]: """The list of edges connected to this problem area.""" return self._edges - @protect_grpc def fix(self) -> RepairToolMessage: """Fix the problem area. @@ -259,27 +252,17 @@ def fix(self) -> RepairToolMessage: parent_design = get_design_from_edge(self.edges[0]) - response = self._repair_stub.FixInexactEdges( - FixInexactEdgesRequest(inexact_edge_problem_area_id=self._grpc_id) + response = self._grpc_client.services.repair_tools.fix_inexact_edges( + inexact_edge_problem_area_id=self._grpc_id ) + tracker_response = response.get("tracker_response") - from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN - - if not USE_TRACKER_TO_UPDATE_DESIGN: + if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: - tracker_response = response.result.complete_command_response - serialized_response = parent_design._serialize_tracker_command_response( - response = tracker_response - ) - parent_design._update_from_tracker(serialized_response) - - message = RepairToolMessage( - success=response.result.success, - created_bodies=response.result.created_bodies_monikers, - modified_bodies=response.result.modified_bodies_monikers, - ) + parent_design._update_from_tracker(tracker_response) + message = self.build_repair_tool_message_from_tracker(tracker_response) return message @@ -312,7 +295,6 @@ def edges(self) -> list["Edge"]: """The list of edges connected to this problem area.""" return self._edges - @protect_grpc def fix(self) -> RepairToolMessage: """Fix the problem area. @@ -325,25 +307,17 @@ def fix(self) -> RepairToolMessage: return RepairToolMessage(False, [], []) parent_design = get_design_from_edge(self.edges[0]) - request = FixExtraEdgesRequest(extra_edge_problem_area_id=self._grpc_id) - response = self._repair_stub.FixExtraEdges(request) - from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN + response = self._grpc_client.services.repair_tools.fix_extra_edges( + extra_edge_problem_area_id=self._grpc_id + ) + tracker_response = response.get("tracker_response") - if not USE_TRACKER_TO_UPDATE_DESIGN: + if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: - tracker_response = response.result.complete_command_response - serialized_response = parent_design._serialize_tracker_command_response( - response = tracker_response - ) - parent_design._update_from_tracker(serialized_response) - - message = RepairToolMessage( - success=response.result.success, - created_bodies=response.result.created_bodies_monikers, - modified_bodies=response.result.modified_bodies_monikers, - ) + parent_design._update_from_tracker(tracker_response) + message = self.build_repair_tool_message_from_tracker(tracker_response) return message @@ -376,7 +350,6 @@ def edges(self) -> list["Edge"]: """The list of edges connected to this problem area.""" return self._edges - @protect_grpc def fix(self) -> RepairToolMessage: """Fix the problem area. @@ -389,26 +362,17 @@ def fix(self) -> RepairToolMessage: return RepairToolMessage(False, [], []) parent_design = get_design_from_edge(self.edges[0]) - response = self._repair_stub.FixShortEdges( - FixShortEdgesRequest(short_edge_problem_area_id=self._grpc_id) + response = self._grpc_client.services.repair_tools.fix_short_edges( + short_edge_problem_area_id=self._grpc_id ) - from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN + tracker_response = response.get("tracker_response") - if not USE_TRACKER_TO_UPDATE_DESIGN: + if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: - tracker_response = response.result.complete_command_response - serialized_response = parent_design._serialize_tracker_command_response( - response = tracker_response - ) - parent_design._update_from_tracker(serialized_response) - - message = RepairToolMessage( - success=response.result.success, - created_bodies=response.result.created_bodies_monikers, - modified_bodies=response.result.modified_bodies_monikers, - ) + parent_design._update_from_tracker(tracker_response) + message = self.build_repair_tool_message_from_tracker(tracker_response) return message @@ -441,7 +405,6 @@ def faces(self) -> list["Face"]: """The list of faces connected to this problem area.""" return self._faces - @protect_grpc def fix(self) -> RepairToolMessage: """Fix the problem area. @@ -454,28 +417,17 @@ def fix(self) -> RepairToolMessage: return RepairToolMessage(False, [], []) parent_design = get_design_from_face(self.faces[0]) - response = self._repair_stub.FixSmallFaces( - FixSmallFacesRequest(small_face_problem_area_id=self._grpc_id) + response = self._grpc_client.services.repair_tools.fix_small_faces( + small_face_problem_area_id=self._grpc_id ) + tracker_response = response.get("tracker_response") - from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN - - if not USE_TRACKER_TO_UPDATE_DESIGN: + if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: - # If USE_TRACKER_TO_UPDATE_DESIGN is True, we serialize the response - # and update the parent design with the serialized response. - tracker_response = response.result.complete_command_response - serialized_response = parent_design._serialize_tracker_command_response( - response = tracker_response - ) - parent_design._update_from_tracker(serialized_response) - - message = RepairToolMessage( - success=response.result.success, - created_bodies=response.result.created_bodies_monikers, - modified_bodies=response.result.modified_bodies_monikers, - ) + parent_design._update_from_tracker(tracker_response) + + message = self.build_repair_tool_message_from_tracker(tracker_response) return message @@ -508,7 +460,6 @@ def edges(self) -> list["Edge"]: """The list of edges connected to this problem area.""" return self._edges - @protect_grpc def fix(self) -> RepairToolMessage: """Fix the problem area. @@ -521,24 +472,17 @@ def fix(self) -> RepairToolMessage: return RepairToolMessage(False, [], []) parent_design = get_design_from_edge(self.edges[0]) - response = self._repair_stub.FixSplitEdges( - FixSplitEdgesRequest(split_edge_problem_area_id=self._grpc_id) + response = self._grpc_client.services.repair_tools.fix_split_edges( + split_edge_problem_area_id=self._grpc_id ) - from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN + tracker_response = response.get("tracker_response") - if not USE_TRACKER_TO_UPDATE_DESIGN: + if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: - tracker_respone = response.result.complete_command_response - serialized_response = parent_design._serialize_tracker_command_response(response = tracker_respone) - parent_design._update_from_tracker(serialized_response) - - message = RepairToolMessage( - success=response.result.success, - created_bodies=response.result.created_bodies_monikers, - modified_bodies=response.result.modified_bodies_monikers, - ) + parent_design._update_from_tracker(tracker_response) + message = self.build_repair_tool_message_from_tracker(tracker_response) return message @@ -571,7 +515,6 @@ def bodies(self) -> list["Body"]: """The list of bodies connected to this problem area.""" return self._bodies - @protect_grpc def fix(self) -> RepairToolMessage: """Fix the problem area. @@ -584,23 +527,17 @@ def fix(self) -> RepairToolMessage: return RepairToolMessage(False, [], []) parent_design = get_design_from_body(self.bodies[0]) - response = self._repair_stub.FixStitchFaces( - FixStitchFacesRequest(stitch_face_problem_area_id=self._grpc_id) + response = self._grpc_client.services.repair_tools.fix_stitch_faces( + stitch_face_problem_area_id=self._grpc_id ) - from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN + tracker_response = response.get("tracker_response") - if not USE_TRACKER_TO_UPDATE_DESIGN: + if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: - tracker_respone = response.result.complete_command_response - serialized_response = parent_design._serialize_tracker_command_response(response = tracker_respone) - parent_design._update_from_tracker(serialized_response) - - message = RepairToolMessage( - success=response.result.success, - created_bodies=response.result.created_bodies_monikers, - modified_bodies=response.result.modified_bodies_monikers, - ) + parent_design._update_from_tracker(tracker_response) + + message = self.build_repair_tool_message_from_tracker(tracker_response) return message @@ -628,7 +565,6 @@ def faces(self) -> list["Face"]: """The list of faces connected to this problem area.""" return self._faces - @protect_grpc def fix(self) -> RepairToolMessage: """Fix the problem area. @@ -641,23 +577,17 @@ def fix(self) -> RepairToolMessage: return RepairToolMessage(False, [], []) parent_design = get_design_from_face(self.faces[0]) - response = self._repair_stub.FixAdjustSimplify( - FixAdjustSimplifyRequest(adjust_simplify_problem_area_id=self._grpc_id) + response = self._grpc_client.services.repair_tools.fix_unsimplified_faces( + adjust_simplify_problem_area_id=self._grpc_id ) - from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN + tracker_response = response.get("tracker_response") - if not USE_TRACKER_TO_UPDATE_DESIGN: + if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: - tracker_respone = response.result.complete_command_response - serialized_response = parent_design._serialize_tracker_command_response(response = tracker_respone) - parent_design._update_from_tracker(serialized_response) - - message = RepairToolMessage( - success=response.result.success, - created_bodies=response.result.created_bodies_monikers, - modified_bodies=response.result.modified_bodies_monikers, - ) + parent_design._update_from_tracker(tracker_response) + + message = self.build_repair_tool_message_from_tracker(tracker_response) return message @@ -685,7 +615,6 @@ def bodies(self) -> list["Body"]: """The list of the bodies connected to this problem area.""" return self._bodies - @protect_grpc def fix(self) -> RepairToolMessage: """Fix the problem area. @@ -710,7 +639,6 @@ def fix(self) -> RepairToolMessage: ## The tool does not return the created or modified objects. ## https://github.com/ansys/pyansys-geometry/issues/1319 message = RepairToolMessage(response.result.success, [], []) - return message diff --git a/src/ansys/geometry/core/tools/repair_tool_message.py b/src/ansys/geometry/core/tools/repair_tool_message.py index 45ef82c33e..ea1725a2bb 100644 --- a/src/ansys/geometry/core/tools/repair_tool_message.py +++ b/src/ansys/geometry/core/tools/repair_tool_message.py @@ -59,6 +59,7 @@ def __init__( self._success = success self._created_bodies = created_bodies self._modified_bodies = modified_bodies + self._deleted_bodies = deleted_bodies self._found = found self._repaired = repaired @@ -77,6 +78,11 @@ def modified_bodies(self) -> list[str]: """The list of the modified bodies after the repair operation.""" return self._modified_bodies + @property + def deleted_bodies(self) -> list[str]: + """The list of the deleted bodies after the repair operation.""" + return self._deleted_bodies + @property def found(self) -> int: """Number of problem areas found for the repair operation.""" From c562347f661bdb5753f38d11013c89d5ab9e40c9 Mon Sep 17 00:00:00 2001 From: smereu Date: Tue, 23 Sep 2025 22:31:42 -0500 Subject: [PATCH 10/33] fix tracker invocation fix a couple of tracker invocations --- src/ansys/geometry/core/_grpc/_services/v0/bodies.py | 5 +++-- src/ansys/geometry/core/designer/body.py | 8 +------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py index c4778a4a21..3494249fa7 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py @@ -25,6 +25,7 @@ import pint import ansys.geometry.core as pyansys_geom +from ansys.geometry.core._grpc._services.v0.designs import GRPCDesignsServiceV0 as designV0 from ansys.geometry.core.errors import protect_grpc from ansys.geometry.core.misc.auxiliary import get_design_from_body from ansys.geometry.core.misc.measurements import DEFAULT_UNITS @@ -727,7 +728,7 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 resp = self.stub.Boolean(request=request) if pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design = get_design_from_body(kwargs["target"]) - serialized_tracker_response = parent_design._serialize_tracker_command_response( + serialized_tracker_response = designV0._serialize_tracker_command_response( response=resp.response ) except grpc.RpcError as err: # pragma: no cover @@ -820,7 +821,7 @@ def combine(self, **kwargs) -> dict: # noqa: D102): b.parent_component.delete_body(b) tracker_response = response.result.complete_command_response - serialized_tracker_response = parent_design._serialize_tracker_command_response( + serialized_tracker_response = designV0._serialize_tracker_command_response( response=tracker_response ) diff --git a/src/ansys/geometry/core/designer/body.py b/src/ansys/geometry/core/designer/body.py index 711e0d0b82..b1d948b977 100644 --- a/src/ansys/geometry/core/designer/body.py +++ b/src/ansys/geometry/core/designer/body.py @@ -1923,13 +1923,7 @@ def __generic_boolean_command( if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: - # If USE_TRACKER_TO_UPDATE_DESIGN is True, we serialize the response - # and update the parent design with the serialized response. - tracker_response = response.result.complete_command_response - serialized_response = parent_design._serialize_tracker_command_response( - tracker_response - ) - parent_design._update_from_tracker(serialized_response) + parent_design._update_from_tracker(response["complete_command_response"]) @reset_tessellation_cache @ensure_design_is_active From ba707d880db27f0b13b599f9cc259ee60c8ec616 Mon Sep 17 00:00:00 2001 From: smereu Date: Wed, 24 Sep 2025 12:32:51 -0500 Subject: [PATCH 11/33] fix response for older versions with no tracker --- src/ansys/geometry/core/_grpc/_services/v0/bodies.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py index 3494249fa7..b79d03f0c6 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py @@ -771,7 +771,7 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 return {"complete_command_response": serialized_tracker_response} @protect_grpc - def combine(self, **kwargs) -> dict: # noqa: D102): + def combine(self, **kwargs) -> dict: # noqa: D102 from ansys.api.geometry.v0.bodies_pb2 import ( CombineIntersectBodiesRequest, CombineMergeBodiesRequest, From 32e5b6438c3926eb423f21c83e39934073c537f3 Mon Sep 17 00:00:00 2001 From: smereu Date: Wed, 24 Sep 2025 12:33:25 -0500 Subject: [PATCH 12/33] fix response for older version with no tracker --- .../geometry/core/_grpc/_services/v0/repair_tools.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py index 971d1237ea..e46d433c19 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py @@ -549,6 +549,7 @@ def fix_duplicate_faces(self, **kwargs) -> dict: # noqa: D102 serialized_tracker_response = designV0._serialize_tracker_command_response( response=response.result.complete_command_response ) + serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { @@ -570,6 +571,7 @@ def fix_missing_faces(self, **kwargs) -> dict: # noqa: D102 serialized_tracker_response = designV0._serialize_tracker_command_response( response=response.result.complete_command_response ) + serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { @@ -591,6 +593,7 @@ def fix_inexact_edges(self, **kwargs) -> dict: # noqa: D102 serialized_tracker_response = designV0._serialize_tracker_command_response( response=response.result.complete_command_response ) + serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { @@ -612,6 +615,7 @@ def fix_extra_edges(self, **kwargs) -> dict: # noqa: D102 serialized_tracker_response = designV0._serialize_tracker_command_response( response=response.result.complete_command_response ) + serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { @@ -633,6 +637,7 @@ def fix_short_edges(self, **kwargs) -> dict: # noqa: D102 serialized_tracker_response = designV0._serialize_tracker_command_response( response=response.result.complete_command_response ) + serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { @@ -654,6 +659,7 @@ def fix_small_faces(self, **kwargs) -> dict: # noqa: D102 serialized_tracker_response = designV0._serialize_tracker_command_response( response=response.result.complete_command_response ) + serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { @@ -675,6 +681,7 @@ def fix_split_edges(self, **kwargs) -> dict: # noqa: D102 serialized_tracker_response = designV0._serialize_tracker_command_response( response=response.result.complete_command_response ) + serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { @@ -696,6 +703,7 @@ def fix_stitch_faces(self, **kwargs) -> dict: # noqa: D102 serialized_tracker_response = designV0._serialize_tracker_command_response( response=response.result.complete_command_response ) + serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { @@ -717,6 +725,7 @@ def fix_unsimplified_faces(self, **kwargs) -> dict: # noqa: D102 serialized_tracker_response = designV0._serialize_tracker_command_response( response=response.result.complete_command_response ) + serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { @@ -738,6 +747,7 @@ def fix_interference(self, **kwargs) -> dict: # noqa: D102 serialized_tracker_response = designV0._serialize_tracker_command_response( response=response.result.complete_command_response ) + serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { From 7847f7fe9371ba3dd09b268f3a389d4af365d5c7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 24 Sep 2025 17:35:55 +0000 Subject: [PATCH 13/33] chore: auto fixes from pre-commit hooks --- .../geometry/core/_grpc/_services/v0/repair_tools.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py index e46d433c19..a09e65ba74 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py @@ -615,7 +615,7 @@ def fix_extra_edges(self, **kwargs) -> dict: # noqa: D102 serialized_tracker_response = designV0._serialize_tracker_command_response( response=response.result.complete_command_response ) - serialized_tracker_response["success"] = response.result.success + serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { @@ -637,7 +637,7 @@ def fix_short_edges(self, **kwargs) -> dict: # noqa: D102 serialized_tracker_response = designV0._serialize_tracker_command_response( response=response.result.complete_command_response ) - serialized_tracker_response["success"] = response.result.success + serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { @@ -659,7 +659,7 @@ def fix_small_faces(self, **kwargs) -> dict: # noqa: D102 serialized_tracker_response = designV0._serialize_tracker_command_response( response=response.result.complete_command_response ) - serialized_tracker_response["success"] = response.result.success + serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { @@ -703,7 +703,7 @@ def fix_stitch_faces(self, **kwargs) -> dict: # noqa: D102 serialized_tracker_response = designV0._serialize_tracker_command_response( response=response.result.complete_command_response ) - serialized_tracker_response["success"] = response.result.success + serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { @@ -725,7 +725,7 @@ def fix_unsimplified_faces(self, **kwargs) -> dict: # noqa: D102 serialized_tracker_response = designV0._serialize_tracker_command_response( response=response.result.complete_command_response ) - serialized_tracker_response["success"] = response.result.success + serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { @@ -747,7 +747,7 @@ def fix_interference(self, **kwargs) -> dict: # noqa: D102 serialized_tracker_response = designV0._serialize_tracker_command_response( response=response.result.complete_command_response ) - serialized_tracker_response["success"] = response.result.success + serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { From b7f27c3f630187e210601fd464e3af43f07701d6 Mon Sep 17 00:00:00 2001 From: smereu Date: Wed, 24 Sep 2025 22:47:37 -0500 Subject: [PATCH 14/33] Misc. fixes and clean up for problem area --- .../core/_grpc/_services/v0/bodies.py | 8 +-- .../core/_grpc/_services/v0/conversions.py | 52 +++++++++++++++ .../core/_grpc/_services/v0/designs.py | 51 --------------- .../core/_grpc/_services/v0/repair_tools.py | 61 +++++++++-------- .../geometry/core/tools/problem_areas.py | 65 +++++++++---------- 5 files changed, 120 insertions(+), 117 deletions(-) diff --git a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py index b79d03f0c6..42dd579a46 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py @@ -25,7 +25,6 @@ import pint import ansys.geometry.core as pyansys_geom -from ansys.geometry.core._grpc._services.v0.designs import GRPCDesignsServiceV0 as designV0 from ansys.geometry.core.errors import protect_grpc from ansys.geometry.core.misc.auxiliary import get_design_from_body from ansys.geometry.core.misc.measurements import DEFAULT_UNITS @@ -46,6 +45,7 @@ from_trimmed_curve_to_grpc_trimmed_curve, from_trimmed_surface_to_grpc_trimmed_surface, from_unit_vector_to_grpc_direction, + serialize_tracker_command_response, ) @@ -728,7 +728,7 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 resp = self.stub.Boolean(request=request) if pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design = get_design_from_body(kwargs["target"]) - serialized_tracker_response = designV0._serialize_tracker_command_response( + serialized_tracker_response = serialize_tracker_command_response( response=resp.response ) except grpc.RpcError as err: # pragma: no cover @@ -821,9 +821,7 @@ def combine(self, **kwargs) -> dict: # noqa: D102 b.parent_component.delete_body(b) tracker_response = response.result.complete_command_response - serialized_tracker_response = designV0._serialize_tracker_command_response( - response=tracker_response - ) + serialized_tracker_response = serialize_tracker_command_response(response=tracker_response) # Return the response - formatted as a dictionary return {"complete_command_response": serialized_tracker_response} diff --git a/src/ansys/geometry/core/_grpc/_services/v0/conversions.py b/src/ansys/geometry/core/_grpc/_services/v0/conversions.py index 06be546dce..c3bd519d29 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/conversions.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/conversions.py @@ -1221,3 +1221,55 @@ def _check_write_body_facets_input(backend_version: "semver.Version", write_body + "26.1.0, but the current version used is " + f"{backend_version}." ) + + +def serialize_tracker_command_response(**kwargs) -> dict: + """Serialize a TrackerCommandResponse object into a dictionary. + + Parameters + ---------- + response : TrackerCommandResponse + The gRPC TrackerCommandResponse object to serialize. + + Returns + ------- + dict + A dictionary representation of the TrackerCommandResponse object. + """ + + def serialize_body(body): + return { + "id": body.id, + "name": body.name, + "can_suppress": body.can_suppress, + "transform_to_master": { + "m00": body.transform_to_master.m00, + "m11": body.transform_to_master.m11, + "m22": body.transform_to_master.m22, + "m33": body.transform_to_master.m33, + }, + "master_id": body.master_id, + "parent_id": body.parent_id, + "is_surface": body.is_surface, + } + + def serialize_entity_identifier(entity): + """Serialize an EntityIdentifier object into a dictionary.""" + return { + "id": entity.id, + } + + response = kwargs["response"] + return { + "success": response.success, + "created_bodies": [ + serialize_body(body) for body in getattr(response, "created_bodies", []) + ], + "modified_bodies": [ + serialize_body(body) for body in getattr(response, "modified_bodies", []) + ], + "deleted_bodies": [ + serialize_entity_identifier(entity) + for entity in getattr(response, "deleted_bodies", []) + ], + } diff --git a/src/ansys/geometry/core/_grpc/_services/v0/designs.py b/src/ansys/geometry/core/_grpc/_services/v0/designs.py index 48f9dd6d51..fa1a370cee 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/designs.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/designs.py @@ -194,54 +194,3 @@ def get_active(self, **kwargs) -> dict: # noqa: D102 "main_part_id": response.main_part.id, "name": response.name, } - - def _serialize_tracker_command_response(**kwargs) -> dict: - """Serialize a TrackerCommandResponse object into a dictionary. - - Parameters - ---------- - response : TrackerCommandResponse - The gRPC TrackerCommandResponse object to serialize. - - Returns - ------- - dict - A dictionary representation of the TrackerCommandResponse object. - """ - - def serialize_body(body): - return { - "id": body.id, - "name": body.name, - "can_suppress": body.can_suppress, - "transform_to_master": { - "m00": body.transform_to_master.m00, - "m11": body.transform_to_master.m11, - "m22": body.transform_to_master.m22, - "m33": body.transform_to_master.m33, - }, - "master_id": body.master_id, - "parent_id": body.parent_id, - "is_surface": body.is_surface, - } - - def serialize_entity_identifier(entity): - """Serialize an EntityIdentifier object into a dictionary.""" - return { - "id": entity.id, - } - - response = kwargs["response"] - return { - "success": response.success, - "created_bodies": [ - serialize_body(body) for body in getattr(response, "created_bodies", []) - ], - "modified_bodies": [ - serialize_body(body) for body in getattr(response, "modified_bodies", []) - ], - "deleted_bodies": [ - serialize_entity_identifier(entity) - for entity in getattr(response, "deleted_bodies", []) - ], - } diff --git a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py index e46d433c19..56c2f64e90 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py @@ -28,10 +28,12 @@ import grpc -from ansys.geometry.core._grpc._services.v0.designs import GRPCDesignsServiceV0 as designV0 from ansys.geometry.core.errors import protect_grpc from ..base.repair_tools import GRPCRepairToolsService +from .conversions import ( + serialize_tracker_command_response, +) class GRPCRepairToolsServiceV0(GRPCRepairToolsService): # noqa: D102 @@ -343,7 +345,7 @@ def find_and_fix_simplify(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FindAndSimplify(request) - serialized_tracker_response = designV0._serialize_tracker_command_response( + serialized_tracker_response = serialize_tracker_command_response( response=response.complete_command_response ) @@ -381,7 +383,7 @@ def find_and_fix_stitch_faces(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FindAndFixStitchFaces(request) - serialized_tracker_response = designV0._serialize_tracker_command_response( + serialized_tracker_response = serialize_tracker_command_response( response=response.complete_command_response ) @@ -463,7 +465,7 @@ def find_and_fix_short_edges(self, **kwargs): # noqa: D102 # Call the gRPC service response = self.stub.FindAndFixShortEdges(request) - serialized_tracker_response = designV0._serialize_tracker_command_response( + serialized_tracker_response = serialize_tracker_command_response( response=response.complete_command_response ) @@ -490,7 +492,7 @@ def find_and_fix_extra_edges(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FindAndFixExtraEdges(request) - serialized_tracker_response = designV0._serialize_tracker_command_response( + serialized_tracker_response = serialize_tracker_command_response( response=response.complete_command_response ) @@ -520,7 +522,7 @@ def find_and_fix_split_edges(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FindAndFixSplitEdges(request) - serialized_tracker_response = designV0._serialize_tracker_command_response( + serialized_tracker_response = serialize_tracker_command_response( response=response.complete_command_response ) @@ -546,14 +548,14 @@ def fix_duplicate_faces(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FixDuplicateFaces(request) - serialized_tracker_response = designV0._serialize_tracker_command_response( + serialized_tracker_response = serialize_tracker_command_response( response=response.result.complete_command_response ) - serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { "tracker_response": serialized_tracker_response, + "repair_tracker_response": self.__serialize_message_response(response), } @protect_grpc @@ -568,14 +570,14 @@ def fix_missing_faces(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FixMissingFaces(request) - serialized_tracker_response = designV0._serialize_tracker_command_response( + serialized_tracker_response = serialize_tracker_command_response( response=response.result.complete_command_response ) - serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { "tracker_response": serialized_tracker_response, + "repair_tracker_response": self.__serialize_message_response(response), } @protect_grpc @@ -590,14 +592,14 @@ def fix_inexact_edges(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FixInexactEdges(request) - serialized_tracker_response = designV0._serialize_tracker_command_response( + serialized_tracker_response = serialize_tracker_command_response( response=response.result.complete_command_response ) - serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { "tracker_response": serialized_tracker_response, + "repair_tracker_response": self.__serialize_message_response(response), } @protect_grpc @@ -612,14 +614,14 @@ def fix_extra_edges(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FixExtraEdges(request) - serialized_tracker_response = designV0._serialize_tracker_command_response( + serialized_tracker_response = serialize_tracker_command_response( response=response.result.complete_command_response ) - serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { "tracker_response": serialized_tracker_response, + "repair_tracker_response": self.__serialize_message_response(response), } @protect_grpc @@ -634,14 +636,14 @@ def fix_short_edges(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FixShortEdges(request) - serialized_tracker_response = designV0._serialize_tracker_command_response( + serialized_tracker_response = serialize_tracker_command_response( response=response.result.complete_command_response ) - serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { "tracker_response": serialized_tracker_response, + "repair_tracker_response": self.__serialize_message_response(response), } @protect_grpc @@ -656,14 +658,14 @@ def fix_small_faces(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FixSmallFaces(request) - serialized_tracker_response = designV0._serialize_tracker_command_response( + serialized_tracker_response = serialize_tracker_command_response( response=response.result.complete_command_response ) - serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { "tracker_response": serialized_tracker_response, + "repair_tracker_response": self.__serialize_message_response(response), } @protect_grpc @@ -678,14 +680,14 @@ def fix_split_edges(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FixSplitEdges(request) - serialized_tracker_response = designV0._serialize_tracker_command_response( + serialized_tracker_response = serialize_tracker_command_response( response=response.result.complete_command_response ) - serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { "tracker_response": serialized_tracker_response, + "repair_tracker_response": self.__serialize_message_response(response), } @protect_grpc @@ -700,14 +702,14 @@ def fix_stitch_faces(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FixStitchFaces(request) - serialized_tracker_response = designV0._serialize_tracker_command_response( + serialized_tracker_response = serialize_tracker_command_response( response=response.result.complete_command_response ) - serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { "tracker_response": serialized_tracker_response, + "repair_tracker_response": self.__serialize_message_response(response), } @protect_grpc @@ -722,14 +724,14 @@ def fix_unsimplified_faces(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FixAdjustSimplify(request) - serialized_tracker_response = designV0._serialize_tracker_command_response( + serialized_tracker_response = serialize_tracker_command_response( response=response.result.complete_command_response ) - serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { "tracker_response": serialized_tracker_response, + "repair_tracker_response": self.__serialize_message_response(response), } @protect_grpc @@ -744,14 +746,14 @@ def fix_interference(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FixInterference(request) - serialized_tracker_response = designV0._serialize_tracker_command_response( + serialized_tracker_response = serialize_tracker_command_response( response=response.result.complete_command_response ) - serialized_tracker_response["success"] = response.result.success # Return the response - formatted as a dictionary return { "tracker_response": serialized_tracker_response, + "repair_tracker_response": self.__serialize_message_response(response), } def __serialize_inspect_result_response(self, response) -> dict: # noqa: D102 @@ -807,3 +809,10 @@ def serialize_issue(issue): for body_issues in response.issues_by_body ] } + + def __serialize_message_response(self, response): + return { + "success": response.result.success, + "created_bodies_monikers": response.result.created_bodies_monikers, + "modified_bodies_monikers": response.result.modified_bodies_monikers, + } diff --git a/src/ansys/geometry/core/tools/problem_areas.py b/src/ansys/geometry/core/tools/problem_areas.py index 8ac6f8f5a7..609fa874a2 100644 --- a/src/ansys/geometry/core/tools/problem_areas.py +++ b/src/ansys/geometry/core/tools/problem_areas.py @@ -74,25 +74,24 @@ def fix(self): """Fix problem area.""" raise NotImplementedError("Fix method is not implemented in the base class.") - def build_repair_tool_message_from_tracker(self, response: dict) -> RepairToolMessage: - """Build a repair tool message from tracker response. + def build_repair_tool_message(self, response: dict) -> RepairToolMessage: + """Build a repair tool message from the service response. Parameters ---------- response : dict - The response from the tracker containing information about changes + The response from the service containing information about the repair operation. Returns ------- RepairToolMessage - A message containing the success status, created, modified, deleted bodies, + A message containing the success status, created bodies, modified bodies, number of found problem areas, and number of repaired problem areas. """ return RepairToolMessage( success=response.get("success"), - created_bodies=response.get("created_bodies", []), - modified_bodies=response.get("modified_bodies", []), - deleted_bodies=response.get("deleted_bodies", []), + created_bodies=response.get("created_bodies_monikers", []), + modified_bodies=response.get("modified_bodies_monikers", []), found=response.get("found", -1), repaired=response.get("repaired", -1), ) @@ -144,14 +143,13 @@ def fix(self) -> RepairToolMessage: response = self._grpc_client.services.repair_tools.fix_duplicate_faces( duplicate_face_problem_area_id=self._grpc_id ) - tracker_response = response.get("tracker_response") if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: - parent_design._update_from_tracker(tracker_response) + parent_design._update_from_tracker(response.get("tracker_response")) - message = self.build_repair_tool_message_from_tracker(tracker_response) + message = self.build_repair_tool_message(response.get("repair_tracker_response")) return message @@ -199,14 +197,13 @@ def fix(self) -> RepairToolMessage: response = self._grpc_client.services.repair_tools.fix_missing_faces( missing_face_problem_area_id=self._grpc_id ) - tracker_response = response.get("tracker_response") if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: - parent_design._update_from_tracker(tracker_response) + parent_design._update_from_tracker(response.get("tracker_response")) - message = self.build_repair_tool_message_from_tracker(tracker_response) + message = self.build_repair_tool_message(response.get("repair_tracker_response")) return message @@ -255,14 +252,13 @@ def fix(self) -> RepairToolMessage: response = self._grpc_client.services.repair_tools.fix_inexact_edges( inexact_edge_problem_area_id=self._grpc_id ) - tracker_response = response.get("tracker_response") if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: - parent_design._update_from_tracker(tracker_response) + parent_design._update_from_tracker(response.get("tracker_response")) - message = self.build_repair_tool_message_from_tracker(tracker_response) + message = self.build_repair_tool_message(response.get("repair_tracker_response")) return message @@ -310,14 +306,13 @@ def fix(self) -> RepairToolMessage: response = self._grpc_client.services.repair_tools.fix_extra_edges( extra_edge_problem_area_id=self._grpc_id ) - tracker_response = response.get("tracker_response") if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: - parent_design._update_from_tracker(tracker_response) + parent_design._update_from_tracker(response.get("tracker_response")) - message = self.build_repair_tool_message_from_tracker(tracker_response) + message = self.build_repair_tool_message(response.get("repair_tracker_response")) return message @@ -365,14 +360,13 @@ def fix(self) -> RepairToolMessage: response = self._grpc_client.services.repair_tools.fix_short_edges( short_edge_problem_area_id=self._grpc_id ) - tracker_response = response.get("tracker_response") if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: - parent_design._update_from_tracker(tracker_response) + parent_design._update_from_tracker(response.get("tracker_response")) - message = self.build_repair_tool_message_from_tracker(tracker_response) + message = self.build_repair_tool_message(response.get("repair_tracker_response")) return message @@ -420,14 +414,13 @@ def fix(self) -> RepairToolMessage: response = self._grpc_client.services.repair_tools.fix_small_faces( small_face_problem_area_id=self._grpc_id ) - tracker_response = response.get("tracker_response") if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: - parent_design._update_from_tracker(tracker_response) + parent_design._update_from_tracker(response.get("tracker_response")) - message = self.build_repair_tool_message_from_tracker(tracker_response) + message = self.build_repair_tool_message(response.get("repair_tracker_response")) return message @@ -475,14 +468,13 @@ def fix(self) -> RepairToolMessage: response = self._grpc_client.services.repair_tools.fix_split_edges( split_edge_problem_area_id=self._grpc_id ) - tracker_response = response.get("tracker_response") if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: - parent_design._update_from_tracker(tracker_response) + parent_design._update_from_tracker(response.get("tracker_response")) - message = self.build_repair_tool_message_from_tracker(tracker_response) + message = self.build_repair_tool_message(response.get("repair_tracker_response")) return message @@ -530,14 +522,13 @@ def fix(self) -> RepairToolMessage: response = self._grpc_client.services.repair_tools.fix_stitch_faces( stitch_face_problem_area_id=self._grpc_id ) - tracker_response = response.get("tracker_response") if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: - parent_design._update_from_tracker(tracker_response) + parent_design._update_from_tracker(response.get("tracker_response")) - message = self.build_repair_tool_message_from_tracker(tracker_response) + message = self.build_repair_tool_message(response.get("repair_tracker_response")) return message @@ -580,14 +571,13 @@ def fix(self) -> RepairToolMessage: response = self._grpc_client.services.repair_tools.fix_unsimplified_faces( adjust_simplify_problem_area_id=self._grpc_id ) - tracker_response = response.get("tracker_response") if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() else: - parent_design._update_from_tracker(tracker_response) + parent_design._update_from_tracker(response.get("tracker_response")) - message = self.build_repair_tool_message_from_tracker(tracker_response) + message = self.build_repair_tool_message(response.get("repair_tracker_response")) return message @@ -635,7 +625,12 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixInterference( FixInterferenceRequest(interference_problem_area_id=self._grpc_id) ) - parent_design._update_design_inplace() + + if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: + parent_design._update_design_inplace() + else: + parent_design._update_from_tracker(response.get("tracker_response")) + ## The tool does not return the created or modified objects. ## https://github.com/ansys/pyansys-geometry/issues/1319 message = RepairToolMessage(response.result.success, [], []) From e1529c04e5a29fa2067e02f8870ece9a925a09aa Mon Sep 17 00:00:00 2001 From: smereu Date: Wed, 24 Sep 2025 22:51:54 -0500 Subject: [PATCH 15/33] remove unused variable --- src/ansys/geometry/core/_grpc/_services/v0/bodies.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py index 42dd579a46..160c42a584 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py @@ -727,7 +727,6 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 request.keep_other = kwargs["keep_other"] resp = self.stub.Boolean(request=request) if pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: - parent_design = get_design_from_body(kwargs["target"]) serialized_tracker_response = serialize_tracker_command_response( response=resp.response ) @@ -777,7 +776,6 @@ def combine(self, **kwargs) -> dict: # noqa: D102 CombineMergeBodiesRequest, ) - parent_design = get_design_from_body(self) other_bodies = kwargs["other"] type_bool_op = kwargs["type_bool_op"] keep_other = kwargs["keep_other"] From 39cfe9b7b502f3af57290f8e415e5cc1c544e381 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 25 Sep 2025 03:53:02 +0000 Subject: [PATCH 16/33] chore: auto fixes from pre-commit hooks --- src/ansys/geometry/core/_grpc/_services/v0/bodies.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py index 160c42a584..f395020651 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py @@ -26,7 +26,6 @@ import ansys.geometry.core as pyansys_geom from ansys.geometry.core.errors import protect_grpc -from ansys.geometry.core.misc.auxiliary import get_design_from_body from ansys.geometry.core.misc.measurements import DEFAULT_UNITS from ..base.bodies import GRPCBodyService From ecb7d501e80550ac88e6381b99956228ff9a3fd1 Mon Sep 17 00:00:00 2001 From: smereu Date: Thu, 25 Sep 2025 11:25:37 -0500 Subject: [PATCH 17/33] fix test failing in old release --- src/ansys/geometry/core/_grpc/_services/v0/bodies.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py index 160c42a584..cf41aa9c89 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py @@ -748,7 +748,7 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 all_resp.append(tmp_resp) if all_resp.count(1) > 0: - resp = 1 + resp.empty_result = 1 elif len(kwargs["other"]) == 1: resp = self.stub.Boolean( request=BooleanRequest( From 2e8b1ac4e5411c7de60f1b8226f7eab5da99fe90 Mon Sep 17 00:00:00 2001 From: smereu Date: Thu, 25 Sep 2025 12:03:46 -0500 Subject: [PATCH 18/33] clean-up after conflict clean-up after conflict --- src/ansys/geometry/core/_grpc/_services/base/bodies.py | 10 +++++----- src/ansys/geometry/core/_grpc/_services/v1/bodies.py | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ansys/geometry/core/_grpc/_services/base/bodies.py b/src/ansys/geometry/core/_grpc/_services/base/bodies.py index 071b88eac9..c81bf23874 100644 --- a/src/ansys/geometry/core/_grpc/_services/base/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/base/bodies.py @@ -219,12 +219,12 @@ def boolean(self, **kwargs) -> dict: """Boolean operation.""" pass - @abstractmethod - def create_body_from_loft_profiles_with_guides(self, **kwargs) -> dict: - """Create a body from loft profiles with guides.""" - pass - @abstractmethod def combine(self, **kwargs) -> dict: """Boolean operation through command.""" pass + + @abstractmethod + def create_body_from_loft_profiles_with_guides(self, **kwargs) -> dict: + """Create a body from loft profiles with guides.""" + pass \ No newline at end of file diff --git a/src/ansys/geometry/core/_grpc/_services/v1/bodies.py b/src/ansys/geometry/core/_grpc/_services/v1/bodies.py index f116d13d43..f3966a2a75 100644 --- a/src/ansys/geometry/core/_grpc/_services/v1/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/v1/bodies.py @@ -193,9 +193,9 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 raise NotImplementedError @protect_grpc - def create_body_from_loft_profiles_with_guides(self, **kwargs) -> dict: # noqa: D102 + def combine(self, **kwargs) -> dict: # noqa: D102 raise NotImplementedError @protect_grpc - def combine(self, **kwargs) -> dict: # noqa: D102 - raise NotImplementedError + def create_body_from_loft_profiles_with_guides(self, **kwargs) -> dict: # noqa: D102 + raise NotImplementedError \ No newline at end of file From dcb5cfc94143780e56815500225839cae2245cf2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 25 Sep 2025 17:04:04 +0000 Subject: [PATCH 19/33] chore: auto fixes from pre-commit hooks --- src/ansys/geometry/core/_grpc/_services/base/bodies.py | 2 +- src/ansys/geometry/core/_grpc/_services/v1/bodies.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ansys/geometry/core/_grpc/_services/base/bodies.py b/src/ansys/geometry/core/_grpc/_services/base/bodies.py index c81bf23874..74c5659f0a 100644 --- a/src/ansys/geometry/core/_grpc/_services/base/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/base/bodies.py @@ -227,4 +227,4 @@ def combine(self, **kwargs) -> dict: @abstractmethod def create_body_from_loft_profiles_with_guides(self, **kwargs) -> dict: """Create a body from loft profiles with guides.""" - pass \ No newline at end of file + pass diff --git a/src/ansys/geometry/core/_grpc/_services/v1/bodies.py b/src/ansys/geometry/core/_grpc/_services/v1/bodies.py index f3966a2a75..c5bc7e26e7 100644 --- a/src/ansys/geometry/core/_grpc/_services/v1/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/v1/bodies.py @@ -198,4 +198,4 @@ def combine(self, **kwargs) -> dict: # noqa: D102 @protect_grpc def create_body_from_loft_profiles_with_guides(self, **kwargs) -> dict: # noqa: D102 - raise NotImplementedError \ No newline at end of file + raise NotImplementedError From db3f2788e81a9386f7d3c4c4bd579d225a766cea Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 25 Sep 2025 17:41:36 +0000 Subject: [PATCH 20/33] chore: auto fixes from pre-commit hooks --- src/ansys/geometry/core/_grpc/_services/base/bodies.py | 2 +- src/ansys/geometry/core/_grpc/_services/v1/bodies.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ansys/geometry/core/_grpc/_services/base/bodies.py b/src/ansys/geometry/core/_grpc/_services/base/bodies.py index 5ca6e35762..d0a4dda485 100644 --- a/src/ansys/geometry/core/_grpc/_services/base/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/base/bodies.py @@ -222,7 +222,7 @@ def boolean(self, **kwargs) -> dict: @abstractmethod def combine(self, **kwargs) -> dict: """Boolean operation through command.""" - + def split_body(self, **kwargs) -> dict: """Split a body.""" pass diff --git a/src/ansys/geometry/core/_grpc/_services/v1/bodies.py b/src/ansys/geometry/core/_grpc/_services/v1/bodies.py index d9a234ae16..c06afe63b3 100644 --- a/src/ansys/geometry/core/_grpc/_services/v1/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/v1/bodies.py @@ -195,8 +195,8 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 @protect_grpc def combine(self, **kwargs) -> dict: # noqa: D102 raise NotImplementedError - - @protect_grpc + + @protect_grpc def split_body(self, **kwargs) -> dict: # noqa: D102 raise NotImplementedError From 61fec18ddf830ee55c63c923687b7d9896250470 Mon Sep 17 00:00:00 2001 From: smereu Date: Mon, 29 Sep 2025 08:53:47 -0500 Subject: [PATCH 21/33] fix undefined variable --- src/ansys/geometry/core/designer/component.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ansys/geometry/core/designer/component.py b/src/ansys/geometry/core/designer/component.py index 0c185c1f32..8ac96254e0 100644 --- a/src/ansys/geometry/core/designer/component.py +++ b/src/ansys/geometry/core/designer/component.py @@ -210,6 +210,7 @@ def __init__( self._name = name self._id = preexisting_id self._instance_name = instance_name + new_component = None else: if parent_component: template_id = template.id if template else "" From 1b6ea87fa332f159305173f9e8d1c62c61df0301 Mon Sep 17 00:00:00 2001 From: smereu Date: Mon, 29 Sep 2025 10:44:58 -0500 Subject: [PATCH 22/33] Update component.py Adjust to name change after merging PR --- src/ansys/geometry/core/designer/component.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ansys/geometry/core/designer/component.py b/src/ansys/geometry/core/designer/component.py index 8ac96254e0..00e05c177f 100644 --- a/src/ansys/geometry/core/designer/component.py +++ b/src/ansys/geometry/core/designer/component.py @@ -205,12 +205,12 @@ def __init__( # Align instance name behavior with the server - empty string if None instance_name = instance_name if instance_name else "" + response = None if preexisting_id: self._name = name self._id = preexisting_id self._instance_name = instance_name - new_component = None else: if parent_component: template_id = template.id if template else "" @@ -226,7 +226,6 @@ def __init__( self._name = response.get("name") self._instance_name = response.get("instance_name") else: - new_component = None self._name = name self._id = None self._instance_name = instance_name @@ -260,10 +259,10 @@ def __init__( elif not read_existing_comp: # This is an independent Component - Create new Part and MasterComponent p = Part( - uuid.uuid4() if not new_component else new_component.template, f"p_{name}", [], [] + uuid.uuid4() if not response else response.template, f"p_{name}", [], [] ) master = MasterComponent( - uuid.uuid4() if not new_component else new_component.component.master_id, + uuid.uuid4() if not response else response.component.master_id, f"master_{name}", p, ) From 3594fc4921248f46228f275a2574bac3906bf460 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Sep 2025 15:45:28 +0000 Subject: [PATCH 23/33] chore: auto fixes from pre-commit hooks --- src/ansys/geometry/core/designer/component.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/ansys/geometry/core/designer/component.py b/src/ansys/geometry/core/designer/component.py index 00e05c177f..55d295e0c3 100644 --- a/src/ansys/geometry/core/designer/component.py +++ b/src/ansys/geometry/core/designer/component.py @@ -258,9 +258,7 @@ def __init__( elif not read_existing_comp: # This is an independent Component - Create new Part and MasterComponent - p = Part( - uuid.uuid4() if not response else response.template, f"p_{name}", [], [] - ) + p = Part(uuid.uuid4() if not response else response.template, f"p_{name}", [], []) master = MasterComponent( uuid.uuid4() if not response else response.component.master_id, f"master_{name}", From 62d90b3d9d170107e13f440ce0d0cff907fcf730 Mon Sep 17 00:00:00 2001 From: smereu Date: Mon, 29 Sep 2025 14:26:04 -0500 Subject: [PATCH 24/33] proper fix to account for name changes in the file --- .../geometry/core/_grpc/_services/v0/components.py | 2 ++ src/ansys/geometry/core/designer/component.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ansys/geometry/core/_grpc/_services/v0/components.py b/src/ansys/geometry/core/_grpc/_services/v0/components.py index 9428ececd1..435af316d9 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/components.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/components.py @@ -74,6 +74,8 @@ def create(self, **kwargs) -> dict: # noqa: D102 "id": response.component.id, "name": response.component.name, "instance_name": response.component.instance_name, + "template" : response.template, + "component" : response.component } @protect_grpc diff --git a/src/ansys/geometry/core/designer/component.py b/src/ansys/geometry/core/designer/component.py index 00e05c177f..8bbcd722df 100644 --- a/src/ansys/geometry/core/designer/component.py +++ b/src/ansys/geometry/core/designer/component.py @@ -211,6 +211,8 @@ def __init__( self._name = name self._id = preexisting_id self._instance_name = instance_name + self._template = None + self._component = None else: if parent_component: template_id = template.id if template else "" @@ -225,10 +227,14 @@ def __init__( self._id = response.get("id") self._name = response.get("name") self._instance_name = response.get("instance_name") + self._template = response.get("template") + self._component = response.get("component") else: self._name = name self._id = None self._instance_name = instance_name + self._template = None + self._component = None # Initialize needed instance variables self._components = [] @@ -259,10 +265,10 @@ def __init__( elif not read_existing_comp: # This is an independent Component - Create new Part and MasterComponent p = Part( - uuid.uuid4() if not response else response.template, f"p_{name}", [], [] + uuid.uuid4() if not self._template else self._template, f"p_{name}", [], [] ) master = MasterComponent( - uuid.uuid4() if not response else response.component.master_id, + uuid.uuid4() if not self._template else self._component.master_id, f"master_{name}", p, ) From bab5a2140f080cb149d3f9da458d7e916d0825fa Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Sep 2025 19:27:51 +0000 Subject: [PATCH 25/33] chore: auto fixes from pre-commit hooks --- src/ansys/geometry/core/_grpc/_services/v0/components.py | 4 ++-- src/ansys/geometry/core/designer/component.py | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/ansys/geometry/core/_grpc/_services/v0/components.py b/src/ansys/geometry/core/_grpc/_services/v0/components.py index 435af316d9..7d2f167ffa 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/components.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/components.py @@ -74,8 +74,8 @@ def create(self, **kwargs) -> dict: # noqa: D102 "id": response.component.id, "name": response.component.name, "instance_name": response.component.instance_name, - "template" : response.template, - "component" : response.component + "template": response.template, + "component": response.component, } @protect_grpc diff --git a/src/ansys/geometry/core/designer/component.py b/src/ansys/geometry/core/designer/component.py index 8bbcd722df..46f4e734e0 100644 --- a/src/ansys/geometry/core/designer/component.py +++ b/src/ansys/geometry/core/designer/component.py @@ -264,9 +264,7 @@ def __init__( elif not read_existing_comp: # This is an independent Component - Create new Part and MasterComponent - p = Part( - uuid.uuid4() if not self._template else self._template, f"p_{name}", [], [] - ) + p = Part(uuid.uuid4() if not self._template else self._template, f"p_{name}", [], []) master = MasterComponent( uuid.uuid4() if not self._template else self._component.master_id, f"master_{name}", From b1744d35bffee1ee7971abb63571cd4574c7d383 Mon Sep 17 00:00:00 2001 From: smereu Date: Mon, 29 Sep 2025 16:19:02 -0500 Subject: [PATCH 26/33] commit to test older version failure --- src/ansys/geometry/core/_grpc/_services/v0/bodies.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py index 89cded1816..3db4d81ece 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py @@ -727,6 +727,7 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 if pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: request.keep_other = kwargs["keep_other"] resp = self.stub.Boolean(request=request) + print ("response normal path", resp) if pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: serialized_tracker_response = serialize_tracker_command_response( response=resp.response @@ -750,6 +751,7 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 if all_resp.count(1) > 0: resp.empty_result = 1 + print ("response with except and other > 1", resp) elif len(kwargs["other"]) == 1: resp = self.stub.Boolean( request=BooleanRequest( @@ -758,9 +760,11 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 method=kwargs["method"], ) ) + print ("response with except and other == 1", resp) else: raise err + print ("final response", resp) if resp.empty_result == 1: raise ValueError( f"Boolean operation of type '{kwargs['method']}' failed: {kwargs['err_msg']}.\n" From b02519e6b746aab69a64e8109ac96481970d46a6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Sep 2025 21:19:24 +0000 Subject: [PATCH 27/33] chore: auto fixes from pre-commit hooks --- src/ansys/geometry/core/_grpc/_services/v0/bodies.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py index 3db4d81ece..a3ce43a064 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py @@ -727,7 +727,7 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 if pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: request.keep_other = kwargs["keep_other"] resp = self.stub.Boolean(request=request) - print ("response normal path", resp) + print("response normal path", resp) if pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: serialized_tracker_response = serialize_tracker_command_response( response=resp.response @@ -751,7 +751,7 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 if all_resp.count(1) > 0: resp.empty_result = 1 - print ("response with except and other > 1", resp) + print("response with except and other > 1", resp) elif len(kwargs["other"]) == 1: resp = self.stub.Boolean( request=BooleanRequest( @@ -760,11 +760,11 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 method=kwargs["method"], ) ) - print ("response with except and other == 1", resp) + print("response with except and other == 1", resp) else: raise err - print ("final response", resp) + print("final response", resp) if resp.empty_result == 1: raise ValueError( f"Boolean operation of type '{kwargs['method']}' failed: {kwargs['err_msg']}.\n" From bea1a3ea4d03a7ae94591bb80e4adbb632e9852b Mon Sep 17 00:00:00 2001 From: smereu Date: Mon, 29 Sep 2025 21:00:00 -0500 Subject: [PATCH 28/33] consistent use of response success --- src/ansys/geometry/core/_grpc/_services/v0/bodies.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py index 3db4d81ece..61d45a91b8 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py @@ -716,7 +716,7 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 from ansys.api.geometry.v0.bodies_pb2 import BooleanRequest # Call the gRPC service and build the requests accordingly - resp = 0 + response_success = 0 serialized_tracker_response = {} try: request = BooleanRequest( @@ -727,7 +727,7 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 if pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: request.keep_other = kwargs["keep_other"] resp = self.stub.Boolean(request=request) - print ("response normal path", resp) + response_success = resp.empty_result if pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: serialized_tracker_response = serialize_tracker_command_response( response=resp.response @@ -750,8 +750,7 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 all_resp.append(tmp_resp) if all_resp.count(1) > 0: - resp.empty_result = 1 - print ("response with except and other > 1", resp) + response_success = 1 elif len(kwargs["other"]) == 1: resp = self.stub.Boolean( request=BooleanRequest( @@ -760,12 +759,11 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 method=kwargs["method"], ) ) - print ("response with except and other == 1", resp) + response_success = resp.empty_result else: raise err - print ("final response", resp) - if resp.empty_result == 1: + if response_success == 1: raise ValueError( f"Boolean operation of type '{kwargs['method']}' failed: {kwargs['err_msg']}.\n" f"Involving bodies:{kwargs['target']}, {kwargs['other']}" From c38ad199b49cf5d20322f74883aed68d48e465a9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 30 Sep 2025 02:02:53 +0000 Subject: [PATCH 29/33] chore: auto fixes from pre-commit hooks --- src/ansys/geometry/core/_grpc/_services/v0/bodies.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py index 61d45a91b8..fba4d3b297 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/bodies.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/bodies.py @@ -750,7 +750,7 @@ def boolean(self, **kwargs) -> dict: # noqa: D102 all_resp.append(tmp_resp) if all_resp.count(1) > 0: - response_success = 1 + response_success = 1 elif len(kwargs["other"]) == 1: resp = self.stub.Boolean( request=BooleanRequest( From 9a355673ebad3a55b3e87c8484177ca5095ea1e6 Mon Sep 17 00:00:00 2001 From: smereu Date: Tue, 30 Sep 2025 11:07:12 -0500 Subject: [PATCH 30/33] fixes after merge conflict --- .../core/_grpc/_services/v0/repair_tools.py | 251 ++++++------------ 1 file changed, 83 insertions(+), 168 deletions(-) diff --git a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py index cbe4ca93e8..87b971320f 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py @@ -332,99 +332,6 @@ def find_simplify(self, **kwargs) -> dict: # noqa: D102 ] } - @protect_grpc - def find_and_fix_simplify(self, **kwargs) -> dict: # noqa: D102 - from ansys.api.geometry.v0.repairtools_pb2 import FindAdjustSimplifyRequest - - # Create the request - assumes all inputs are valid and of the proper type - request = FindAdjustSimplifyRequest( - selection=kwargs["selection"], - comprehensive=kwargs["comprehensive_result"], - ) - - # Call the gRPC service - response = self.stub.FindAndSimplify(request) - - serialized_tracker_response = serialize_tracker_command_response( - response=response.complete_command_response - ) - - # Return the response - formatted as a dictionary - return { - "success": response.success, - "found": response.found, - "repaired": response.repaired, - "created_bodies_monikers": [], - "modified_bodies_monikers": [], - "complete_command_response": serialized_tracker_response, - } - - @protect_grpc - def find_and_fix_stitch_faces(self, **kwargs) -> dict: # noqa: D102 - from ansys.api.geometry.v0.repairtools_pb2 import FindStitchFacesRequest - from google.protobuf.wrappers_pb2 import BoolValue, DoubleValue - - from ..base.conversions import from_measurement_to_server_length - - # Create the request - assumes all inputs are valid and of the proper type - request = FindStitchFacesRequest( - faces=kwargs["body_ids"], - maximum_distance=DoubleValue( - value=from_measurement_to_server_length(kwargs["max_distance"]) - ) - if kwargs["max_distance"] is not None - else None, - allow_multiple_bodies=BoolValue(value=kwargs["allow_multiple_bodies"]), - maintain_components=BoolValue(value=kwargs["maintain_components"]), - check_for_coincidence=BoolValue(value=kwargs["check_for_coincidence"]), - comprehensive=kwargs["comprehensive_result"], - ) - - # Call the gRPC service - response = self.stub.FindAndFixStitchFaces(request) - - serialized_tracker_response = serialize_tracker_command_response( - response=response.complete_command_response - ) - - # Return the response - formatted as a dictionary - return { - "success": response.success, - "created_bodies_monikers": response.created_bodies_monikers, - "modified_bodies_monikers": response.modified_bodies_monikers, - "found": response.found, - "repaired": response.repaired, - "complete_command_response": serialized_tracker_response, - } - - @protect_grpc - def inspect_geometry(self, **kwargs) -> dict: # noqa: D102 - from ansys.api.geometry.v0.repairtools_pb2 import InspectGeometryRequest - - # Create the request - assumes all inputs are valid and of the proper type - request = InspectGeometryRequest(bodies=kwargs.get("bodies", [])) - - # Call the gRPC service - inspect_result_response = self.stub.InspectGeometry(request) - - # Serialize and return the response - return self.__serialize_inspect_result_response(inspect_result_response) - - @protect_grpc - def repair_geometry(self, **kwargs) -> dict: # noqa: D102 - from ansys.api.geometry.v0.repairtools_pb2 import RepairGeometryRequest - - # Create the request - assumes all inputs are valid and of the proper type - request = RepairGeometryRequest(bodies=kwargs.get("bodies", [])) - - # Call the gRPC service - response = self.stub.RepairGeometry(request) - - # Return the response - formatted as a dictionary - return { - "success": response.result.success, - } - @protect_grpc def find_interferences(self, **kwargs) -> dict: # noqa: D102 from ansys.api.geometry.v0.repairtools_pb2 import FindInterferenceRequest @@ -537,21 +444,6 @@ def find_and_fix_split_edges(self, **kwargs) -> dict: # noqa: D102 } @protect_grpc - def fix_duplicate_faces(self, **kwargs) -> dict: # noqa: D102 - from ansys.api.geometry.v0.repairtools_pb2 import FixDuplicateFacesRequest - - # Create the request - assumes all inputs are valid and of the proper type - request = FixDuplicateFacesRequest( - duplicate_face_problem_area_id=kwargs["duplicate_face_problem_area_id"], - ) - - # Call the gRPC service - response = self.stub.FixDuplicateFaces(request) - - serialized_tracker_response = serialize_tracker_command_response( - response=response.result.complete_command_response) - - @protect_grpc def find_and_fix_simplify(self, **kwargs) -> dict: # noqa: D102 from ansys.api.geometry.v0.repairtools_pb2 import FindAdjustSimplifyRequest @@ -564,38 +456,20 @@ def find_and_fix_simplify(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FindAndSimplify(request) - serialized_tracker_response = serialize_tracker_command_response( - response.complete_command_response + serialized_tracker_response = serialize_tracker_command_response( + response=response.complete_command_response ) # Return the response - formatted as a dictionary return { - "tracker_response": serialized_tracker_response, - "repair_tracker_response": self.__serialize_message_response(response), - } - - @protect_grpc - def fix_missing_faces(self, **kwargs) -> dict: # noqa: D102 - from ansys.api.geometry.v0.repairtools_pb2 import FixMissingFacesRequest - - # Create the request - assumes all inputs are valid and of the proper type - request = FixMissingFacesRequest( - missing_face_problem_area_id=kwargs["missing_face_problem_area_id"], - ) - - # Call the gRPC service - response = self.stub.FixMissingFaces(request) - - serialized_tracker_response = serialize_tracker_command_response( - response=response.result.complete_command_response "success": response.success, "found": response.found, "repaired": response.repaired, "created_bodies_monikers": [], "modified_bodies_monikers": [], "complete_command_response": serialized_tracker_response, - ) - + } + @protect_grpc def find_and_fix_stitch_faces(self, **kwargs) -> dict: # noqa: D102 from ansys.api.geometry.v0.repairtools_pb2 import FindStitchFacesRequest @@ -620,8 +494,83 @@ def find_and_fix_stitch_faces(self, **kwargs) -> dict: # noqa: D102 # Call the gRPC service response = self.stub.FindAndFixStitchFaces(request) - serialized_tracker_response = self._serialize_tracker_command_response( - response.complete_command_response + serialized_tracker_response = serialize_tracker_command_response( + response=response.complete_command_response + ) + + # Return the response - formatted as a dictionary + return { + "success": response.success, + "created_bodies_monikers": response.created_bodies_monikers, + "modified_bodies_monikers": response.modified_bodies_monikers, + "found": response.found, + "repaired": response.repaired, + "complete_command_response": serialized_tracker_response, + } + + @protect_grpc + def inspect_geometry(self, **kwargs) -> dict: # noqa: D102 + from ansys.api.geometry.v0.repairtools_pb2 import InspectGeometryRequest + + # Create the request - assumes all inputs are valid and of the proper type + request = InspectGeometryRequest(bodies=kwargs.get("bodies", [])) + + # Call the gRPC service + inspect_result_response = self.stub.InspectGeometry(request) + + # Serialize and return the response + return self.__serialize_inspect_result_response(inspect_result_response) + + @protect_grpc + def repair_geometry(self, **kwargs) -> dict: # noqa: D102 + from ansys.api.geometry.v0.repairtools_pb2 import RepairGeometryRequest + + # Create the request - assumes all inputs are valid and of the proper type + request = RepairGeometryRequest(bodies=kwargs.get("bodies", [])) + + # Call the gRPC service + response = self.stub.RepairGeometry(request) + + # Return the response - formatted as a dictionary + return { + "success": response.result.success, + } + + @protect_grpc + def fix_duplicate_faces(self, **kwargs) -> dict: # noqa: D102 + from ansys.api.geometry.v0.repairtools_pb2 import FixDuplicateFacesRequest + + # Create the request - assumes all inputs are valid and of the proper type + request = FixDuplicateFacesRequest( + duplicate_face_problem_area_id=kwargs["duplicate_face_problem_area_id"], + ) + + # Call the gRPC service + response = self.stub.FixDuplicateFaces(request) + + serialized_tracker_response = serialize_tracker_command_response( + response=response.result.complete_command_response) + + # Return the response - formatted as a dictionary + return { + "tracker_response": serialized_tracker_response, + "repair_tracker_response": self.__serialize_message_response(response), + } + + @protect_grpc + def fix_missing_faces(self, **kwargs) -> dict: # noqa: D102 + from ansys.api.geometry.v0.repairtools_pb2 import FixMissingFacesRequest + + # Create the request - assumes all inputs are valid and of the proper type + request = FixMissingFacesRequest( + missing_face_problem_area_id=kwargs["missing_face_problem_area_id"], + ) + + # Call the gRPC service + response = self.stub.FixMissingFaces(request) + + serialized_tracker_response = serialize_tracker_command_response( + response=response.result.complete_command_response ) # Return the response - formatted as a dictionary @@ -804,42 +753,8 @@ def fix_interference(self, **kwargs) -> dict: # noqa: D102 return { "tracker_response": serialized_tracker_response, "repair_tracker_response": self.__serialize_message_response(response), - "success": response.success, - "created_bodies_monikers": response.created_bodies_monikers, - "modified_bodies_monikers": response.modified_bodies_monikers, - "found": response.found, - "repaired": response.repaired, - "complete_command_response": serialized_tracker_response, } - - @protect_grpc - def inspect_geometry(self, **kwargs) -> dict: # noqa: D102 - from ansys.api.geometry.v0.repairtools_pb2 import InspectGeometryRequest - - # Create the request - assumes all inputs are valid and of the proper type - request = InspectGeometryRequest(bodies=[build_grpc_id(b) for b in kwargs["body_ids"]]) - - # Call the gRPC service - response = self.stub.InspectGeometry(request) - - # Serialize and return the response - return self.__serialize_inspect_result_response(response) - - @protect_grpc - def repair_geometry(self, **kwargs) -> dict: # noqa: D102 - from ansys.api.geometry.v0.repairtools_pb2 import RepairGeometryRequest - - # Create the request - assumes all inputs are valid and of the proper type - request = RepairGeometryRequest(bodies=[build_grpc_id(b) for b in kwargs["body_ids"]]) - - # Call the gRPC service - response = self.stub.RepairGeometry(request) - - # Return the response - formatted as a dictionary - return { - "success": response.result.success, - } - + def __serialize_inspect_result_response(self, response) -> dict: # noqa: D102 def serialize_body(body): return { @@ -892,7 +807,7 @@ def serialize_issue(issue): } for body_issues in response.issues_by_body ] - } + } def __serialize_message_response(self, response): return { From 251dca06c7122bde761009958fd286b2826bffa0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 30 Sep 2025 16:09:41 +0000 Subject: [PATCH 31/33] chore: auto fixes from pre-commit hooks --- .../core/_grpc/_services/v0/repair_tools.py | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py index 87b971320f..ab574432fe 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py @@ -34,7 +34,7 @@ from .conversions import ( serialize_tracker_command_response, ) -from .conversions import build_grpc_id + class GRPCRepairToolsServiceV0(GRPCRepairToolsService): # noqa: D102 """Repair tools service for gRPC communication with the Geometry server. @@ -469,7 +469,7 @@ def find_and_fix_simplify(self, **kwargs) -> dict: # noqa: D102 "modified_bodies_monikers": [], "complete_command_response": serialized_tracker_response, } - + @protect_grpc def find_and_fix_stitch_faces(self, **kwargs) -> dict: # noqa: D102 from ansys.api.geometry.v0.repairtools_pb2 import FindStitchFacesRequest @@ -506,8 +506,8 @@ def find_and_fix_stitch_faces(self, **kwargs) -> dict: # noqa: D102 "found": response.found, "repaired": response.repaired, "complete_command_response": serialized_tracker_response, - } - + } + @protect_grpc def inspect_geometry(self, **kwargs) -> dict: # noqa: D102 from ansys.api.geometry.v0.repairtools_pb2 import InspectGeometryRequest @@ -549,14 +549,15 @@ def fix_duplicate_faces(self, **kwargs) -> dict: # noqa: D102 response = self.stub.FixDuplicateFaces(request) serialized_tracker_response = serialize_tracker_command_response( - response=response.result.complete_command_response) - + response=response.result.complete_command_response + ) + # Return the response - formatted as a dictionary return { "tracker_response": serialized_tracker_response, "repair_tracker_response": self.__serialize_message_response(response), - } - + } + @protect_grpc def fix_missing_faces(self, **kwargs) -> dict: # noqa: D102 from ansys.api.geometry.v0.repairtools_pb2 import FixMissingFacesRequest @@ -754,7 +755,7 @@ def fix_interference(self, **kwargs) -> dict: # noqa: D102 "tracker_response": serialized_tracker_response, "repair_tracker_response": self.__serialize_message_response(response), } - + def __serialize_inspect_result_response(self, response) -> dict: # noqa: D102 def serialize_body(body): return { @@ -807,7 +808,7 @@ def serialize_issue(issue): } for body_issues in response.issues_by_body ] - } + } def __serialize_message_response(self, response): return { From b84e23c113641e2088b2b7dd13b98159d375f9ca Mon Sep 17 00:00:00 2001 From: smereu Date: Wed, 1 Oct 2025 14:39:04 -0500 Subject: [PATCH 32/33] Remove last direct usage of stubs in problem_areat.py --- src/ansys/geometry/core/tools/problem_areas.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ansys/geometry/core/tools/problem_areas.py b/src/ansys/geometry/core/tools/problem_areas.py index 609fa874a2..3cee557c35 100644 --- a/src/ansys/geometry/core/tools/problem_areas.py +++ b/src/ansys/geometry/core/tools/problem_areas.py @@ -622,9 +622,8 @@ def fix(self) -> RepairToolMessage: return RepairToolMessage(False, [], []) parent_design = get_design_from_body(self.bodies[0]) - response = self._repair_stub.FixInterference( - FixInterferenceRequest(interference_problem_area_id=self._grpc_id) - ) + response = self._grpc_client.services.repair_tools.fix_interference( + interference_problem_area_id=self._grpc_id) if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace() @@ -633,7 +632,7 @@ def fix(self) -> RepairToolMessage: ## The tool does not return the created or modified objects. ## https://github.com/ansys/pyansys-geometry/issues/1319 - message = RepairToolMessage(response.result.success, [], []) + message = RepairToolMessage(response.get("repair_tracker_response").get("success"), [], []) return message From 687fabe992eb7968ccc3608d3f1f574275baf2d6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 1 Oct 2025 19:40:06 +0000 Subject: [PATCH 33/33] chore: auto fixes from pre-commit hooks --- src/ansys/geometry/core/tools/problem_areas.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ansys/geometry/core/tools/problem_areas.py b/src/ansys/geometry/core/tools/problem_areas.py index 3cee557c35..5223edfd0a 100644 --- a/src/ansys/geometry/core/tools/problem_areas.py +++ b/src/ansys/geometry/core/tools/problem_areas.py @@ -24,9 +24,6 @@ from abc import abstractmethod from typing import TYPE_CHECKING -from ansys.api.geometry.v0.repairtools_pb2 import ( - FixInterferenceRequest, -) from ansys.api.geometry.v0.repairtools_pb2_grpc import RepairToolsStub from google.protobuf.wrappers_pb2 import Int32Value @@ -623,7 +620,8 @@ def fix(self) -> RepairToolMessage: parent_design = get_design_from_body(self.bodies[0]) response = self._grpc_client.services.repair_tools.fix_interference( - interference_problem_area_id=self._grpc_id) + interference_problem_area_id=self._grpc_id + ) if not pyansys_geom.USE_TRACKER_TO_UPDATE_DESIGN: parent_design._update_design_inplace()