Skip to content

Javascript class for Generate G code including extrusion calculation

Notifications You must be signed in to change notification settings

SphaeroX/Javascript-G-Code-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 

Repository files navigation

Slicer JavaScript Class

The Slicer class is designed to generate G-code instructions for 3D printing tasks. It provides methods to control movements and extrusion for your printer.

Class Initialization

const slicer = new Slicer(nozzleDiameter, layerHeight, filamentDiameter, movementSpeed, printSpeed, heightSpeed, retractSpeed, retractLength);

Properties

  • nozzleDiameter: Diameter of the printer nozzle.
  • layerHeight: Height of each printed layer.
  • filamentDiameter: Diameter of the filament.
  • movementSpeed: Default movement speed.
  • printSpeed: Default printing speed.
  • heightSpeed: Default height change speed.
  • retractSpeed: Retraction speed.
  • retractLength: Retraction length.
  • extrusionWidth: Width of extrusion.
  • currentPosition: Current position of the printer.
  • eRoundFactor: Rounding factor for extrusion calculations.
  • gcode: Accumulated G-code instructions.

Methods

  • calculateFilamentLength(distance): Calculate filament length based on distance.
  • calculateDistance(x1, y1, x2, y2): Calculate distance between two points.
  • generateExtrusionGcode(x1, y1, x2, y2): Generate G-code for extrusion move.
  • addGcodeLine(gcode, speed): Add a G-code line to the instructions.
  • extrusionMove(x, y, speed): Perform an extrusion move.
  • extrusionMoveTo(x, y, speed): Move to a position with extrusion.
  • extrude(length, speed): Extrude filament.
  • moveZ(z, retract, speed): Move in the Z direction.
  • move(x, y, z, speed): Move in the X, Y, and optionally Z directions.
  • moveTo(x, y, z, speed): Move to a position in the X, Y, and optionally Z directions.
  • retract(e): Perform retraction.
  • unretract(e): Cancel retraction.
  • bedHeat(temp): Heat the bed to the specified temperature.
  • bedHeatWait(temp): Heat the bed and wait.
  • toolHeat(temp): Heat the tool to the specified temperature.
  • toolHeatWait(temp): Heat the tool and wait.
  • setSpeed(speed): Set the movement speed.
  • disableAll(): Disable all components.
  • home(): Home the printer.
  • getGcode(): Get the accumulated G-code instructions.
  • printRectangle(x, y, startDirection, isClockwise): Prints a Rectangle
  • printRectanglefilled(x, y, fillDensity): Prints a filled Rectangle

Example Usage

run the slicer.class.js, above the class is an example

About

Javascript class for Generate G code including extrusion calculation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published