Skip to content
bitli edited this page Aug 17, 2014 · 1 revision

GCode generation

The GCode generation is quite a large bit of code. As a lot is going on here. Important bits here are:

  1. PathOrderOptimizer: This piece of code needs to solve a TravelingSalesmanProblem. Given a list of polygons/lines it tries to find the best order in which to print them. It currently does this by finding the closest next polygon to print.
  2. Infill: This code generates a group of lines from an area. This is the code that generates the actual infill pattern. There is also a concentric infill function, which is currently not used.
  3. Comb: The combing code is the code that tries to avoid holes when moving around the head without printing. This code also detects when it fails. The final GCode generator uses the combing code while generating the final GCode. So they interact closely.
  4. GCodeExport: The GCode export is a 2 step process. First it collects all the paths for a layer that it needs to print, this includes all moves, prints, extrusion widths. And then it generates the final GCode. This is the only piece of code that has knowledge about GCode, and to generate a different flavour of GCode it will be the only piece that needs adjustment. All volumetric calculations also happen here.

Implementation notes

  • The code generation starts by writing some comments and initial code.
  • The raft is then generated of required
  • Then each layer is generated and written:
    • First the parameters relevant to the layer are initialized
    • Then the code planner is created, then the print support and layer is added to it by addSupportToGCode() and addVolumeLayerToGCode(). The print support can be added before or after the layer.
  • Finally the paths are written to the GCode

TBD

Standard comments in GCode

Clone this wiki locally