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

    Class Job

    Represents a complete print job containing paths, layers, and state

    Manages the collection of paths, organizes them into layers and tools, and tracks the current print state

    Index

    Constructors

    • Creates a new Job instance

      Parameters

      • opts: { minLayerThreshold?: number; state?: State } = {}

        Job options

        • OptionalminLayerThreshold?: number

          Minimum layer height threshold (default: LayersIndexer.DEFAULT_TOLERANCE)

        • Optionalstate?: State

          Initial state (default: State.initial)

      Returns Job

    Properties

    boundingBox: BoundingBox = ...
    inprogressPath: Path

    Current in-progress path

    paths: Path[] = []

    All paths in the job

    state: State

    Current print state

    stats: JobStats = ...

    Statistics accumulated while interpreting the job's G-code

    Accessors

    • get countLayers(): number

      Gets the total number of layers in the job

      Returns number

      Number of layers

    • get extrusions(): Path[]

      Gets all extrusion paths in the job

      Returns Path[]

      Array of extrusion paths

    • get isPlanar(): boolean

      Checks if the job contains planar extrusion layers

      Returns boolean

      True if the job contains at least one layer, false otherwise

    • get metadata(): Metadata

      Gets the slicer metadata (thumbnails, layer metadata, slicer name) for this job

      Returns Metadata

      The metadata, or undefined if none has been set

    • set metadata(metadata: Metadata): void

      Sets the slicer metadata and forwards layer metadata to the layer indexer

      Parameters

      • metadata: Metadata

        Parsed slicer metadata

      Returns void

      Must be set before paths are indexed (i.e. before executing commands) so the layer indexer can use slicer-provided layer boundaries instead of the tolerance-based fallback.

    • get toolPaths(): Path[][]

      Gets paths organized by tool

      Returns Path[][]

      2D array of paths, where each sub-array contains paths for a specific tool

    • get travels(): Path[]

      Gets all travel paths in the job

      Returns Path[]

      Array of travel paths

    Methods

    • Adds a path to the job and indexes it

      Parameters

      • path: Path

        Path to add

      Returns void

    • Finalizes the current in-progress path and starts a new one of the given type

      Parameters

      Returns Path

      The newly created path, seeded with the current position

      Called when a path type change is detected (e.g. switching between travel and extrusion moves).

    • Finalizes the current in-progress path

      Returns void

      If the in-progress path has vertices, it will be added to the job and the in-progress path reference will be cleared

    • Resolves the current state's position for rendering.

      Returns { x: number; y: number; z: number }

      The position as concrete x, y, z numbers

      An axis that has not been homed has an unknown (undefined) position. The job chooses to assume the origin (0) for such axes so the viewer can still render best-effort (see #361); state.isHomed lets a consumer tell these assumed coordinates from real ones.

    • Resumes the last path from the job as the current in-progress path

      Returns void

      Removes the path from all indexes and sets it as the current in-progress path