Topography follow the mass/surface

Hallo Everyone.

i am trying to make a topography that will follow the outer surface of the generic model(see in the picture 1), so that it looks like excavation. i tried this script but it gives me not the correct result. i want my topo to be around the generic model. Please help what i am doing wrong



Hello if you add a node Flatten before the last node could work, although you could get a message about points