Well, first it would be helpful if you could elaborate on what you mean by 2D entities (splines, even if they are 3D splines? what about renderable splines? etc.). If you only want to keep geometry objects, this will be enough:
delete (for obj in objects where NOT isKindOf obj GeometryClass collect obj)
Thanks for you replies, when I noted 2D i was refering to enteites like splines etc that are usually importrde from AutoCAD. I would like to keep 3D objects, cameras etc.
I tried the SwordSlayers script but it seems that it deletes too much items even 3D objects.
Yeah, that's why I asked for further specification, although 'splines etc' is still not all that much better. Anyway, you can use delete shapes to delete all the splines and for the rest... that depends on what it is.. If you'd for example want to delete all shapes that are flat, you could do it this way:
delete (for obj in shapes where abs (obj.max - obj.min).z < 1e-3 collect obj)