Upload a copy of your script and model:
I would just have all your surfaces in a tree and use the normal vector to direct it outside.