The above line gives me a single cube (2 lattice points in each direction).
But I want a lattice with 4 lattice points in each direction. How do I generate that?
It is easy to generate coordinates for these using
If you need the grid lines too, you can generate a 2D lattice for each face in a similar way and extrude them into lines.
The comments I got for this post are about speed basically. I improved it greatly because I removed opacity objects (which are nice visually but cause slow down). So let me just show the final result of fast and much more complicated (Tetrahedral) lattice than yours (which means your simple cubic will work too but with a bonus). So get your data
Build extended lattice:
Now, let me go back in time and explain from the very beginning how it works. A brute force approach. Here is a single lattice cell:
Now use Translate:
Even so the method is a bit wasteful (you repeating overlapping spheres), it is very simple and works for much more complicated crystal structures where creating custom grid is tedious - plus the style of lattice data is nice: