script detaching all faces (or elements) within certain distance or with similar characteristics, as separate objects

Is there a script detaching all faces within a certain distance (or maybe combined with some similar characteristics?), as separate objects (instances)? It could be useful for detaching of windows for example, where every single window is not an element but is formed from two or more faces so the selecting and detaching them is time consuming, or for example doors (which are one object) so that every single door becomes a single object. Instead of selecting each door in the element sub-object level and detach it, it might be helpful to have a script that somehow recognize that some elements form a separate object (a door in this case). I guess everybody who works with 3ds, has stumbled here and there upon this situation especially when you have imported geometry.