Help with Python Script for perovskite lattice (atoms) 3D

Hello,
I am new to the concept of Python scripting for blender.
I have a script that I need to modify in order to generate a 3D structure of the following. (I could do it manually in blender but it is too time-consuming). Any help is highly appreciated. Please note that I am using a MacBook Pro.

So I am trying to create a 3D structure of a Perovsite Lattice of LAO/ STO.

I attached a picture of the general image I want to go for and the python script I have.
Ignore the comment about the graphene in the image. I know how to generate that one.

Here is the script, I just don’t know how to quite modify it to get what I am looking for since I never worked with Python before.


blender-drawlattice-master.zip (123 KB)

Any help is highly appreciated