Ansys Employee

I see you are using the Combine tool and seleting a body so edge selection is not involved. The RemoveRegions() method is done as the second part of a Combine operation that intersected some bodies. The is the same as just deleting a body after the intersection. A big challenge with scripting, which determines ultimately whether a process can be scripted or not is whether selections can be done without a graphical interface.

One way to handle this is to place edge/bodies/faces/vertices into named selections before the script runs, and the script will get entities in the named selections. Another way, which can sometimes get the desired entities in simple models, is to get based on a min/max XYZ value. You can get a bounding box or centroid of faces/edges/bodies and check XYZ values and only use those above or below a value you want. For vertices, you can get exact XYZ locations to check against min/max target values. You already know about the index method for selections, which is a type of selection by ID.

Also, to make scripting robust, which guarantees the right selection after operations, is to get the return value of an operation and then contnue to operate on it. For the Combine.RemoveRegions() operation that you showed, this always happens after a Combine.Intersect(). So get the result bodies like this:

targets = BodySelection.Create(GetRootPart().Bodies[0])
tools = BodySelection.Create(GetRootPart().Bodies[2])
options = MakeSolidsOptions()
result = Combine.Intersect(targets, tools, options)
newBodies = result.CreatedBodies
selection = BodySelection.Create(newBodies)
result = Combine.RemoveRegions(selection)

Of course, you will have to get the original "targets" and "tools" bodies by some other method, such as index, named selection, max/min XYZ, or they may also be the result of a previous operation.