Skip to content

filipe-maia/flatcam

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

624 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlatCAM: 2D Computer-Aided PCB Manufacturing

(c) 2014-2016 Juan Pablo Caram

FlatCAM is a program for preparing CNC jobs for making PCBs on a CNC router. Among other things, it can take a Gerber file generated by your favorite PCB CAD program, and create G-Code for Isolation routing.


All the code in here is a migration of the code found in https://bitbucket.org/jpcgt/flatcam/src/master/ (and http://flatcam.org/) to newer versions of Python and to newer dependencies versions (like PyQt4 to PyQt5).

You can use the version of FlatCAM in here, but it's recommended for you to use the following version of FlatCAM (because it's newer and has more features): https://bitbucket.org/marius_stanciu/flatcam_beta/src/Beta_8.995/


To start this program you need Python installed in your computer (tested with version 3.13.4).

Before starting this program for the first time on your computer, make sure you have all the required Python dependencies by running 'pip install -r requirements.txt' (and, if you are on Windows, 'pip install -r requirements_windows.txt' as well). Tested with NumPy 2.3.0, MatPlotLib 3.10.3, RTree 1.4.0, SciPy 1.15.3, SimpleJson 3.20.1 and svg.path 6.3.

To start this program run 'py flatcam' or 'python flatcam'.

If you are using Windows, you can use FlatCAM.bat.

NOTE: To use FlatCAM in an O.S. different from win64, delete the three folders of Shapely inside FlatCAM folder ("shapely", "Shapely.libs" and "Shapely-1.8.5.dist-info"), then (if 'pip install shapely==1.8.5' fails) download Shapely 1.8.5 for the O.S. where you plan to run FlatCAM and place it inside FlatCAM folder. TODO: remove shapely 1.8.5_win64 from inside project folder and use the one installed by pip with the requirements.txt (uncomment the shapely line in the requirements.txt); migrate to shapely>=2.1.1.


TODO: Remove any mentions to sip and/or filefinder from the requirements.txt if any of them are not required.

TODO:

[DEBUG][MainThread] Radio toggled
[WARNING][MainThread] Tried to set an option or field that does not exist: use_buffer_for_union
[DEBUG][MainThread] on_generatecutout_button_click--> FlatCAMObj.read_form()
[WARNING][MainThread] Failed to read option from field: use_buffer_for_union
[DEBUG][MainThread] on_iso_button_click--> FlatCAMObj.read_form()
[WARNING][MainThread] Failed to read option from field: use_buffer_for_union
[DEBUG][MainThread] build_ui--> FlatCAMObj.to_form()
[WARNING][MainThread] Tried to set an option or field that does not exist: coordinate_format
[DEBUG][MainThread] on_exportgcode_button_click--> FlatCAMObj.read_form()
[WARNING][MainThread] Failed to read option from field: coordinate_format
...
[DEBUG] {'type': 'C', 'size': 2.286}
[DEBUG] Line 608: Aperture change to (29)
[DEBUG] {'type': 'C', 'size': 1.27}
[DEBUG] {'type': 'C', 'size': 1.27}
[WARNING] Joining 213 polygons.
[DEBUG] Union by buffer...
[WARNING] Union(buffer) done.
[DEBUG][Dummy-2] 0.241575 seconds executing initialize().
[DEBUG][MainThread] on_auto_offset_button_click--> FlatCAMObj.read_form()
[WARNING][MainThread] Failed to read option from field: zeros
[DEBUG][MainThread] build_ui--> FlatCAMObj.to_form()
[WARNING][MainThread] Tried to set an option or field that does not exist: zeros
[DEBUG][MainThread] on_generate_milling_button_click--> FlatCAMObj.read_form()
[WARNING][MainThread] Failed to read option from field: zeros
[DEBUG][Dummy-40] set_active --> OC.get_names()
QObject::connect: Cannot queue arguments of type 'QItemSelection'
(Make sure 'QItemSelection' is registered using qRegisterMetaType().)
QObject::connect: Cannot queue arguments of type 'QItemSelection'
(Make sure 'QItemSelection' is registered using qRegisterMetaType().)

TODO: Warning shown when using versions 1.8.x of shapely instead of versions 2.x:

[DEBUG][MainThread] plot --> FlatCAMObj.plot()
C:\flatcam\descartes\patch.py:66: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  return PathPatch(PolygonPath(polygon), **kwargs)

TODO: For example, after generating G-Code from an Excellon file, if after that a Gerber file is opened (with shapely version inferior to 2), at least once this error happened (maybe related to the TODO 'warning shown when using versions 1.8.x of shapely instead of versions 2.x'):

