Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adaptive templates delete region API call #191

Merged
merged 4 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -160,3 +160,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 @@ -786,3 +786,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)
Loading