Original G-code lines stored for reference
Metadata extracted from G-code comments, including thumbnails
Parses a single line of G-code into a command object.
Single line of G-code to parse
Whether to preserve comments in the parsed command (default: true)
Parsed GCodeCommand object or null if line is empty/invalid
Parses G-code input into commands and metadata
G-code to parse, either as a string or array of lines
Object containing parsed metadata and commands
Extracts metadata from G-code commands, particularly focusing on thumbnails.
Array of G-code commands containing metadata in comments
Object containing extracted metadata (currently only thumbnails)
This method processes special comments in the G-code that contain metadata. Currently, it focuses on extracting thumbnail data that some slicers embed in the G-code file. The thumbnail data is typically found between 'thumbnail begin' and 'thumbnail end' markers in the comments.
The method handles multi-line thumbnail data by accumulating characters until it encounters the end marker. Once complete, it validates the thumbnail data before storing it in the thumbnails record.
A G-code parser that processes G-code commands and extracts metadata.
Remarks
This parser handles both single-line and multi-line G-code input, extracting commands, parameters, and metadata such as thumbnails. It preserves comments and maintains the original source lines.
Example