I use Sprutcam to generate my g-code. Basically, the CAM process is:
1) Import a solid model (usually drawn with a CAD program)
2) Define your operations
2a) Each operation is assigned tools, toolpaths, width of cut, depth of cut, RPM, feed rate, etc...
2b) Some operations like 3d machining are assigned ball end mills and use the bottom and sides of the end mill. This is all calculated using the internal software algorithms - things that would be nearly impossible to do by hand.
3) Post-process ("post") your code. This converts from Sprutcam's internal representation (move to location x,y,z) to your machine's representation (g01 x,y,z). This is where the g-code is actually written for your specific machine controller.
Sample code, as you can see this snippet is from ~28,000 lines of code in:
Code:
(3D Machining)
N28300 T43 G43 H43 M6
(1/4 Ball EM)
N28310 S5100 M3 M8
N28320 G0 X-2.371 Y-0.5632 Z0.05
N28330 Z0.0101
N28340 G1 Z-0.0649 F20
N28350 G2 X-2.3299 Y-0.5515 Z-0.0649 I0.049 J-0.094
N28360 G1 X-1.8999
N28370 G2 X-1.8584 Y-0.5632 Z-0.0649 I-0.0072 J-0.1048
N28380 G1 X-1.8398
N28390 Z-0.0798
N28400 G3 X-1.9007 Y-0.5407 Z-0.0798 I-0.0667 J-0.0868
N28410 G1 X-2.3298
N28420 G3 X-2.3902 Y-0.5632 Z-0.0798 I0.0067 J-0.11
N28430 G1 X-2.406
N28440 Z-0.1
N28450 G2 X-2.3298 Y-0.5294 Z-0.1 I0.0823 J-0.0828
N28460 G1 X-1.8994
N28470 G2 X-1.824 Y-0.5632 Z-0.1 I-0.0077 J-0.1183
N28480 G1 X-1.8143
N28490 Z-0.1202
N28500 G3 X-1.9009 Y-0.5214 Z-0.1202 I-0.0925 J-0.0808
N28510 G1 X-2.3288
N28520 G3 X-2.4157 Y-0.5632 Z-0.1202 I0.0046 J-0.1205
N28530 G1 X-2.4219
...
LOTS more lines of code
...