Level terrain under any GameObject

All is said in the subject…

I need to write a C# script which alters (flats) terrainData under a GameObject. How can I compute the footprint of the GameObject and change heights accordingly ?

You could put a box collider around your object and get the size of the box collider, then figure out which vertices are underneath that collider and drop their height.