Skip to content

Script pygcode crop

Peter Boin edited this page Jul 30, 2017 · 4 revisions

Cropping Script

This script cuts out a portion of a gcode file so it may be executed independently of the rest of the file.

==================
TODO
==================

Example Uses

Cut specific lines

cut out from line 100 to line 199 (inclusive) of the part.gcode file (yielding 100 lines)

$ pygcode-crop part.gcode 100:200

note: 200 is the first line excluded from the cropped region

also: the above line is equivalent to:

$ pygcode-crop part.gcode =100:=200
$ pygcode-crop part.gcode n=100:n=200

where n is the file's line number

Resume from depth

Let's say you have a pocket operation, but you had to stop it half way through (at a depth of 3.2mm). you can resume it by cropping out everything before Z reached -3.2mm

$ pygcode-crop pocket.gcode "z<=-3.2:"

note: as soon as < or > characters are used in the conditions, the range parameter must be expressed inside " quotes.

Only middle part

Or you're engraving 3 words stacked on top of each other, but you only want to engrave the middle word. The space between the top 2 words centres at y=3mm, and between the bottom 2 words is at y=6mm.

$ pygcode-crop engraving.gcode "y>3:y>6"

Multiple Conditions

You can also separate multiple conditions with ,s, they're all anded together. So in the engraving example, if you have 2 sets of 3 words:

Jane              foo
loves              bar
 John               roo

engraved in the order Jane, loves, John, foo, bar, and lastly roo. And the blank region in between engravings centres around x~=10

to just engrave bar you can crop it out with:

$ pygcode-crop engraving.gcode "x>10,y>3:y>6"

Clone this wiki locally