DWG to Walls on same layer

Hello,

I’ve been trying to get my script correct for a few days now. I want to convert a DWG to a Revit model and I’ve started with the walls. Now I’m coming across an issue. If all the walls are on te same layer, some get placed by exterior face and some interior. The difference between the walls lies them in interior en exterior walls.

I’ve now split up the DWG in to those two parts and now the script works perfectly. But I don’t want it to work like that. I’d rather have another way of working around it.

I’ve tried to convert the DWG to middle line and placing the wall by core. I first extracted the points and then tried to find the middle of the nearest points. Yet I haven’t got a clue how i to make the last part work. My plan was when I got the middle points to use the node “bestthroughpoints” after, to get the middle line.
I’ve also thought about converting the Walls in the dwg to a Polygon. But that was even more complex.

In the replies i put the images of my script.