Skip to content

Commit

Permalink
Adaptive templates delete region API call (#191)
Browse files Browse the repository at this point in the history
* Initial commit

* Review changes

* Update src/ansys/motorcad/core/methods/adaptive_geometry.py

---------

Co-authored-by: JackDavies <[email protected]>
Co-authored-by: jgsdavies <[email protected]>
  • Loading branch information
3 people authored Oct 9, 2023
1 parent cf6ab8d commit d25c7a0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/ansys/motorcad/core/methods/adaptive_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,22 @@ def unite_regions(self, region, regions):
region._from_json(united_raw)

return region

def delete_region(self, region, remove_children=False):
"""Delete region from Motor-CAD geometry engine.
Parameters
----------
region : ansys.motorcad.core.geometry.Region
Motor-CAD region object
remove_children : boolean
Whether to remove regions children
"""
self.connection.ensure_version_at_least("2024.0")

raw_region = region._to_json()

method = "DeleteRegion"
params = [raw_region, remove_children]
self.connection.send_and_receive(method, params)
11 changes: 11 additions & 0 deletions tests/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,3 +804,14 @@ def test_check_collisions_3():
collisions = mc.check_collisions(square, [triangle])
assert len(collisions) == 1
assert collisions[0] == triangle


def test_delete_region():
stator = mc.get_region("Stator")

mc.delete_region(stator)

with pytest.raises(Exception) as e_info:
mc.get_region("Stator")

assert "Failed to find region with name" in str(e_info.value)

0 comments on commit d25c7a0

Please sign in to comment.