Skip to content
xmarduel edited this page Sep 1, 2023 · 38 revisions

Warning: PyCut is still in early stage and rapid development, the software is completely beta (but usable).

PyCut is a clone of jsCut, the excellent (at least for beginners) CAM, web-based programm, that takes as input svg files and generates G-Code. So why this rewrite ?

One reason is: I wanted the spindle control (M3/M5) codes inside the generated g-code. It is worth a rewrite!

So it begins as a "fun" project, in order to understand how a G-code generator works, and how easy (or hard) it is to achieve. Well, it is not so easy (but stealing jsCut code helps). And I learned about jsCut through the CnC Philosophy pages.

So PyCut is written in python, with the GUI with PySide6. Python-3.10 is mandatory because of the new python annotations which are not backwards compatible. Reading/discretization of the SVG paths is done with the svgelement python module. The toolpaths are calculated with the Shapely library.

The excellent things from jsCut are (among others):

  • a great svg viewer, with an API (snap.js) to add svg path(s) to the viewer content:
    • in black the regions of the geometry that will be affected
    • in green the calculated toolpaths
  • a great gcode simulator -in webgl-

So the idea is the following:

  • MainWindow in PySide DONE
  • in PySide, display the SVG viewer stuff (QGraphicsView with SvgItem) DONE (geometry previews, toolpaths, tabs)
  • in PySide, display the WebGL stuff (QWebEngineView) DONE
  • Tool paths generation DONE
  • Tabs handling DONE
  • G-Code generation with spindle control (actually absent in jsCut -wow! what a feature!-) DONE
  • G-Code viewer (as in Candle) DONE
  • G-Code simulation (as in JsCut) DONE

After that

  • using opencamlib / cutsim for gcode simulation ? (but it seems it uses linuxCNC gcode interpreter to eval the path, so maybe linux only) POSTPONED
  • toolpaths calculated with opencamlib ?

Then

It should not be necessary to pass to PyCut svg with only "paths" svg elements. All svg shapes

  • <rect> DONE
  • <circle> DONE
  • <ellipse> DONE
  • <polygon> DONE
  • <line> DONE
  • <polyline> DONE

should be loadable (as well as <path> of course) DONE thanks to svgelements stuff.

  • The <text> elements still have to be exported as path. There is an utility in PyCut (svgtext2svgpath.py) for this which is still experimental and could be integrated into PyCut: IN PROGRESS!
  • Shapes/paths items defined in the defs and used through the <use> tag, with or without transformations ? IN PROGRESS! There is a second utility in PyCut svgresolver.py to resolve these items, which could be integrated right into PyCut transparently to the user.
Clone this wiki locally