What can it be us pretty clear. You have multiple curve loops as you are trying to build a PolyCurve from a surface with a hole in it.
Where you are going wrong isn’t clear as I don’t understand what you want to do. By the sounds of it you want to build a custom exporter which isn’t something that can just happen without sanitizing your data or otherwise limiting the scope (remove the window loops).
As far as can I help you, you’ll need to provide more info for anyone to help. A Revit model is a good place to start.