Skip to content

Commit c9d691f

Browse files
jacobrkerstetterpre-commit-ci[bot]pyansys-ci-bot
authored
feat: design activation changes (#1707)
Co-authored-by: jkerstet <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent 7b4de97 commit c9d691f

File tree

3 files changed

+5
-28
lines changed

3 files changed

+5
-28
lines changed

doc/changelog.d/1707.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
design activation changes

src/ansys/geometry/core/designer/design.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -983,27 +983,7 @@ def insert_file(self, file_location: Path | str) -> Component:
983983
self._design_stub.Insert(InsertRequest(filepath=filepath_server))
984984
self._grpc_client.log.debug(f"File {file_location} successfully inserted into design.")
985985

986-
# Get a temporal design object to update the current one
987-
tmp_design = Design("", self._modeler, read_existing_design=True)
988-
989-
# Update the reference to the design
990-
for component in tmp_design.components:
991-
component._parent_component = self
992-
993-
# Update the design's components - add the new one
994-
#
995-
# If the list is empty, add the components from the new design
996-
if not self._components:
997-
self._components.extend(tmp_design.components)
998-
else:
999-
# Insert operation adds the inserted file as a component to the design.
1000-
for tmp_component in tmp_design.components:
1001-
# Otherwise, check which is the new component added
1002-
for component in self._components:
1003-
if component.id == tmp_component.id:
1004-
break
1005-
# If not equal, add the component - since it has not been found
1006-
self._components.append(tmp_component)
986+
self._update_design_inplace()
1007987

1008988
self._grpc_client.log.debug(f"Design {self.name} is successfully updated.")
1009989

tests/integration/test_design_import.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from ansys.geometry.core.sketch import Sketch
3737
from ansys.geometry.core.tools.unsupported import PersistentIdType
3838

39-
from .conftest import FILES_DIR, IMPORT_FILES_DIR, skip_if_core_service
39+
from .conftest import FILES_DIR, IMPORT_FILES_DIR
4040

4141

4242
def _create_flat_design(modeler: Modeler) -> Design:
@@ -306,9 +306,6 @@ def test_open_file(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory):
306306

307307
def test_design_insert(modeler: Modeler):
308308
"""Test inserting a file into the design."""
309-
# Skip for CoreService
310-
skip_if_core_service(modeler, test_design_insert.__name__, "insert_file")
311-
312309
# Create a design and sketch a circle
313310
design = modeler.create_design("Insert")
314311
sketch = Sketch()
@@ -321,6 +318,7 @@ def test_design_insert(modeler: Modeler):
321318

322319
# Check that there are two components
323320
assert len(design.components) == 2
321+
assert design._is_active
324322
assert design.components[0].name == "Component_Cylinder"
325323
assert design.components[1].name == "DuplicatesDesign"
326324

@@ -329,9 +327,6 @@ def test_design_insert_with_import(modeler: Modeler):
329327
"""Test inserting a file into the design through the external format import
330328
process.
331329
"""
332-
# Skip for CoreService
333-
skip_if_core_service(modeler, test_design_insert_with_import.__name__, "insert_file")
334-
335330
# Create a design and sketch a circle
336331
design = modeler.create_design("Insert")
337332
sketch = Sketch()
@@ -344,5 +339,6 @@ def test_design_insert_with_import(modeler: Modeler):
344339

345340
# Check that there are two components
346341
assert len(design.components) == 2
342+
assert design._is_active
347343
assert design.components[0].name == "Component_Cylinder"
348344
assert design.components[1].name == "Wheel1"

0 commit comments

Comments
 (0)