Need help in digital fabrication parametric structure script / joints

I was working on a script that would lead me to this result and I finished it, but in the end I stopped at the problem of interlocking. I want the shape to be hollow in both directions so that the design is stable and strong like the attached picture

What can i do
Is there any script that I can use to reach this result in an easier way?

and this photo from what i made