Skip to content

Gcode command-line tools, used for handle gcode files

License

Notifications You must be signed in to change notification settings

mauroalderete/gcode-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

46 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

gcode-cli

Gcode command-line tool to transform, validate and parse gcode files

Β 

Β 

Content

Β 

πŸ‘‹ Introducing gcode-cli

gcode-cli is a command-line tool that help you to apply masive operations to your gcode files like skew corrections, translations or chekcsum integrity.

For the moment, this project is in early development phase, so that all version are inestables.

You can take a look to the upcoming features to know more about gode-cli future.

Hey! don't be discouraged, you can help me to carry out this project in many ways, contributing with new features, reporting bugs, sharing in your social networks or supporting with a ⭐

Please, look at Contributing to gcode-cli to choose the way to collaborate that with you feel better.

Install

With go install

The latest main version

go install github.com/mauroalderete/gcode-cli

Or, use the next command to install a specific version

go install github.com/mauroalderete/gcode-cli@v0.4.5

From source code

Clone this repository and open folder in a terminal

git clone https://github.com/mauroalderete/gcode-cli
cd gcode-cli

Prepare to build

go generate

Execute the build

go build

If all goes well, you will have the executable file gcode-cli

Optionally, copy this binary in your binary folder preference.

cp gcode-cli /usr/bin
cp gcode-cli GOPATH/bin

Download binaries

Usage

gcode-cli [command]

gcode-cli makes operations on a source that contains a 3d model written with gcode specifications. This source can come from a file in the filesystem or of stdin passed as a result of another command.

Some subcommands apply a transform operation directly on the content of the source, the result of this can be printed in stdout or a new file.

Other subcommands, instead, generate a summary and although his output only showed on stdout, but can be represented by many formats, usually JSON, YAML or customizable string.ad, generates summary and his output only showed on stdout, but can will be represented by many formats, usually JSON, YAML or customizable string.

Help commands

help

gcode-cli help

Print a help message about any command

version

gcode-cli version

Print the version number of gcode-cli

Summary command

describe

gcode-cli describe my-file.gcode --json

Print metadata from gcode source. It allow you get simple info in many formats.

You can use the format flag to pretty-print the text output using a Go template pattern. For example {{.Filename}}\t{{.LinesCount}}\t{{.BlocksCount}}\t{{.Coverage}}%. The fields available are:

  • Filename: Prints the name of [FILE] it is provided. Otherwise only print an empty character
  • LinesCount: Prints lines quantity containing the source, whatever [FILE] either stdin.
  • BlocksCount: Prints the amount of these lines are valid blocks.
  • Coverage: Prints the percentage of the lines that are blocks

Skew subcommands

gcode-cli skew xy [--ratio|radian|degree <float32>] [--output <filename>] my-file.gcode

The skew subcommand allow apply the math operation to skew the model on an specific plane. This is util to fix the skew issue that present an many 3d machine.

Sometimes the assambly of a 3d machine cause that the angle between his axis hasn't 90 degrees. This ocassions to figure will print them twisted, turned or skewed.

To fix this, gcode-cli include the subcommand skew that allows you apply a masive operation math to correct the skew on an specific plane.

Skew on XY plane

gcode-cli skew xy [--ratio|radian|degree <float32>] [--output <filename>] my-file.gcode

If your models print with a skew probably your 3d printer has not had 90 degrees between axis X and axis Y. In this case, you can use the subcommand skew xy to fix your impressions.

The subcommand requires the ratio to fix the model. The ratio can be to indicated through an angle in degrees, an angle in radians or a ratio in millimetres.

To calculate the ratio that you need to apply in the models you can:

  • Print a skew test mdoel to plane XY, for example this or this
  • Align the figure to a carpenter's square (or similar tool). Make sure that the edge of the X-axis side of the print is completely aligned with the edge of the square.
  • Bring the other face of the figure as close as you can to the other face of the square.
  • At this moment, you can observe a space free between the edges of the figure Y axis and the square. This space free can be in the corner of the carpenter's square or in the other extreme.
  • Using a calliper measure the free distance. That is, you need to know how many millimetres on the X axis the figure needs to move so that the separated end can stick to the square.
  • The last data that you need to know is the height of the figure.
  • With these values, you already calculate the ratio following the next formula ratio = height the figure / offset in x axis.
  • If the space free was in the corner of the square, then the ratio is negative, otherwise, it is positive.

To check if the ratio calculated is correct you can:

  • Execute the skew correction command to the model that you used to calculate the skew correction
gcode-cli skew xy --ratio <you value> --output skew-test.gcode my-skew-calibration-model.gcode
  • Print them
  • Check the perpendicular property with a square following the same steps previously described.
  • If the space disappeared, congratulations you can now compensate for the skew of any model you print.
  • Otherwise, repeat the procedure to calculate the ratio until you get the result you are expecting.

πŸš€ Upcomming Features

gcode-cli has all the potential to grow further. Here are some of the upcoming features planned (not in any order),

  • βœ”οΈ Apply skew corrections on ZY plane and XZ plane.
  • βœ”οΈ Files verification.
  • βœ”οΈ Set checksum attribute to improve the integrity of the files.

πŸ”¨ How to Set up gcode-cli for Development?

You set up gcode-cli locally with a few easy steps.

  1. Clone the repository
git clone https://github.com/mauroalderete/gcode-cli
  1. Change the working directory
cd gcode-cli
  1. Restore module
go mod tidy
  1. You can run all unit tests and examples to check it's working
go test ./...
  1. Optionally, if you have godocs installed, You can run a server to access documentation via website at localhost.
GOROOT=$GOPATH godoc -http=localhost:9090

πŸ” Built With

🀝 Contributing to gcode-cli

Any kind of positive contribution is welcome! Please help us to grow by contributing to the project.

If you wish to contribute, you can work on any issue or create one on your own. After adding your code, please send us a Pull Request.

Please read CONTRIBUTING for details on our CODE OF CONDUCT, and the process for submitting pull requests to us.

πŸ™ Support

We all need support and motivation. gcode-cli is not an exception. Please give this project a ⭐ start to encourage and show that you liked it. Don't forget to leave a ⭐ star before you move away.

If you found the app helpful, consider supporting us with a coffee.

Invitame un cafΓ© en cafecito.app