I must say that, at my age, I have a very hard time trying to conceptually understand How a computer can make a gun. Just don’t get it!
Imagine a flat steel plate, spread it with a very thin layer of powdered metal.
Heat ‘em up to just below the melting point.
Scan the powder with a laser to get it hot enough to melt and fuse it into a solid.
Spread another thin layer of powder on top, weld that to the first layer, and repeat hundreds or even thousands of times...
Any object can be described in a series of dots. So if you remember your 3 dimensional drawings, there is the location of the dot (x,y,z), the size of the dot (think fractions of mm) and then there is the material at that location (plastic, metal, etc). 3d printing or more specifically, additive manufacturing, is done by first selecting the material called a filament. This is fed to the “print head” where it is deformed with heat (melted) and a tiny dot (more likely a stream) is pushed out the nozzle. The material is hot enough so that it creates a fused bond with the prior layer.
What we need now are directions for the head. These are the X,Y,Z coordinates. To accomplish this, there is something called Gcode. This is a simplistic mechanical program that says go to 1.1.1 and extrude a dot and move to 1.2.1 (move sideways on the Y axis). Gcode is translated by the computer into a series of steps or electrical pulses that are sent to the stepper motors that move the head.
To create the directions (Gcode), you need a software tool called a slicer and you need a 3d image of the objection. The slicer assembles all the gcode for a single layer (z axis) into one series of linked movements of the head. Then it will increment the z axis and execute the instructions for the next layer. This process is repeated until the entire set of dots have been extruded.
There are other considerations regarding materials, extrusion temperatures, overhangs, dual filaments, etc. But that is the basics of how it works.
Ultimately, if you have a file that describes the object to be printed, you then run it through your slicer and then load the filament and gcode into your printer, press start ..... and then wait.