From 1d84bab8e55dbe848937c68c93e88db76ff78683 Mon Sep 17 00:00:00 2001 From: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Date: Fri, 19 Apr 2024 12:56:56 +0200 Subject: [PATCH 1/8] feat: add ``export_to`` functions --- src/ansys/geometry/core/designer/design.py | 185 ++++++++++++++- tests/integration/test_design_export.py | 251 +++++++++++++++++++++ 2 files changed, 431 insertions(+), 5 deletions(-) create mode 100644 tests/integration/test_design_export.py diff --git a/src/ansys/geometry/core/designer/design.py b/src/ansys/geometry/core/designer/design.py index a6f8c687a2..d92cc26b8a 100644 --- a/src/ansys/geometry/core/designer/design.py +++ b/src/ansys/geometry/core/designer/design.py @@ -46,6 +46,7 @@ import numpy as np from pint import Quantity, UndefinedUnitError +from ansys.geometry.core.connection.backend import BackendType from ansys.geometry.core.connection.conversions import ( grpc_frame_to_frame, grpc_matrix_to_matrix, @@ -253,13 +254,13 @@ def download( Format for the file to save to. """ # Sanity checks on inputs - if isinstance(file_location, Path): - file_location = str(file_location) + if isinstance(file_location, str): + file_location = Path(file_location) # Check if the folder for the file location exists - if not Path(file_location).parent.exists(): + if not file_location.parent.exists(): # Create the parent directory - Path(file_location).parent.mkdir(parents=True, exist_ok=True) + file_location.parent.mkdir(parents=True, exist_ok=True) # Process response self._grpc_client.log.debug(f"Requesting design download in {format.value[0]} format.") @@ -292,6 +293,180 @@ def download( f"Design is successfully downloaded at location {file_location}." ) + def export_to_scdocx(self, location: Union[Path, str] = None) -> str: + """ + Export the design to an scdocx file. + + Parameters + ---------- + location : Union[~pathlib.Path, str], optional + Location on disk to save the file to. If None, the file will be saved + in the current working directory. + + Returns + ------- + str + The path to the saved file. + """ + # Define the file location + file_location = (Path(location) if location else Path.cwd()) / f"{self.name}.scdocx" + + # Export the design to an scdocx file + self.download(file_location, DesignFileFormat.SCDOCX) + + # Return the file location + return file_location + + def export_to_parasolid_text(self, location: Union[Path, str] = None) -> str: + """ + Export the design to a Parasolid text file. + + Parameters + ---------- + location : Union[~pathlib.Path, str], optional + Location on disk to save the file to. If None, the file will be saved + in the current working directory. + + Returns + ------- + str + The path to the saved file. + """ + # Determine the extension based on the backend type + ext = "x_t" if self._grpc_client.backend_type == BackendType.LINUX_SERVICE else "xmt_txt" + + # Define the file location + file_location = (Path(location) if location else Path.cwd()) / f"{self.name}.{ext}" + + # Export the design to a Parasolid text file + self.download(file_location, DesignFileFormat.PARASOLID_TEXT) + + # Return the file location + return file_location + + def export_to_parasolid_bin(self, location: Union[Path, str] = None) -> str: + """ + Export the design to a Parasolid binary file. + + Parameters + ---------- + location : Union[~pathlib.Path, str], optional + Location on disk to save the file to. If None, the file will be saved + in the current working directory. + + Returns + ------- + str + The path to the saved file. + """ + # Determine the extension based on the backend type + ext = "x_b" if self._grpc_client.backend_type == BackendType.LINUX_SERVICE else "xmt_bin" + + # Define the file location + file_location = (Path(location) if location else Path.cwd()) / f"{self.name}.{ext}" + + # Export the design to a Parasolid binary file + self.download(file_location, DesignFileFormat.PARASOLID_BIN) + + # Return the file location + return file_location + + def export_to_fmd(self, location: Union[Path, str] = None) -> str: + """ + Export the design to an FMD file. + + Parameters + ---------- + location : Union[~pathlib.Path, str], optional + Location on disk to save the file to. If None, the file will be saved + in the current working directory. + + Returns + ------- + str + The path to the saved file. + """ + # Define the file location + file_location = (Path(location) if location else Path.cwd()) / f"{self.name}.fmd" + + # Export the design to an FMD file + self.download(file_location, DesignFileFormat.FMD) + + # Return the file location + return file_location + + def export_to_step(self, location: Union[Path, str] = None) -> str: + """ + Export the design to a STEP file. + + Parameters + ---------- + location : Union[~pathlib.Path, str], optional + Location on disk to save the file to. If None, the file will be saved + in the current working directory. + + Returns + ------- + str + The path to the saved file. + """ + # Define the file location + file_location = (Path(location) if location else Path.cwd()) / f"{self.name}.stp" + + # Export the design to a STEP file + self.download(file_location, DesignFileFormat.STEP) + + # Return the file location + return file_location + + def export_to_iges(self, location: Union[Path, str] = None) -> str: + """ + Export the design to an IGES file. + + Parameters + ---------- + location : Union[~pathlib.Path, str], optional + Location on disk to save the file to. If None, the file will be saved + in the current working directory. + + Returns + ------- + str + The path to the saved file. + """ + # Define the file location + file_location = (Path(location) if location else Path.cwd()) / f"{self.name}.igs" + + # Export the design to an IGES file + self.download(file_location, DesignFileFormat.IGES) + + # Return the file location + return file_location + + def export_to_pmdb(self, location: Union[Path, str] = None) -> str: + """ + Export the design to a PMDB file. + + Parameters + ---------- + location : Union[~pathlib.Path, str], optional + Location on disk to save the file to. If None, the file will be saved + in the current working directory. + + Returns + ------- + str + The path to the saved file. + """ + # Define the file location + file_location = (Path(location) if location else Path.cwd()) / f"{self.name}.pmdb" + + # Export the design to a PMDB file + self.download(file_location, DesignFileFormat.PMDB) + + # Return the file location + return file_location + @check_input_types @ensure_design_is_active def create_named_selection( @@ -694,7 +869,7 @@ def __read_existing_design(self) -> None: # Since they're the same in the backend. self._name = design.name - response = self._commands_stub.GetAssembly(EntityIdentifier(id="")) + response = self._commands_stub.GetAssembly(EntityIdentifier(id=self._design_id)) # Store created objects created_parts = {p.id: Part(p.id, p.name, [], []) for p in response.parts} diff --git a/tests/integration/test_design_export.py b/tests/integration/test_design_export.py new file mode 100644 index 0000000000..cb9e4e2326 --- /dev/null +++ b/tests/integration/test_design_export.py @@ -0,0 +1,251 @@ +# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates. +# SPDX-License-Identifier: MIT +# +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +"""Test design export functionality.""" + +import numpy as np +import pytest + +from ansys.geometry.core import Modeler +from ansys.geometry.core.connection.backend import BackendType +from ansys.geometry.core.designer import Component, Design +from ansys.geometry.core.math import Plane, Point2D, Point3D, UnitVector3D, Vector3D +from ansys.geometry.core.sketch import Sketch + + +def _create_demo_design(modeler: Modeler) -> Design: + """Create a demo design for the tests.""" + modeler.create_design("Demo") + + design_name = "DemoDesign" + design = modeler.create_design(design_name) + + # Create a car + car1 = design.add_component("Car1") + comp1 = car1.add_component("A") + comp2 = car1.add_component("B") + wheel1 = comp2.add_component("Wheel1") + + # Create car base frame + sketch = Sketch().box(Point2D([5, 10]), 10, 20) + comp2.add_component("Base").extrude_sketch("BaseBody", sketch, 5) + + # Create first wheel + sketch = Sketch(Plane(direction_x=Vector3D([0, 1, 0]), direction_y=Vector3D([0, 0, 1]))) + sketch.circle(Point2D([0, 0]), 5) + wheel1.extrude_sketch("Wheel", sketch, -5) + + # Create 3 other wheels and move them into position + rotation_origin = Point3D([0, 0, 0]) + rotation_direction = UnitVector3D([0, 0, 1]) + + wheel2 = comp2.add_component("Wheel2", wheel1) + wheel2.modify_placement(Vector3D([0, 20, 0])) + + wheel3 = comp2.add_component("Wheel3", wheel1) + wheel3.modify_placement(Vector3D([10, 0, 0]), rotation_origin, rotation_direction, np.pi) + + wheel4 = comp2.add_component("Wheel4", wheel1) + wheel4.modify_placement(Vector3D([10, 20, 0]), rotation_origin, rotation_direction, np.pi) + + # Create 2nd car + car2 = design.add_component("Car2", car1) + car2.modify_placement(Vector3D([30, 0, 0])) + + # Create top of car - applies to BOTH cars + sketch = Sketch(Plane(Point3D([0, 5, 5]))).box(Point2D([5, 2.5]), 10, 5) + comp1.extrude_sketch("Top", sketch, 5) + + return design + + +def _checker_method(comp: Component, comp_ref: Component, precise_check: bool = True) -> None: + # Check component features + if precise_check: + assert comp.id == comp_ref.id + assert comp.name == comp_ref.name + assert len(comp.bodies) == len(comp_ref.bodies) + assert len(comp.components) == len(comp_ref.components) + assert len(comp.coordinate_systems) == len(comp_ref.coordinate_systems) + assert comp.shared_topology == comp_ref.shared_topology + + # Check design features + if isinstance(comp, Design) and isinstance(comp_ref, Design): + assert len(comp.materials) == len(comp_ref.materials) + assert len(comp.named_selections) == len(comp_ref.named_selections) + + if precise_check: + # Check bodies (if any) + for body, body_ref in zip( + sorted(comp.bodies, key=lambda b: b.name), sorted(comp_ref.bodies, key=lambda b: b.name) + ): + assert body.id == body_ref.id + assert body.name == body_ref.name + + # Check subcomponents + for subcomp, subcomp_ref in zip( + sorted(comp.components, key=lambda c: c.name), + sorted(comp_ref.components, key=lambda c: c.name), + ): + _checker_method(subcomp, subcomp_ref, precise_check) + + +def test_export_to_scdocx(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory): + """Test exporting a design to scdocx format.""" + # Create a demo design + design = _create_demo_design(modeler) + + # Define the location and expected file location + location = tmp_path_factory.mktemp("test_export_to_scdocx") + file_location = location / f"{design.name}.scdocx" + + # Export to scdocx + design.export_to_scdocx(location) + + # Check the exported file + assert file_location.exists() + + # Import the scdocx + design_read = modeler.open_file(file_location) + + # Check the imported design + _checker_method(design_read, design, True) + + +def test_export_to_parasolid_text(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory): + """Test exporting a design to parasolid text format.""" + # Create a demo design + design = _create_demo_design(modeler) + + # Define the location and expected file location + location = tmp_path_factory.mktemp("test_export_to_parasolid_text") + + if modeler.client.backend_type == BackendType.LINUX_SERVICE: + file_location = location / f"{design.name}.x_t" + else: + file_location = location / f"{design.name}.xmt_txt" + + # Export to parasolid text + design.export_to_parasolid_text(location) + + # Check the exported file + assert file_location.exists() + + # TODO: Check the exported file content + + +def test_export_to_parasolid_binary(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory): + """Test exporting a design to parasolid binary format.""" + # Create a demo design + design = _create_demo_design(modeler) + + # Define the location and expected file location + location = tmp_path_factory.mktemp("test_export_to_parasolid_binary") + + if modeler.client.backend_type == BackendType.LINUX_SERVICE: + file_location = location / f"{design.name}.x_b" + else: + file_location = location / f"{design.name}.xmt_bin" + + # Export to parasolid binary + design.export_to_parasolid_bin(location) + + # Check the exported file + assert file_location.exists() + + # TODO: Check the exported file content + + +def test_export_to_step(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory): + """Test exporting a design to STEP format.""" + # Create a demo design + design = _create_demo_design(modeler) + + # Define the location and expected file location + location = tmp_path_factory.mktemp("test_export_to_step") + file_location = location / f"{design.name}.stp" + + # Export to step + design.export_to_step(location) + + # Check the exported file + assert file_location.exists() + + # Import the scdocx + design_read = modeler.open_file(file_location) + + # Check the imported design + _checker_method(design_read, design, False) + + +def test_export_to_iges(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory): + """Test exporting a design to IGES format.""" + # Create a demo design + design = _create_demo_design(modeler) + + # Define the location and expected file location + location = tmp_path_factory.mktemp("test_export_to_stl") + file_location = location / f"{design.name}.igs" + + # Export to IGES + design.export_to_iges(location) + + # Check the exported file + assert file_location.exists() + + # TODO: Check the exported file content + + +def test_export_to_fmd(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory): + """Test exporting a design to FMD format.""" + # Create a demo design + design = _create_demo_design(modeler) + + # Define the location and expected file location + location = tmp_path_factory.mktemp("test_export_to_fmd") + file_location = location / f"{design.name}.fmd" + + # Export to FMD + design.export_to_fmd(location) + + # Check the exported file + assert file_location.exists() + + # TODO: Check the exported file content + + +def test_export_to_pmdb(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory): + """Test exporting a design to PMDB format.""" + # Create a demo design + design = _create_demo_design(modeler) + + # Define the location and expected file location + location = tmp_path_factory.mktemp("test_export_to_pmdb") + file_location = location / f"{design.name}.pmdb" + + # Export to PMDB + design.export_to_pmdb(location) + + # Check the exported file + assert file_location.exists() + + # TODO: Check the exported file content From 27e6e5e582f74e7b6ff7897a353de62a93025431 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 19 Apr 2024 10:58:26 +0000 Subject: [PATCH 2/8] chore: auto fixes from pre-commit hooks --- tests/integration/test_design_export.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/integration/test_design_export.py b/tests/integration/test_design_export.py index cb9e4e2326..8ef7c5d3c9 100644 --- a/tests/integration/test_design_export.py +++ b/tests/integration/test_design_export.py @@ -19,7 +19,6 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. - """Test design export functionality.""" import numpy as np From 7ecf3740f1c6818675a1e7f72dc89232764e3cf9 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot Date: Fri, 19 Apr 2024 10:59:39 +0000 Subject: [PATCH 3/8] Adding changelog entry: 1147.added.md --- doc/changelog.d/1147.added.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/1147.added.md diff --git a/doc/changelog.d/1147.added.md b/doc/changelog.d/1147.added.md new file mode 100644 index 0000000000..fe797d0492 --- /dev/null +++ b/doc/changelog.d/1147.added.md @@ -0,0 +1 @@ +feat: add ``export_to`` functions \ No newline at end of file From 42938a561bfa48de5cb94c473911834f0405a7d0 Mon Sep 17 00:00:00 2001 From: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Date: Fri, 19 Apr 2024 13:10:27 +0200 Subject: [PATCH 4/8] fix: failing tests --- tests/integration/conftest.py | 2 +- tests/integration/test_design_export.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 413f48cbc9..40a5f9507d 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -48,7 +48,7 @@ def skip_if_linux(modeler: Modeler, test_name: str, element_not_available: str): """Skip test if running on Linux.""" if modeler.client.backend_type == BackendType.LINUX_SERVICE: pytest.skip( - f"Skipping '{test_name}'. '{element_not_available}' not available on Linux service." + reason=f"Skipping '{test_name}'. '{element_not_available}' not on Linux service." ) # skip! diff --git a/tests/integration/test_design_export.py b/tests/integration/test_design_export.py index 8ef7c5d3c9..354fc5e04d 100644 --- a/tests/integration/test_design_export.py +++ b/tests/integration/test_design_export.py @@ -183,17 +183,18 @@ def test_export_to_step(modeler: Modeler, tmp_path_factory: pytest.TempPathFacto location = tmp_path_factory.mktemp("test_export_to_step") file_location = location / f"{design.name}.stp" - # Export to step + # Export to STEP design.export_to_step(location) # Check the exported file assert file_location.exists() - # Import the scdocx - design_read = modeler.open_file(file_location) + if modeler.client.backend_type != BackendType.LINUX_SERVICE: + # Import the STEP file + design_read = modeler.open_file(file_location) - # Check the imported design - _checker_method(design_read, design, False) + # Check the imported design + _checker_method(design_read, design, False) def test_export_to_iges(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory): From 45f02dd4afede1330f9d38ed2835afb756316464 Mon Sep 17 00:00:00 2001 From: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Date: Fri, 19 Apr 2024 14:27:49 +0200 Subject: [PATCH 5/8] feat: extract function --- src/ansys/geometry/core/designer/design.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/ansys/geometry/core/designer/design.py b/src/ansys/geometry/core/designer/design.py index d92cc26b8a..f153191cd6 100644 --- a/src/ansys/geometry/core/designer/design.py +++ b/src/ansys/geometry/core/designer/design.py @@ -293,6 +293,10 @@ def download( f"Design is successfully downloaded at location {file_location}." ) + def __build_export_file_location(self, location: Union[Path, str, None], ext: str) -> Path: + """Build the file location for export functions.""" + return (Path(location) if location else Path.cwd()) / f"{self.name}.{ext}" + def export_to_scdocx(self, location: Union[Path, str] = None) -> str: """ Export the design to an scdocx file. @@ -309,7 +313,7 @@ def export_to_scdocx(self, location: Union[Path, str] = None) -> str: The path to the saved file. """ # Define the file location - file_location = (Path(location) if location else Path.cwd()) / f"{self.name}.scdocx" + file_location = self.__build_export_file_location(location, "scdocx") # Export the design to an scdocx file self.download(file_location, DesignFileFormat.SCDOCX) @@ -336,7 +340,7 @@ def export_to_parasolid_text(self, location: Union[Path, str] = None) -> str: ext = "x_t" if self._grpc_client.backend_type == BackendType.LINUX_SERVICE else "xmt_txt" # Define the file location - file_location = (Path(location) if location else Path.cwd()) / f"{self.name}.{ext}" + file_location = self.__build_export_file_location(location, ext) # Export the design to a Parasolid text file self.download(file_location, DesignFileFormat.PARASOLID_TEXT) @@ -363,7 +367,7 @@ def export_to_parasolid_bin(self, location: Union[Path, str] = None) -> str: ext = "x_b" if self._grpc_client.backend_type == BackendType.LINUX_SERVICE else "xmt_bin" # Define the file location - file_location = (Path(location) if location else Path.cwd()) / f"{self.name}.{ext}" + file_location = self.__build_export_file_location(location, ext) # Export the design to a Parasolid binary file self.download(file_location, DesignFileFormat.PARASOLID_BIN) @@ -387,7 +391,7 @@ def export_to_fmd(self, location: Union[Path, str] = None) -> str: The path to the saved file. """ # Define the file location - file_location = (Path(location) if location else Path.cwd()) / f"{self.name}.fmd" + file_location = self.__build_export_file_location(location, "fmd") # Export the design to an FMD file self.download(file_location, DesignFileFormat.FMD) @@ -411,7 +415,7 @@ def export_to_step(self, location: Union[Path, str] = None) -> str: The path to the saved file. """ # Define the file location - file_location = (Path(location) if location else Path.cwd()) / f"{self.name}.stp" + file_location = self.__build_export_file_location(location, "stp") # Export the design to a STEP file self.download(file_location, DesignFileFormat.STEP) @@ -435,7 +439,7 @@ def export_to_iges(self, location: Union[Path, str] = None) -> str: The path to the saved file. """ # Define the file location - file_location = (Path(location) if location else Path.cwd()) / f"{self.name}.igs" + file_location = self.__build_export_file_location(location, "igs") # Export the design to an IGES file self.download(file_location, DesignFileFormat.IGES) @@ -459,7 +463,7 @@ def export_to_pmdb(self, location: Union[Path, str] = None) -> str: The path to the saved file. """ # Define the file location - file_location = (Path(location) if location else Path.cwd()) / f"{self.name}.pmdb" + file_location = self.__build_export_file_location(location, "pmdb") # Export the design to a PMDB file self.download(file_location, DesignFileFormat.PMDB) From 821705c638465d9457cc642fcaf96ff2a9b8c9b0 Mon Sep 17 00:00:00 2001 From: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Date: Fri, 19 Apr 2024 14:28:51 +0200 Subject: [PATCH 6/8] docs: proper docstring --- src/ansys/geometry/core/designer/design.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/ansys/geometry/core/designer/design.py b/src/ansys/geometry/core/designer/design.py index f153191cd6..d3f4a2776b 100644 --- a/src/ansys/geometry/core/designer/design.py +++ b/src/ansys/geometry/core/designer/design.py @@ -294,7 +294,22 @@ def download( ) def __build_export_file_location(self, location: Union[Path, str, None], ext: str) -> Path: - """Build the file location for export functions.""" + """ + Build the file location for export functions. + + Parameters + ---------- + location : Union[~pathlib.Path, str, None] + Location on disk to save the file to. If None, the file will be saved + in the current working directory. + ext : str + Extension to use for the file. + + Returns + ------- + ~pathlib.Path + The file location for the export function. + """ return (Path(location) if location else Path.cwd()) / f"{self.name}.{ext}" def export_to_scdocx(self, location: Union[Path, str] = None) -> str: From 3db0173349de8d6028d06f595b27754b1051a574 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 19 Apr 2024 12:30:51 +0000 Subject: [PATCH 7/8] chore: auto fixes from pre-commit hooks --- src/ansys/geometry/core/designer/design.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ansys/geometry/core/designer/design.py b/src/ansys/geometry/core/designer/design.py index d3f4a2776b..f53cecacea 100644 --- a/src/ansys/geometry/core/designer/design.py +++ b/src/ansys/geometry/core/designer/design.py @@ -296,7 +296,7 @@ def download( def __build_export_file_location(self, location: Union[Path, str, None], ext: str) -> Path: """ Build the file location for export functions. - + Parameters ---------- location : Union[~pathlib.Path, str, None] @@ -304,7 +304,7 @@ def __build_export_file_location(self, location: Union[Path, str, None], ext: st in the current working directory. ext : str Extension to use for the file. - + Returns ------- ~pathlib.Path From cac143a39d1e17e3b3d8f585cc25c7aa671dee03 Mon Sep 17 00:00:00 2001 From: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Date: Fri, 19 Apr 2024 14:35:29 +0200 Subject: [PATCH 8/8] ci: check str input as well to download method --- tests/integration/test_design_import.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/test_design_import.py b/tests/integration/test_design_import.py index cf0d81ecb0..1b1e6bbae3 100644 --- a/tests/integration/test_design_import.py +++ b/tests/integration/test_design_import.py @@ -191,7 +191,7 @@ def test_open_file(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory): comp1.extrude_sketch("Top", sketch, 5) file = tmp_path_factory.mktemp("test_design_import") / "two_cars.scdocx" - design.download(file) + design.download(str(file)) design2 = modeler.open_file(file)