Suggestions on how to implement svg's viewbox effect

Have you considered to use a CSG library after generating your shape geometry? There are actually various projects available, see: Looking for Updated plug-in for CSG

I’m not sure this helps but a subtract operation could a possible solution for your issue.