To make solid 3D shapes, it's not usual to try to construct them directly in G-code. Normally, you'd use a 3D CAD modeling program to design the 3D part, then run it through a CAM program to generate the G-code that runs the CNC machine. One nice, simple CAD program is MOI; it's on my site, along with DeskProto, which simplifies the process of generating the G-code.