Removing doubles on imported 3DXML ngon mesh
EDIT

A better approach would be to look for the two "ripped" edges in a face that share the same geometry. (edges parallel with same mid point test or similar), and remove the edges verts from the remove doubles list.



Thanks for your help guys, The answer kinda came to me when I was creating pics to explain the situation and opened up the poly.  

The trick was looking at faces with more than one double and removing them from the remove doubles operator, otherwise will end up trying to make a poly with holes, which ends up being a hole.

The following reduces vert count of building.014 from 4205 to 1258... and leaves the roof intact.

import bpy
import bmesh
context = bpy.context
obj = context.object
print("X" * 80)
bm = bmesh.new()
bm.from_mesh(obj.data)
bm.faces.ensure_lookup_table()
ignore_doubles = []
for f in bm.faces:
    verts = f.verts
    dubs = bmesh.ops.find_doubles(bm,
                                  verts=verts,
                                  dist=0.00001)
    double_verts = dubs['targetmap']
    if len(double_verts.keys()) &gt; 1:
        for k, v in double_verts.items():
            ignore_doubles.append(v)

verts = list(set(bm.verts) - set(ignore_doubles))            
bmesh.ops.remove_doubles(bm, verts=verts, dist=0.00001)

bm.to_mesh(context.object.data)