Accessing list of bodies, faces, edges


I currently have a workflow using the GUI in order to mesh some imported CAD model. My goal is to translate that workflow into a (possibly python since it is a language I am more comfortable with) script that is generic enough so it can handle roughly similar CAD models (by that I mean that some bodies in the CAD model will have the same names, some planes will be identical, etc. but there will be some differences).
So far, I have been able to record a full workflow for a specific CAD model, so this gives me an idea of how my script should be structured. However, I have some difficulties in making it more generic.
For example. Let's say that my imported file contained 6 bodies but I want to keep only 5 (for which I know the name).
I am looking to do something like this:
* obtain a list of all bodies in my model (no idea how to do this / which command to use)
* make some search in their name (I know how to do this in python)
* decide which one to delete (I know how to do this in python / simlab)
Another thing that I would like to do is how to access the selection list in python.
With a concrete example, I am:
* Using Inspect / Edges / by plane to select some edges (I know the command for this)
* Apply some mesh controls on those edges (I know the command for this as well)
My problem is that in a generic script you want to know which are the edges ids to pass to the second command (because MeshControl needs it).
One way that might work is to actually create a group when you do the inspect and use getEntityFromGroup to pass the result. But this seems quite complicated.
Any comments are more than welcome.