Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@appliedengdesign/gcode-reference

appliedengdesign151MIT0.0.8TypeScript support: included

Node module to provide descriptions and reference to CNC G-Codes

nodejs, node, typescript, reference, mill, cnc, gcode, lathe, milling, turning, appliedengdesign

readme

NPM Version NPM DL GitHub Issues Github Stars MIT License

CodeQL Node.js CI

Follow @appliedengdesign

G-Code Reference

This project aims to provide a JSON-backed reference to the G & M codes associated with CNC mills, lathes, 3D printers and more. This project was created to be consumed by our VSCode G-Code Syntax extension for hover information, but we think it can be of use for many different applications.

Goals

Since this is still in very early stages of development, here are the goals outlined for the project:

  • JSON Files
    • Provide a comprehensive & accurate source of information on G & M codes for CNC Mills & Lathes, as well as 3D Printers.
  • Provide an API to be consumed by Typescript / Javascript / Node applications to retrieve the information.
  • Ability to generate full pages of information in HTML or Markdown.
  • Act as a single reseource via GitHub pages for all to read the documentation
  • Provide a simple interface for contributors to add / modify the reference JSON.

Install

To install the latest version:

npm install @appliedengdesign/gcode-reference --save

Usage

Try it in the Node.js REPL :)

Javascript:

// Import Everything ESM/Typescript style
import * as GRef from 'gcode-reference';
// OR
const GRef = require('gcode-reference');

const gref = new GReference();
// OR
// initialize with a machine type
const gref = new GReference('mill');
// OR
// initalize with a machine type and variant
const gref = new GReference('mill', 'mazak');

// Get Complete G-Code Object
const gcode = gref.get('G1');

// Get All Codes
const gcode = gref.getAllCodes(CodeTypes.G);

// Get Short Description
const shortDesc = gref.getShortDesc('G1');

// Get Full Description
const desc = gref.getDesc('G1');

// Get Current Machine Type
const type = gref.getType();

// Set Machine Type (Will rebuild reference)
gref.setType(GRef.MachineTypes.Mill);

// Set or Remove a Variant
gref.setVariant(Gref.MachineTypes.Mazak);
gref.removeVariant();

// Check if there is a variant
gref.isVariant();

// Get Parameters for a G/M Code
gref.getParams('G84');

// MARKDOWN GENERATION

// Get Code as Markdown
const codeMarkdown = gref.getCodeAsMarkdown('G1');

// Get All Codes formatted in Markdown
const codesMarkdown = gref.getAllCodesAsMarkdown('gcode');

// HTML GENERATION

// Get Code as HTML (complete w/ head/meta)
const codeHTML = gref.getCodeAsHTML('G1', false);

// Get Code as HTML (partial) - default if true/false not included
const codeHTML = gref.getCodeAsHTML('G1');

// Get All Codes as HTML (partial by default as well)
const codeHTML = gref.getAllCodesAsHTML('G1', false);

// You can also import the types separately / individually when using Typescript
import {
  Categories,
  Category,
  CNCCodes,
  Code,
  CodeType,
  CodeTypes,
  ICode,
  MachineType,
  MachineTypes,
  Parameters,
  Variant,
  Variants,
} from 'gcode-reference';

Machine Types

Supported machine types are edm, mill, lathe, laser, printer or swiss. You can select the machine type using the string variant or use the enum MachineTypes.

Variants

The current supported variants are amada, brother, centroid, citizen, doosan, fadal, fanuc, haas, hurco, mach3, mazak, milltrs, mitsu, okuma, snpmaker and tormach. These are also exposed under the enum Variants.

For more information on creating more variants or requesting them, please check out our Contributing page.

Schema

The schema used for the JSON data is published in the repo cnccodes-json-schema and was created specifically for this project.

Issues

If you find any bugs or issues with the package, please create a new GitHub issue.

Contributing

We Need Your Help

We need people to help add more G & M codes to the various machine tool bases as well as adding variants.

For information on contributing, please refer to the CONTRIBUTING doc for information on how to add to this project.

Contributors

About Applied Eng & Design

We are a full service engineering and design firm, specializing in CAD/CAM, CNC milling, rapid prototyping, training and more. We also like to dabble in Arudino / RaspberryPi projects, electronics, drones and robotics projects! Subscribe to our YouTube channel for videos on our projects, screencast tutorials, and more!

Follow us on Twitter & Instagram, and like our Facebook Page!

License

This extension is licensed under the MIT License.

changelog

Change Log

All changes to the gcode-reference project will be documented here

v0.0.8

New Features

  • Added HTML Generation per code or all codes. Both as partials or complete HTML (including head) #24

Other

  • Updated dependencies
  • Updated README

v0.0.7

New Features

  • Added Markdown generation per code or all codes #21

Other

  • Updated dependencies
  • Fixed dependabot configuration
  • Updated README
  • Updated Mocha tests for markdown generation

v0.0.6

New Features

  • Added Snampmaker2 a350 #4

Other

  • Updated dependencies
  • Added dependabot.yml configuration
  • Moved SECURITY.md into .github
  • Fixed typo in CodeQL badge link
  • Added action to lock closed issues
  • Added CODEOWNERS file
  • Updated .prettierrc with semi and quoteProps
  • Added lint:fix and pretty:fix scripts
  • Added NodeJS Github Actions workflow
  • Removed GitLens configurations
  • Added NodeJS CI badge to README
  • Cleaned up and Prettied code
  • Added Contributors section to README
  • Added recommended VSCode extensions to extensions.json
  • Added prettier use, fixed a typo and added contributors addition to CONTRIBUTING.ms

v0.0.5

New Feaures

  • getCodes script now shows full object depth
  • Variant now able to remove G/M codes

Fixes

  • Refactor types to fit schema better
  • Updated test suite for variants

Other

  • Added more code entries in EDM / Laser / 3D Printer
  • Updated dependencies
  • Added Stale workflow
  • Updated CodeQL workflow
  • CNCCodes JSON Schema updated to v0.3.0 Possible Breaking

v0.0.4

New Features

  • NEW Support for JSON Variant files
  • Added getAllCodes function to GReference class

Fixes

  • Renamed all JSON files to conform to *.cncc.json
  • Changed Mitsubishi & Milltronics variant naming to conform to Schema
  • Refactored type definitions to be cleaner
  • Added util folder and constants export.

Other

  • Updated all dependencies
  • Updated Typescript to ES2021
  • Added Mocha testing w/ JSON Validation
  • Updated Copyright year in license
  • Added CNCCodes JSON Schema dependency (2022-07).
  • Added new scripts for building package
  • Added tests to vscode launch
  • Updated README
  • Updated CONTRIBUTING
  • Added tsconfig.build.json to exclude test and script folders

v0.0.3

Fixes

  • Fixed scripts to include JSON in dist

v0.0.2

Fixes

  • Fixed typo in README
  • Fixed tsconfig.json includes

v0.0.1

  • Initial Version with minimal framework and schema