Skip to content
xmarduel edited this page Mar 15, 2023 · 38 revisions

PyCut

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.

By the way,I began to use jsCut because Easel (for beginners too), although free, makes limitations (among others) on the choices of the fonts - which is quite a shame...

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. The toolpaths are calculated with the Shapely library. Shapely had been with no doubt superior than the ClipperLib (used by jsCut) for separating tabs (line/polygon intersection). But moving from ClipperLib to Shapely has been a (very) tough job. This is due to my inexperience but also to the fact that Shapely is, well, difficult to master).

All in all, Shapely is far less forgiving than ClipperLib, but now PyCut is python only code, so hopefully more users can discover (the bugs of) PyCut. When running PyCut, please observe the console output for possible exceptions...

Positive thing about Shapely, this has to be pointed out, is that the programmer has full control over everything, so things can be fixed/improved, so thank you Shapely in all cases.

Hopefully there will be users that will be able to contribute (and fix problems). There is a developper doc for this purpose (TODO)

The excellent things from jsCut are (among others):

  • a great svg viewer, with an API 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-
  • the CAM stuff, based on the Clipper library (simple enough for me)

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

After that

  • Migrating WebGL stuff to "native" python (QtOpenGL) ? well the jsCut stuff is excellent and is actually embedded in PyCut through QWebEngineView
  • or using opencamlib (they say its ok but the GUI has to be done by the client app) TODO

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 svgpathtools 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