Is there a script command in order to select all entities of a given family? e.g., select all points, select all lines, select all surfaces, etc.

Example : I would like to select all visible curves in order to create a new part containing all the curves.

I sweep tons of 2D sufaces in order to create my 3D geometry, therefore I lose track of the vertex names, curves names, surfaces names, etc. After my geometry is done, I want to clean my model and automatically create separate parts containing all vertex, all curves, all surfaces, etc.