diff --git a/doc/changelog.d/1922.added.md b/doc/changelog.d/1922.added.md new file mode 100644 index 0000000000..c44279596d --- /dev/null +++ b/doc/changelog.d/1922.added.md @@ -0,0 +1 @@ +Update with delta \ No newline at end of file diff --git a/src/ansys/geometry/core/__init__.py b/src/ansys/geometry/core/__init__.py index 4b388a543f..1b1608da6f 100644 --- a/src/ansys/geometry/core/__init__.py +++ b/src/ansys/geometry/core/__init__.py @@ -70,3 +70,6 @@ DOCUMENTATION_BUILD: bool = os.environ.get("PYANSYS_GEOMETRY_DOC_BUILD", "false").lower() == "true" """Global flag for the documentation to use the proper PyVista Jupyter backend.""" + +USE_TRACKER_TO_UPDATE_DESIGN: bool = False +"""Global constant for checking whether to use the tracker to update designs.""" 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 5b7000e990..0d940c9944 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py @@ -251,6 +251,11 @@ 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( + response.complete_command_response + ) + # Return the response - formatted as a dictionary return { "success": response.success, @@ -258,6 +263,7 @@ def find_and_fix_simplify(self, **kwargs) -> dict: # noqa: D102 "repaired": response.repaired, "created_bodies_monikers": [], "modified_bodies_monikers": [], + "complete_command_response": serialized_tracker_response, } @protect_grpc @@ -271,7 +277,7 @@ def inspect_geometry(self, **kwargs) -> dict: # noqa: D102 inspect_result_response = self.stub.InspectGeometry(request) # Serialize and return the response - return self.serialize_inspect_result_response(inspect_result_response) + return self._serialize_inspect_result_response(inspect_result_response) @protect_grpc def repair_geometry(self, **kwargs) -> dict: # noqa: D102 @@ -326,6 +332,10 @@ 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( + response.complete_command_response + ) + # Return the response - formatted as a dictionary return { "success": response.success, @@ -333,6 +343,7 @@ def find_and_fix_short_edges(self, **kwargs): # noqa: D102 "repaired": response.repaired, "created_bodies_monikers": [], "modified_bodies_monikers": [], + "complete_command_response": serialized_tracker_response, } @protect_grpc @@ -346,6 +357,10 @@ 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( + response.complete_command_response + ) + # Return the response - formatted as a dictionary return { "success": response.success, @@ -353,6 +368,7 @@ def find_and_fix_extra_edges(self, **kwargs) -> dict: # noqa: D102 "repaired": response.repaired, "created_bodies_monikers": response.created_bodies_monikers, "modified_bodies_monikers": response.modified_bodies_monikers, + "complete_command_response": serialized_tracker_response, } @protect_grpc @@ -371,6 +387,10 @@ 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( + response.complete_command_response + ) + # Return the response - formatted as a dictionary return { "success": response.success, @@ -378,10 +398,10 @@ def find_and_fix_split_edges(self, **kwargs) -> dict: # noqa: D102 "repaired": response.repaired, "created_bodies_monikers": [], "modified_bodies_monikers": [], + "complete_command_response": serialized_tracker_response, } - @staticmethod - def serialize_inspect_result_response(response) -> dict: # noqa: D102 + def _serialize_inspect_result_response(self, response) -> dict: # noqa: D102 def serialize_body(body): return { "id": body.id, @@ -434,3 +454,53 @@ 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, + } + + def serialize_entity_identifier(entity): + """Serialize an EntityIdentifier object into a dictionary.""" + return { + "id": entity.id, + "type": entity.type, + } + + 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/designer/body.py b/src/ansys/geometry/core/designer/body.py index 0550c95653..b4872da493 100644 --- a/src/ansys/geometry/core/designer/body.py +++ b/src/ansys/geometry/core/designer/body.py @@ -1849,7 +1849,16 @@ def __generic_boolean_command( for b in other_bodies: b.parent_component.delete_body(b) - parent_design._update_design_inplace() + from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN + + if not 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 = self._serialize_tracker_command_response(tracker_response) + parent_design._update_from_tracker(serialized_response) @reset_tessellation_cache @ensure_design_is_active diff --git a/src/ansys/geometry/core/designer/design.py b/src/ansys/geometry/core/designer/design.py index 9b5ef22186..d9f8e04545 100644 --- a/src/ansys/geometry/core/designer/design.py +++ b/src/ansys/geometry/core/designer/design.py @@ -1220,3 +1220,185 @@ def _update_design_inplace(self) -> None: # Read the existing design self.__read_existing_design() + + def _update_from_tracker(self, tracker_response): + """ + Update the design with the changed bodies while preserving unchanged ones. + + Parameters + ---------- + tracker_response : list[dict] + A list of dictionaries representing tracker response information. + """ + self._grpc_client.log.debug( + f"Starting _update_from_tracker with response: {tracker_response}" + ) + + # Function to update a body if it exists + def update_body(existing_body, body_info): + self._grpc_client.log.debug( + f"Updating body '{existing_body.name}' (ID: {existing_body.id}) " + f"with new info: {body_info}" + ) + existing_body.name = body_info["name"] + existing_body._template._is_surface = body_info.get("is_surface", False) + + # Function to find and add bodies within components recursively + def find_and_add_body(body_info, component): + self._grpc_client.log.debug( + f"Searching for parent_id {body_info.get('parent_id')} to " + f"add body '{body_info['name']}' (ID: {body_info['id']}) within components list." + ) + for component in component: + if component.id == 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) + self._grpc_client.log.debug( + f"Added new body '{new_body.name}' (ID: {new_body.id}) " + f"to component '{component.name}' (ID: {component.id})." + ) + + return True # Found and added + + # Recursively search in subcomponents + if find_and_add_body(body_info, component.components): + return True + + return False # Not found + + # Function to find and update bodies within components recursively + def find_and_update_body(body_info, component): + self._grpc_client.log.debug( + f"Searching for body ID {body_info['id']} to update within components list." + ) + + if component == []: + return False + for body in component.bodies: + if body.id == body_info["id"]: + update_body(body, body_info) + self._grpc_client.log.debug( + f"Updated body '{body.name}' (ID: {body.id}) found in" + f" component '{component.name}' (ID: {component.id})." + ) + return True # Found and updated + + # Recursively search in subcomponents + if find_and_update_body(body_info, component.components): + return True + + return False # Not found + + # Function to find and remove bodies within components recursively + + def find_and_remove_body(body_info, component): + self._grpc_client.log.debug( + f"Searching for body ID {body_info['id']} to remove within components list." + ) + if component == []: + return False + for body in component.bodies: + if body.id == body_info["id"]: + # Remove the body from the component + body._is_alive = False # Mark as dead + component.bodies.remove(body) + self._grpc_client.log.debug( + f"Removed body '{body_info['name']}' (ID: {body_info['id']}) " + f"from component '{component.name}' (ID: {component.id})." + ) + + return True # Found and removed + + # Recursively search in subcomponents + if find_and_remove_body(body_info, component.components): + return True + + return False # Not found + + # Loop through all changed bodies from the tracker + for body_info in tracker_response["modified_bodies"]: + body_id = body_info["id"] + body_name = body_info["name"] + self._grpc_client.log.debug( + f"Processing modified body: ID={body_id}, Name='{body_name}'" + ) + is_surface = body_info.get( + "is_surface", False + ) # Default to False if "is_surface" is missing + updated = False # Track if a body was updated + + # First, check bodies at the root level + for body in self.bodies: + if body.id == body_id: + update_body(body, body_info) + updated = True + self._grpc_client.log.debug( + f"Modified body '{body_name}' (ID: {body_id}) " + "found and updated at root level." + ) + break + + # If not found in root, search within components + if not updated: + for component in self.components: + updated = find_and_update_body(body_info, component) + + # Loop through all deleted bodies from the tracker + for body_info in tracker_response["deleted_bodies"]: + body_id = body_info["id"] + self._grpc_client.log.debug(f"Processing deleted body: ID={body_id}") + removed = False # Track if a body was removed + + # First, check bodies at the root level + for body in self.bodies: + if body.id == body_id: + body._is_alive = False # Mark as dead + self.bodies.remove(body) + removed = True + self._grpc_client.log.info( + f"Deleted body (ID: {body_id}) removed from root level." + ) + break + + # If not found in root, search within components + if not removed: + removed = find_and_remove_body(body_info, self.components) + + # Loop through all added bodies from the tracker + for body_info in tracker_response["created_bodies"]: + self._grpc_client.log.debug( + f"Processing created body: ID={body_id}, Name='{body_name}'" + ) + body_id = body_info["id"] + body_name = body_info["name"] + is_surface = body_info["is_surface"] + + added = False # Track if a body was added + + # First, check if the body already exists at the root level + for body in self.bodies: + if body.id == body_id: + added = True + self._grpc_client.log.debug( + f"Created body '{body_name}' (ID: {body_id}) " + "already exists at root level (skipped adding)." + ) + break + + # If not found in root, search within components + if not added: + added = find_and_add_body(body_info, self.components) + + # If still not found, add it as a new body at the root level + if not added: + new_body = MasterBody(body_id, body_name, self._grpc_client, is_surface=is_surface) + self.bodies.append(new_body) + self._grpc_client.log.debug( + f"Added new body '{new_body.name}' (ID: {new_body.id}) " + "to root level as no parent was found." + ) diff --git a/src/ansys/geometry/core/tools/prepare_tools.py b/src/ansys/geometry/core/tools/prepare_tools.py index 241d47ad37..ad613442bc 100644 --- a/src/ansys/geometry/core/tools/prepare_tools.py +++ b/src/ansys/geometry/core/tools/prepare_tools.py @@ -266,11 +266,11 @@ def enhanced_share_topology( ) message = RepairToolMessage( - response.get("success"), - response.get("created_bodies_monikers"), - response.get("modified_bodies_monikers"), - response.get("found"), - response.get("repaired"), + success=response.get("success"), + created_bodies=response.get("created_bodies_monikers"), + modified_bodies=response.get("modified_bodies_monikers"), + found=response.get("found"), + repaired=response.get("repaired"), ) return message diff --git a/src/ansys/geometry/core/tools/problem_areas.py b/src/ansys/geometry/core/tools/problem_areas.py index b7ec80f2b0..01b9db36c2 100644 --- a/src/ansys/geometry/core/tools/problem_areas.py +++ b/src/ansys/geometry/core/tools/problem_areas.py @@ -83,6 +83,58 @@ 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, + } + + def serialize_entity_identifier(entity): + """Serialize an EntityIdentifier object into a dictionary.""" + return { + "id": entity.id, + # "type": entity.type, + } + + # 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. @@ -131,11 +183,19 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixDuplicateFaces( FixDuplicateFacesRequest(duplicate_face_problem_area_id=self._grpc_id) ) - parent_design._update_design_inplace() + from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN + + if not USE_TRACKER_TO_UPDATE_DESIGN: + parent_design._update_design_inplace() + else: + tracker_response = response.result.complete_command_response + serialized_response = self._serialize_tracker_command_response(tracker_response) + parent_design._update_from_tracker(serialized_response) + message = RepairToolMessage( - response.result.success, - response.result.created_bodies_monikers, - response.result.modified_bodies_monikers, + success=response.result.success, + created_bodies=response.result.created_bodies_monikers, + modified_bodies=response.result.modified_bodies_monikers, ) return message @@ -186,11 +246,22 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixMissingFaces( FixMissingFacesRequest(missing_face_problem_area_id=self._grpc_id) ) - parent_design._update_design_inplace() + + serialized_response = self._serialize_tracker_command_response( + response.result.complete_command_response + ) + + from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN + + if not USE_TRACKER_TO_UPDATE_DESIGN: + parent_design._update_design_inplace() + else: + parent_design._update_from_tracker(serialized_response) + message = RepairToolMessage( - response.result.success, - response.result.created_bodies_monikers, - response.result.modified_bodies_monikers, + success=response.result.success, + created_bodies=response.result.created_bodies_monikers, + modified_bodies=response.result.modified_bodies_monikers, ) return message @@ -237,15 +308,26 @@ def fix(self) -> RepairToolMessage: return RepairToolMessage(False, [], []) parent_design = get_design_from_edge(self.edges[0]) + response = self._repair_stub.FixInexactEdges( FixInexactEdgesRequest(inexact_edge_problem_area_id=self._grpc_id) ) - parent_design._update_design_inplace() + + from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN + + if not USE_TRACKER_TO_UPDATE_DESIGN: + parent_design._update_design_inplace() + else: + tracker_response = response.result.complete_command_response + serialized_response = self._serialize_tracker_command_response(tracker_response) + parent_design._update_from_tracker(serialized_response) + message = RepairToolMessage( - response.result.success, - response.result.created_bodies_monikers, - response.result.modified_bodies_monikers, + success=response.result.success, + created_bodies=response.result.created_bodies_monikers, + modified_bodies=response.result.modified_bodies_monikers, ) + return message @@ -293,11 +375,19 @@ def fix(self) -> RepairToolMessage: 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) - parent_design._update_design_inplace() + from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN + + if not USE_TRACKER_TO_UPDATE_DESIGN: + parent_design._update_design_inplace() + else: + tracker_response = response.result.complete_command_response + serialized_response = self._serialize_tracker_command_response(tracker_response) + parent_design._update_from_tracker(serialized_response) + message = RepairToolMessage( - response.result.success, - response.result.created_bodies_monikers, - response.result.modified_bodies_monikers, + success=response.result.success, + created_bodies=response.result.created_bodies_monikers, + modified_bodies=response.result.modified_bodies_monikers, ) return message @@ -348,11 +438,19 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixShortEdges( FixShortEdgesRequest(short_edge_problem_area_id=self._grpc_id) ) - parent_design._update_design_inplace() + from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN + + if not USE_TRACKER_TO_UPDATE_DESIGN: + parent_design._update_design_inplace() + else: + tracker_response = response.result.complete_command_response + serialized_response = self._serialize_tracker_command_response(tracker_response) + parent_design._update_from_tracker(serialized_response) + message = RepairToolMessage( - response.result.success, - response.result.created_bodies_monikers, - response.result.modified_bodies_monikers, + success=response.result.success, + created_bodies=response.result.created_bodies_monikers, + modified_bodies=response.result.modified_bodies_monikers, ) return message @@ -403,11 +501,22 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixSmallFaces( FixSmallFacesRequest(small_face_problem_area_id=self._grpc_id) ) - parent_design._update_design_inplace() + + from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN + + if not 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 = self._serialize_tracker_command_response(tracker_response) + parent_design._update_from_tracker(serialized_response) + message = RepairToolMessage( - response.result.success, - response.result.created_bodies_monikers, - response.result.modified_bodies_monikers, + success=response.result.success, + created_bodies=response.result.created_bodies_monikers, + modified_bodies=response.result.modified_bodies_monikers, ) return message @@ -457,12 +566,21 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixSplitEdges( FixSplitEdgesRequest(split_edge_problem_area_id=self._grpc_id) ) - parent_design._update_design_inplace() + from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN + + if not USE_TRACKER_TO_UPDATE_DESIGN: + parent_design._update_design_inplace() + else: + tracker_respone = response.result.complete_command_response + serialized_response = self._serialize_tracker_command_response(tracker_respone) + parent_design._update_from_tracker(serialized_response) + message = RepairToolMessage( - response.result.success, - response.result.created_bodies_monikers, - response.result.modified_bodies_monikers, + success=response.result.success, + created_bodies=response.result.created_bodies_monikers, + modified_bodies=response.result.modified_bodies_monikers, ) + return message @@ -511,11 +629,19 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixStitchFaces( FixStitchFacesRequest(stitch_face_problem_area_id=self._grpc_id) ) - parent_design._update_design_inplace() + from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN + + if not USE_TRACKER_TO_UPDATE_DESIGN: + parent_design._update_design_inplace() + else: + tracker_respone = response.result.complete_command_response + serialized_response = self._serialize_tracker_command_response(tracker_respone) + parent_design._update_from_tracker(serialized_response) + message = RepairToolMessage( - response.result.success, - response.result.created_bodies_monikers, - response.result.modified_bodies_monikers, + success=response.result.success, + created_bodies=response.result.created_bodies_monikers, + modified_bodies=response.result.modified_bodies_monikers, ) return message @@ -560,11 +686,19 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixAdjustSimplify( FixAdjustSimplifyRequest(adjust_simplify_problem_area_id=self._grpc_id) ) - parent_design._update_design_inplace() + from ansys.geometry.core import USE_TRACKER_TO_UPDATE_DESIGN + + if not USE_TRACKER_TO_UPDATE_DESIGN: + parent_design._update_design_inplace() + else: + tracker_respone = response.result.complete_command_response + serialized_response = self._serialize_tracker_command_response(tracker_respone) + parent_design._update_from_tracker(serialized_response) + message = RepairToolMessage( - response.result.success, - response.result.created_bodies_monikers, - response.result.modified_bodies_monikers, + success=response.result.success, + created_bodies=response.result.created_bodies_monikers, + modified_bodies=response.result.modified_bodies_monikers, ) 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 4329c7d7f7..45ef82c33e 100644 --- a/src/ansys/geometry/core/tools/repair_tool_message.py +++ b/src/ansys/geometry/core/tools/repair_tool_message.py @@ -30,6 +30,10 @@ def __init__( success: bool, created_bodies: list[str], modified_bodies: list[str], + deleted_bodies: list[str] = None, + craeted_components: list[str] = None, + modified_components: list[str] = None, + deleted_components: list[str] = None, found: int = -1, repaired: int = -1, ): diff --git a/src/ansys/geometry/core/tools/repair_tools.py b/src/ansys/geometry/core/tools/repair_tools.py index a0d468a70b..750855e7f8 100644 --- a/src/ansys/geometry/core/tools/repair_tools.py +++ b/src/ansys/geometry/core/tools/repair_tools.py @@ -23,6 +23,7 @@ from typing import TYPE_CHECKING +import ansys.geometry.core as pyansys_geometry from ansys.geometry.core.connection import GrpcClient from ansys.geometry.core.errors import protect_grpc from ansys.geometry.core.misc.auxiliary import ( @@ -479,7 +480,12 @@ def find_and_fix_short_edges( ) parent_design = get_design_from_body(bodies[0]) - parent_design._update_design_inplace() + + if not pyansys_geometry.USE_TRACKER_TO_UPDATE_DESIGN: + parent_design._update_design_inplace() + else: + parent_design._update_from_tracker(response["complete_command_response"]) + message = RepairToolMessage( success=response["success"], found=response["found"], @@ -530,13 +536,18 @@ def find_and_fix_extra_edges( ) parent_design = get_design_from_body(bodies[0]) - parent_design._update_design_inplace() + + if not pyansys_geometry.USE_TRACKER_TO_UPDATE_DESIGN: + parent_design._update_design_inplace() + else: + parent_design._update_from_tracker(response["complete_command_response"]) + message = RepairToolMessage( - response["success"], - response["created_bodies_monikers"], - response["modified_bodies_monikers"], - response["found"], - response["repaired"], + success=response["success"], + created_bodies=response["created_bodies_monikers"], + modified_bodies=response["modified_bodies_monikers"], + found=response["found"], + repaired=response["repaired"], ) return message @@ -592,14 +603,20 @@ def find_and_fix_split_edges( ) parent_design = get_design_from_body(bodies[0]) - parent_design._update_design_inplace() + + if not pyansys_geometry.USE_TRACKER_TO_UPDATE_DESIGN: + parent_design._update_design_inplace() + else: + parent_design._update_from_tracker(response["complete_command_response"]) + message = RepairToolMessage( - response["success"], - response["created_bodies_monikers"], - response["modified_bodies_monikers"], - response["found"], - response["repaired"], + success=response["success"], + created_bodies=response["created_bodies_monikers"], + modified_bodies=response["modified_bodies_monikers"], + found=response["found"], + repaired=response["repaired"], ) + return message @protect_grpc @@ -642,13 +659,18 @@ def find_and_fix_simplify( ) parent_design = get_design_from_body(bodies[0]) - parent_design._update_design_inplace() + + if not pyansys_geometry.USE_TRACKER_TO_UPDATE_DESIGN: + parent_design._update_design_inplace() + else: + parent_design._update_from_tracker(response["complete_command_response"]) + message = RepairToolMessage( - response["success"], - response["created_bodies_monikers"], - response["modified_bodies_monikers"], - response["found"], - response["repaired"], + success=response["success"], + created_bodies=response["created_bodies_monikers"], + modified_bodies=response["modified_bodies_monikers"], + found=response["found"], + repaired=response["repaired"], ) return message diff --git a/tests/integration/test_repair_tools.py b/tests/integration/test_repair_tools.py index 4317691149..801c75fb32 100644 --- a/tests/integration/test_repair_tools.py +++ b/tests/integration/test_repair_tools.py @@ -402,7 +402,8 @@ def test_find_and_stitch_and_missing_faces(modeler: Modeler): for i in stitch_faces: i.fix() assert len(design.bodies) == 1 - assert design.bodies[0].is_surface + # TODO : Add surface body check from backend. Issue is being tracked in #2031. + # assert design.bodies[0].is_surface missing_faces = modeler.repair_tools.find_missing_faces(design.bodies) for face in missing_faces: face.fix()