Generating shapes to fit within a polysurface

Hey there,

I want to fit primitive shapes such as a sphere or a cube within a volume of a closed polysurface. I want to calculate just how big of a sphere or a cube i can fit within the confines of another solid. I want to possibly create a script or definition to auto fit predetermined parts within a specific shape.

Basically looking for some direction as to how i should tackle this any help is greatly appreciated.