Skip to content

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

License

Notifications You must be signed in to change notification settings

tyeth/snapmaker2-gcode-reference

 
 

Repository files navigation

NPM Version NPM DL

GitHub Issues Github Stars CodeQL MIT License

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

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(GRef.MachineTypes.Mill);
// OR
// initalize with a machine type and variant
const gref = new GReference(GRef.MachineTypes.Mill, GRef.Variants.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');

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

TODO

  • Lathe G/M Codes
  • 3D Printer G/M Codes
  • Swiss G/M Codes
  • EDM G/M Codes
  • Laser G/M Codes
  • Variants
  • Export to Markdown
  • Export to HTML

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.

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.

About

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

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%