gcode-preview - v3.0.0-alpha.3
    Preparing search index...

    Class Interpreter

    Interprets and executes G-code commands, updating the job state accordingly

    This class handles the execution of G-code commands, translating them into movements and state changes in the print job. It supports common G-code commands including linear moves (G0/G1), arcs (G2/G3), unit changes (G20/G21), and tool selection.

    Indexable

    • [key: string]: (...args: unknown[]) => unknown
    Index

    Constructors

    Properties

    deretractions: number = 0
    extrusionDistance: number = 0
    feedrateChanges: number = 0
    g1: (command: GCodeCommand, job: Job) => void = ...

    Type declaration

      • (command: GCodeCommand, job: Job): void
      • Executes a linear move command (G0/G1)

        Parameters

        • command: GCodeCommand

          GCodeCommand containing move parameters

        • job: Job

          Job instance to update

        Returns void

        Handles both rapid moves (G0) and linear moves (G1). Updates the job state and adds points to the current path based on the command parameters. G0 is for rapid moves (non-extrusion), G1 is for linear moves (with optional extrusion).

    g3: (command: GCodeCommand, job: Job) => void = ...

    Type declaration

      • (command: GCodeCommand, job: Job): void
      • Executes an arc move command (G2/G3)

        Parameters

        • command: GCodeCommand

          GCodeCommand containing arc parameters

        • job: Job

          Job instance to update

        Returns void

        Handles both clockwise (G2) and counter-clockwise (G3) arc moves. Supports both I/J center offset and R radius modes. Calculates intermediate points along the arc and updates the job state accordingly. G2 is for clockwise arcs, G3 is for counter-clockwise arcs.

    others: number = 0
    points: number = 0
    retractions: number = 0

    Methods

    • Executes an array of G-code commands, updating the provided job

      Parameters

      • commands: GCodeCommand[]

        Array of GCodeCommand objects to execute

      • job: Job = ...

        Job instance to update (default: new Job)

      Returns Job

      The updated job instance

    • Executes a linear move command (G0/G1)

      Parameters

      • command: GCodeCommand

        GCodeCommand containing move parameters

      • job: Job

        Job instance to update

      Returns void

      Handles both rapid moves (G0) and linear moves (G1). Updates the job state and adds points to the current path based on the command parameters. G0 is for rapid moves (non-extrusion), G1 is for linear moves (with optional extrusion).

    • Executes an arc move command (G2/G3)

      Parameters

      • command: GCodeCommand

        GCodeCommand containing arc parameters

      • job: Job

        Job instance to update

      Returns void

      Handles both clockwise (G2) and counter-clockwise (G3) arc moves. Supports both I/J center offset and R radius modes. Calculates intermediate points along the arc and updates the job state accordingly. G2 is for clockwise arcs, G3 is for counter-clockwise arcs.

    • Executes a G28 homing command

      Parameters

      • command: GCodeCommand

        GCodeCommand containing the command

      • job: Job

        Job instance to update

      Returns void

      Moves all axes to their home positions (0,0,0) and updates the job state.

    • Selects tool 0 (T0)

      Parameters

      • command: GCodeCommand

        GCodeCommand containing the command

      • job: Job

        Job instance to update

      Returns void

      Updates the job state to use tool 0. Tools are typically used for multi-extruder setups or different print heads.

    • Selects tool 1 (T1)

      Parameters

      • command: GCodeCommand

        GCodeCommand containing the command

      • job: Job

        Job instance to update

      Returns void

      Updates the job state to use tool 1. Tools are typically used for multi-extruder setups or different print heads.

    • Selects tool 2 (T2)

      Parameters

      • command: GCodeCommand

        GCodeCommand containing the command

      • job: Job

        Job instance to update

      Returns void

      Updates the job state to use tool 2. Tools are typically used for multi-extruder setups or different print heads.

    • Selects tool 3 (T3)

      Parameters

      • command: GCodeCommand

        GCodeCommand containing the command

      • job: Job

        Job instance to update

      Returns void

      Updates the job state to use tool 3. Tools are typically used for multi-extruder setups or different print heads.

    • Selects tool 4 (T4)

      Parameters

      • command: GCodeCommand

        GCodeCommand containing the command

      • job: Job

        Job instance to update

      Returns void

      Updates the job state to use tool 4. Tools are typically used for multi-extruder setups or different print heads.

    • Selects tool 5 (T5)

      Parameters

      • command: GCodeCommand

        GCodeCommand containing the command

      • job: Job

        Job instance to update

      Returns void

      Updates the job state to use tool 5. Tools are typically used for multi-extruder setups or different print heads.

    • Selects tool 6 (T6)

      Parameters

      • command: GCodeCommand

        GCodeCommand containing the command

      • job: Job

        Job instance to update

      Returns void

      Updates the job state to use tool 6. Tools are typically used for multi-extruder setups or different print heads.

    • Selects tool 7 (T7)

      Parameters

      • command: GCodeCommand

        GCodeCommand containing the command

      • job: Job

        Job instance to update

      Returns void

      Updates the job state to use tool 7. Tools are typically used for multi-extruder setups or different print heads.