batch_geometry_operations#

Modeler2D.batch_geometry_operations()#

Batch geometry operations in a single cleanup phase.

This context manager is useful when several modeler operations are applied in sequence and intermediate cleanup_objects calls would otherwise make Python object references stale. It can also improve performance for large geometries by deferring repeated cleanup work until the batch completes. Operations inside the context may temporarily leave the Python object dictionaries out of sync with AEDT. Any cleanup_objects calls are combined into one cleanup when the outermost context exits, so names or other stable selections should be used for objects that may be removed or changed during the batch.

This context is not thread-safe.

Examples

>>> from ansys.aedt.core.hfss import Hfss
>>> from ansys.aedt.core.generic.constants import Axis
>>> app = Hfss()
>>> target = app.modeler.create_box(origin=[0, 0, 0], sizes=[100, 100, 20])
>>> cutter = app.modeler.create_cylinder(orientation=Axis.Z, origin=[0, 0, -1], radius=1, height=22)
>>> with app.modeler.batch_geometry_operations():
...     app.modeler.subtract(target.name, cutter.name, keep_originals=False)