From 16d598c9ee949f4d16cb6642af884ce838ed53a6 Mon Sep 17 00:00:00 2001 From: jonahrb Date: Tue, 16 Sep 2025 09:43:59 -0500 Subject: [PATCH 1/7] add parameter --- src/ansys/geometry/core/designer/design.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/ansys/geometry/core/designer/design.py b/src/ansys/geometry/core/designer/design.py index 98565b7e22..9a9da120ec 100644 --- a/src/ansys/geometry/core/designer/design.py +++ b/src/ansys/geometry/core/designer/design.py @@ -426,7 +426,9 @@ def __build_export_file_location(self, location: Path | str | None, ext: str) -> """ return (Path(location) if location else Path.cwd()) / f"{self.name}.{ext}" - def export_to_scdocx(self, location: Path | str | None = None) -> Path: + def export_to_scdocx( + self, location: Path | str | None = None, write_body_facets: bool = False + ) -> Path: """Export the design to an scdocx file. Parameters @@ -434,6 +436,8 @@ def export_to_scdocx(self, location: Path | str | None = None) -> Path: location : ~pathlib.Path | str, optional Location on disk to save the file to. If None, the file will be saved in the current working directory. + write_body_facets : bool, default: False + Option to write body facets into the saved file. SCDOCX and DISCO only, 26R1 and later. Returns ------- @@ -444,12 +448,14 @@ def export_to_scdocx(self, location: Path | str | None = None) -> Path: file_location = self.__build_export_file_location(location, "scdocx") # Export the design to an scdocx file - self.download(file_location, DesignFileFormat.SCDOCX) + self.download(file_location, DesignFileFormat.SCDOCX, write_body_facets) # Return the file location return file_location - def export_to_disco(self, location: Path | str | None = None) -> Path: + def export_to_disco( + self, location: Path | str | None = None, write_body_facets: bool = False + ) -> Path: """Export the design to an dsco file. Parameters @@ -457,6 +463,8 @@ def export_to_disco(self, location: Path | str | None = None) -> Path: location : ~pathlib.Path | str, optional Location on disk to save the file to. If None, the file will be saved in the current working directory. + write_body_facets : bool, default: False + Option to write body facets into the saved file. SCDOCX and DISCO only, 26R1 and later. Returns ------- @@ -467,7 +475,7 @@ def export_to_disco(self, location: Path | str | None = None) -> Path: file_location = self.__build_export_file_location(location, "dsco") # Export the design to an dsco file - self.download(file_location, DesignFileFormat.DISCO) + self.download(file_location, DesignFileFormat.DISCO, write_body_facets) # Return the file location return file_location From 6028c63df607300758b35f1aaee1df8a91bd2ca2 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Tue, 16 Sep 2025 14:46:43 +0000 Subject: [PATCH 2/7] chore: adding changelog file 2231.fixed.md [dependabot-skip] --- doc/changelog.d/2231.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/2231.fixed.md diff --git a/doc/changelog.d/2231.fixed.md b/doc/changelog.d/2231.fixed.md new file mode 100644 index 0000000000..5b60051f51 --- /dev/null +++ b/doc/changelog.d/2231.fixed.md @@ -0,0 +1 @@ +Add option to write body facets to explicit export methods From 454b6a234836e6cfe3840b0ca568fee6b22f3dfd Mon Sep 17 00:00:00 2001 From: cord Date: Tue, 16 Sep 2025 10:08:36 -0600 Subject: [PATCH 3/7] adding facets writing to tests for test coverage --- tests/integration/test_design.py | 4 ++-- tests/integration/test_design_export.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/integration/test_design.py b/tests/integration/test_design.py index 8d13cbe7dd..d9bb816b81 100644 --- a/tests/integration/test_design.py +++ b/tests/integration/test_design.py @@ -1220,7 +1220,7 @@ def test_download_file(modeler: Modeler, tmp_path_factory: pytest.TempPathFactor else: file_save = tmp_path_factory.mktemp("scdoc_files_save") / "cylinder.scdocx" - design.save(file_location=file_save) + design.save(file_location=file_save, write_body_facets=True) # Check for other exports - Windows backend... if not BackendType.is_core_service(modeler.client.backend_type): @@ -3778,7 +3778,7 @@ def test_vertices(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory): location = tmp_path_factory.mktemp("test_export_to_scdocx") file_location = location / f"{design.name}.scdocx" - design.export_to_scdocx(location) + design.export_to_scdocx(location, write_body_facets=True) assert file_location.exists() design_read = modeler.open_file(file_location) assert len(design_read.named_selections) == 5 diff --git a/tests/integration/test_design_export.py b/tests/integration/test_design_export.py index 44c4269149..84b1ee2125 100644 --- a/tests/integration/test_design_export.py +++ b/tests/integration/test_design_export.py @@ -219,7 +219,7 @@ def test_export_to_disco(modeler: Modeler, tmp_path_factory: pytest.TempPathFact file_location = location / f"{design.name}.dsco" # Export to dsco - design.export_to_disco(location) + design.export_to_disco(location, write_body_facets=True) # Check the exported file assert file_location.exists() From fcc42a7af364a86950ac737729b91184a23d4ac4 Mon Sep 17 00:00:00 2001 From: cord Date: Wed, 17 Sep 2025 09:52:22 -0600 Subject: [PATCH 4/7] adding file size assert to ensure file size includes facets --- tests/integration/test_design.py | 3 ++- tests/integration/test_design_export.py | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_design.py b/tests/integration/test_design.py index d9bb816b81..e3354c3201 100644 --- a/tests/integration/test_design.py +++ b/tests/integration/test_design.py @@ -3778,7 +3778,8 @@ def test_vertices(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory): location = tmp_path_factory.mktemp("test_export_to_scdocx") file_location = location / f"{design.name}.scdocx" - design.export_to_scdocx(location, write_body_facets=True) + exported_file = design.export_to_scdocx(location, write_body_facets=True) + assert os.path.getsize(exported_file) == pytest.approx(216642, 1e-3, 100) assert file_location.exists() design_read = modeler.open_file(file_location) assert len(design_read.named_selections) == 5 diff --git a/tests/integration/test_design_export.py b/tests/integration/test_design_export.py index 84b1ee2125..211baa32e0 100644 --- a/tests/integration/test_design_export.py +++ b/tests/integration/test_design_export.py @@ -21,6 +21,7 @@ # SOFTWARE. """Test design export functionality.""" +import os from pathlib import Path import numpy as np @@ -219,7 +220,10 @@ def test_export_to_disco(modeler: Modeler, tmp_path_factory: pytest.TempPathFact file_location = location / f"{design.name}.dsco" # Export to dsco - design.export_to_disco(location, write_body_facets=True) + exported_file = design.export_to_disco(location, write_body_facets=True) + + # Checking file size to ensure facets are exported + assert os.path.getsize(exported_file) == pytest.approx(53844, 1e-3, 100) # Check the exported file assert file_location.exists() From 04d2f7b5a1e62864223258dbe9a22792aa754cd0 Mon Sep 17 00:00:00 2001 From: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Date: Tue, 23 Sep 2025 16:04:49 +0200 Subject: [PATCH 5/7] fix: pre-commit --- tests/integration/test_design.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/test_design.py b/tests/integration/test_design.py index e3354c3201..c1486f3fe4 100644 --- a/tests/integration/test_design.py +++ b/tests/integration/test_design.py @@ -3779,7 +3779,7 @@ def test_vertices(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory): location = tmp_path_factory.mktemp("test_export_to_scdocx") file_location = location / f"{design.name}.scdocx" exported_file = design.export_to_scdocx(location, write_body_facets=True) - assert os.path.getsize(exported_file) == pytest.approx(216642, 1e-3, 100) + assert exported_file.stat().st_size == pytest.approx(216642, 1e-3, 100) assert file_location.exists() design_read = modeler.open_file(file_location) assert len(design_read.named_selections) == 5 From f24595029652794db18d7ba2d4673069363c5fdb Mon Sep 17 00:00:00 2001 From: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Date: Tue, 23 Sep 2025 16:05:01 +0200 Subject: [PATCH 6/7] fix: pre-commit --- tests/integration/test_design_export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/test_design_export.py b/tests/integration/test_design_export.py index 211baa32e0..ff2ce40e1b 100644 --- a/tests/integration/test_design_export.py +++ b/tests/integration/test_design_export.py @@ -223,7 +223,7 @@ def test_export_to_disco(modeler: Modeler, tmp_path_factory: pytest.TempPathFact exported_file = design.export_to_disco(location, write_body_facets=True) # Checking file size to ensure facets are exported - assert os.path.getsize(exported_file) == pytest.approx(53844, 1e-3, 100) + assert exported_file.stat().st_size == pytest.approx(53844, 1e-3, 100) # Check the exported file assert file_location.exists() From 87ef22ead8cb3761af9ae9382ee8f819738a2560 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 23 Sep 2025 14:05:17 +0000 Subject: [PATCH 7/7] 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 ff2ce40e1b..0ee6f447fa 100644 --- a/tests/integration/test_design_export.py +++ b/tests/integration/test_design_export.py @@ -21,7 +21,6 @@ # SOFTWARE. """Test design export functionality.""" -import os from pathlib import Path import numpy as np