[DEBUG][MainThread] plot --> FlatCAMObj.plot()
Traceback (most recent call last):
  File "C:\flatcam\FlatCAMApp.py", line 1591, in on_object_created
    obj.plot()
    ~~~~~~~~^^
  File "C:\flatcam\FlatCAMObj.py", line 653, in plot
    patch = PolygonPatch(poly,
                         facecolor="#BBF268",
                         edgecolor="#006E20",
                         alpha=0.75,
                         zorder=2)
  File "C:\flatcam\descartes\patch.py", line 66, in PolygonPatch
    return PathPatch(PolygonPath(polygon), **kwargs)
                     ~~~~~~~~~~~^^^^^^^^^
  File "C:\flatcam\descartes\patch.py", line 44, in PolygonPath
    [asarray(this.exterior)]
             ^^^^^^^^^^^^^
  File "C:\flatcam\descartes\patch.py", line 22, in exterior
    or self.context['coordinates'][0])
       ~~~~~~~~~~~~^^^^^^^^^^^^^^^
TypeError: 'Polygon' object is not subs

TODO: If using shapely 2.1.1, while opening a Gerber file (maybe related to the TODO 'warning shown when using versions 1.8.x of shapely instead of versions 2.x'):

[DEBUG][MainThread] plot --> FlatCAMObj.plot()
Traceback (most recent call last):
  File "C:\flatcam\FlatCAMApp.py", line 1591, in on_object_created
    obj.plot()
    ~~~~~~~~^^
  File "C:\flatcam\FlatCAMObj.py", line 653, in plot
    patch = PolygonPatch(poly,
                         facecolor="#BBF268",
                         edgecolor="#006E20",
                         alpha=0.75,
                         zorder=2)
  File "C:\flatcam\descartes\patch.py", line 66, in PolygonPatch
    return PathPatch(PolygonPath(polygon), **kwargs)
                     ~~~~~~~~~~~^^^^^^^^^
  File "C:\flatcam\descartes\patch.py", line 43, in PolygonPath
    vertices = concatenate(
                    [asarray(this.exterior)]
                    + [asarray(r) for r in this.interiors])
ValueError: zero-dimensional arrays cannot be concatenated

TODO: This is an older bug and don't know if it already solved itself out or not. For example, after clicking on button to generate CNC (this is probably related with the TODO "if using shapely versions 2.x the green areas won't be drawn"):

[DEBUG][MainThread] plot --> FlatCAMObj.plot()
[WARNING][MainThread] A geometry component was not a polygon:
[WARNING][MainThread] MULTIPOLYGON (((...)))

TODO: If using shapely versions 2.x the green areas won't be drawn. This is an older bug and don't know if it already solved itself out or not. This is maybe related with the TODO "for example, after clicking on button to generate CNC".

TODO: This error happens sometimes while starting FlatCAM, but application doesn't seem to bug out, so this is a minor todo.

C:\flatcam>py flatcam
C:\flatcam\FlatCAMApp.py:785: SyntaxWarning: invalid escape sequence '\ '
  escape bracket [ with \  otherwise there is error
C:\flatcam\FlatCAMApp.py:921: SyntaxWarning: invalid escape sequence '\['
  match = re.search("\[([^\]]+)\](.*)", msg)
C:\flatcam\FlatCAMObj.py:748: SyntaxWarning: "is not" with 'str' literal. Did you mean "!="?
  if option is not 'name':
C:\flatcam\camlib.py:1615: SyntaxWarning: invalid escape sequence '\+'
  '?(?=.*I([\+-]?\d+))?(?=.*J([\+-]?\d+))?[XYIJ][^D]*(?:D0([12]))?\*$')
C:\flatcam\camlib.py:2324: SyntaxWarning: "is not" with 'str' literal. Did you mean "!="?
  if self.apertures[current_aperture]["type"] is not "AM":
C:\flatcam\svgparse.py:275: SyntaxWarning: invalid escape sequence '\{'
  kind = re.search('(?:\{.*\})?(.*)$', node.tag).group(1)
C:\flatcam\FlatCAMDraw.py:1019: SyntaxWarning: "is" with 'int' literal. Did you mean "=="?
  if self.active_tool is not None and event.button is 1:
C:\flatcam\ToolTransform.py:267: SyntaxWarning: "is" with 'str' literal. Did you mean "=="?
  if axis is 'X':
C:\flatcam\ToolTransform.py:271: SyntaxWarning: "is" with 'str' literal. Did you mean "=="?
  elif axis is 'Y':
C:\flatcam\ToolTransform.py:308: SyntaxWarning: "is" with 'str' literal. Did you mean "=="?
  if axis is 'X':
C:\flatcam\ToolTransform.py:310: SyntaxWarning: "is" with 'str' literal. Did you mean "=="?
  elif axis is 'Y':
[INFO][MainThread] FlatCAM Starting...

TODO: This error is maybe caused by the migration from pyqt4 to pyqt5 and happens sometimes while starting FlatCAM, and re-starting FlatCAM usually solves this error, so this is a minor bug:

[DEBUG][MainThread] Radio toggled
[INFO][MainThread] Radio type: <class 'PyQt5.QtCore.QThread'>
Traceback (most recent call last):
  File "C:\flatcam\GUIElements.py", line 48, in on_toggle
    if radio.isChecked():
       ^^^^^^^^^^^^^^^
AttributeError: 'QThread' object has no attribute 'isChecked'