Coder Social home page Coder Social logo

pyrech / gcode-estimator Goto Github PK

View Code? Open in Web Editor NEW
11.0 1.0 1.0 9.53 MB

Estimate the length/weight/cost of filament used for a 3D print by parsing the gcode file

License: MIT License

PHP 97.10% Makefile 2.90%
3d 3d-printing filament gcode length weight cost

gcode-estimator's Introduction

GcodeEstimator

GcodeEstimator is a PHP library to estimate the length/weight/cost of filament used for a 3D print through the corresponding gcode file.

Requires PHP >= 7.2.

Features

Unlike other implementations, this library supports most of g-code operations commonly used by 3d printers:

  • all kind of moves (rapid, linear, clockwise arc, counter-clockwise arc)
  • absolute and relative positionings
  • switch between absolute/relative modes
  • current position reset
  • millimeter and inche units

Estimations should be quite realist whatever the slicer/printer you use.

Installation

Use Composer to install GcodeEstimator in your project:

composer require "pyrech/gcode-estimator"

Usage

Basic usage to get the length of filament used:

include __DIR__.'/vendor/autoload.php';

use Pyrech\GcodeEstimator\Estimator;

$estimator = new Estimator();
$estimate = $estimator->estimate($absolutePathToGcode);

$estimate->getLength(); // returns the length of filament used (in mm);

You can also estimate the weight and cost of your print by describing the properties of your filament spool:

include __DIR__.'/vendor/autoload.php';

use Pyrech\GcodeEstimator\Estimator;
use Pyrech\GcodeEstimator\Filament;

$filament = new Filament(
    1.75, // filament diameter in mm
    1.24, // filament density in g/cm³
    750,  // weight of the spool in g
    25.99 // price of the spool (whatever your currency)
);

$estimator = new Estimator();
$estimate = $estimator->estimate($absolutePathToGcode, $filament);

$estimate->getLength(); // returns the length of filament used (in mm);
$estimate->getWeight(); // returns the weight of filament used (in g);
$estimate->getCost();   // returns the cost of filament used (in whatever currency you specified);

Further documentation

You can see the current and past versions using one of the following:

And finally some meta documentation:

Credits

License

GcodeEstimator is licensed under the MIT License - see the LICENSE file for details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.