Wrong CNC job path while using Isolation Tool

Issue #539 open
Maciej Andrzejewski created an issue

When creating CNC job from geometry using Isolation Tool and Tool Offset parameter set to 0,05mm it generates the CNC path wrong.

The path should be offset 0,05mm from the copper but it overlay the copper (left side of the image) like it was set with -0,05mm in some places and in the other places of the gerber it works fine (right side of the image).

Image of wrong path:

The path should look like in this image where all the paths are offset some space from the copper.

I have supplied gerber file as a reference.

Comments (19)

  1. Marius Stanciu

    Hi,

    Versions older than the current one are no longer discussed except in the sense that: “something worked in previous version but no longer work in the current version”.

    Can you please explain what is not working in the current version (version 8.994)?
    I mean, can you give some details on what did you expect and what did you get? Are you using the Isolation Tool? What settings did you used there? And so on.

    Also try to report issues one after another. Perhaps using bullet points so it is clear what we are talking about.

  2. Maciej Andrzejewski reporter

    Hi @Marius Stanciu ,

    I have edited the post.
    Is it more clear now or should I record a screencast?

  3. Marius Stanciu

    Hi,

    Ok, now it is clear. The issue is happening only for “cutouts”, I mean “negative geometry”, holes in a polygon.
    Unfortunately is not that easy to solve. I will see what can be done.

  4. Maciej Andrzejewski reporter

    It is not clear for me why that happen because it is not consistent.

    For example I can generate 3 pass geometry that will produce correct result.
    If I edit the geometry and delete one of the board outline (one of three) and save it then generate output again it is clear that in SOME places there is above negative effect.

    At the moment I have workaround for that: Im generating single pass geometry and the generate 3 pass geometry that substract the first one. So I have two geometry (and finally gcodes): one with single pass and second with pass number 2 and 3.

  5. Maciej Andrzejewski reporter
    1. You point me to separate private repo - how do you merge changes to vanilla?
    2. It is not working. Please use below settings: 3 pass, 0,05mm offset. It will not allow me to create CNC job - Internal error occured:

      Console output:

      ```
      [DEBUG][MainThread] build_ui--> FlatCAMObj.build_ui()
      [DEBUG][MainThread] build_ui--> FlatCAMObj.build_ui()
      [DEBUG][MainThread] build_ui--> FlatCAMObj.build_ui()
      [DEBUG][MainThread] build_ui--> FlatCAMObj.build_ui()
      [DEBUG][MainThread] Generating CNCJob from Geometry ...
      [DEBUG][MainThread] Object OptoCalib.GTL_iso_combined_cnc has been promised.
      [DEBUG][Dummy-4] AppObject.new_object()
      [DEBUG][Dummy-4] Calling object constructor...
      [DEBUG][Dummy-4] Creating CNCJob object...
      [DEBUG][Dummy-4] FlatCAMObj.visible()
      [DEBUG][Dummy-4] 0.064944 seconds before initialize().
      [DEBUG][Dummy-4] Creating a CNCJob out of a multi-geometry
      [DEBUG] geometry_tool_gcode_gen()
      [DEBUG] Using RTree path optimization.
      [DEBUG] 74 paths
      [DEBUG] Indexing geometry before generating G-Code...
      [DEBUG] Starting G-Code...
      [WARNING] Number of paths for which to generate GCode: 74
      [DEBUG] Finished G-Code... 74 paths traced.
      [DEBUG][Dummy-4] New object with name: OptoCalib.GTL_iso_combined_cnc. 0.222710 seconds executing initialize().
      [DEBUG][Dummy-4] camlib.CNCJob.bounds()
      [DEBUG][Dummy-4] Moving new object back to main thread.
      [DEBUG][MainThread] on_object_created()
      [DEBUG][MainThread] on_object_created --> OC.append()
      [DEBUG][MainThread] FlatCAMCNCJob.set_ui()
      [DEBUG][MainThread] set_ui --> FlatCAMObj.to_form()
      [DEBUG][MainThread] FlatCAMCNCJob.gcode_header()
      [DEBUG][MainThread] build_ui--> FlatCAMObj.build_ui()
      [DEBUG][MainThread] CNCJobObject.build_ui()
      [DEBUG][MainThread] build_ui--> FlatCAMObj.build_ui()
      [DEBUG][MainThread] CNCJobObject.build_ui()
      [DEBUG][Dummy-5] plot --> FlatCAMObj.plot()
      [DEBUG][MainThread] build_ui--> FlatCAMObj.build_ui()
      [DEBUG][MainThread] CNCJobObject.build_ui()
      [DEBUG][Dummy-5] 0.352742 seconds adding object and plotting.
      [DEBUG][MainThread] build_ui--> FlatCAMObj.build_ui()
      [DEBUG][MainThread] CNCJobObject.build_ui()
      [DEBUG][MainThread] App.on_delete()
      [DEBUG][MainThread] App.on_delete() --> CNCJob object: OptoCalib.GTL_iso_combined_cnc. 'CNCJobObject' object has no attribute 'probing_shapes'
      [DEBUG][MainThread] App.on_delete()
      [DEBUG][MainThread] build_ui--> FlatCAMObj.build_ui()
      [DEBUG][Dummy-4] ToolIsolation.combined_normal()
      [DEBUG][Dummy-4] AppObject.new_object()
      [DEBUG][Dummy-4] Calling object constructor...
      [DEBUG][Dummy-4] FlatCAMObj.visible()
      [DEBUG][Dummy-4] 0.043260 seconds before initialize().
      [DEBUG][Dummy-4] New object with name: OptoCalib.GTL_iso_combined. 0.000204 seconds executing initialize().
      [DEBUG][Dummy-4] camlib.Geometry.bounds()
      [DEBUG][Dummy-4] Moving new object back to main thread.
      [DEBUG][MainThread] on_object_created()
      [DEBUG][MainThread] on_object_created --> OC.append()
      [DEBUG][MainThread] GeometryObject.set_ui()
      [DEBUG][MainThread] set_ui --> FlatCAMObj.to_form()
      [DEBUG][MainThread] camlib.Geometry.bounds()
      [DEBUG][MainThread] build_ui--> FlatCAMObj.build_ui()
      [DEBUG][MainThread] build_ui--> FlatCAMObj.build_ui()
      [DEBUG][MainThread] build_ui--> FlatCAMObj.build_ui()
      [DEBUG][Dummy-6] plot --> FlatCAMObj.plot()
      [DEBUG][MainThread] build_ui--> FlatCAMObj.build_ui()
      [DEBUG][Dummy-6] 0.138942 seconds adding object and plotting.
      [DEBUG][MainThread] build_ui--> FlatCAMObj.build_ui()
      [DEBUG][MainThread] build_ui--> FlatCAMObj.build_ui()
      [DEBUG][MainThread] Generating CNCJob from Geometry ...
      [DEBUG][MainThread] Object OptoCalib.GTL_iso_combined_cnc has been promised.
      [DEBUG][Dummy-4] AppObject.new_object()
      [DEBUG][Dummy-4] Calling object constructor...
      [DEBUG][Dummy-4] Creating CNCJob object...
      [DEBUG][Dummy-4] FlatCAMObj.visible()
      [DEBUG][Dummy-4] 0.097724 seconds before initialize().
      [DEBUG][Dummy-4] Creating a CNCJob out of a multi-geometry
      [DEBUG] geometry_tool_gcode_gen()
      [DEBUG] Using RTree path optimization.
      [DEBUG] 74 paths

      ```

  6. Maciej Andrzejewski reporter

    Is there any easy way to run your PyQt6 version along PyQt5 libraries installed? I had to uninstall PyQt5 because of this error:
    RuntimeError: Refusing to import PyQt6 because PyQt5.QtCore is already imported.

  7. Marius Stanciu

    Hi,

    It is not working. Please use below settings: 3 pass, 0,05mm offset. It will not allow me to create CNC job - Internal error occured:

    Weird, I can’t reproduce the issue. Later I will make a screen capture to show you how I do it. Make sure you use the latest commit. Also make sure that you open the Tcl Shell window and see the error there.

    Is there any easy way to run your PyQt6 version along PyQt5 libraries installed?

    There is no way to use PyQt5 and PyQt6 frameworks side by side due of the VisPy package.
    BTW, make sure you don’t use VisPy 0.9.1 and 0.9.2. Versions 0.9.0 and 0.9.3 and later are OK from the performance point of view.
    What you can do is to use a Python virtual environment where you install only the PyQt6 package. https://uoa-eresearch.github.io/eresearch-cookbook/recipe/2014/11/26/python-virtual-env/ and the rest of the required packages and run FlatCAM Evo from there.

    You point me to separate private repo - how do you merge changes to vanilla?

    Usually I cherry-pick the PR’s that others may make, implement them in my working copy and when the time come I force push my whole branch over the target one. The contributors are still listed as making those PR’s and are recorded in the Help->About->Programmers page.

  8. Marius Stanciu

    I confirm the reported issue and after investigation found that the root cause was that in the process of geometry generation some of the generated geometry elements were empty which created exceptions.
    I have added a geometry cleaning step and solved the issue in the latest commit on my working copy (https://bitbucket.org/marius_stanciu/flatcam_beta/branch/Beta_8.995).

    LE: Unfortunately, offsetting the path does not guarantee that full isolation can be provided. As you can see in the following picture, a small part could not be processed due of this offset. If no offset is added then the isolation is complete (as it exits from the Isolation Plugin). Modifying the paths create an uncertainty regarding the end result.

  9. Maciej Andrzejewski reporter

    Iv checked that version and it is working fine 🙂
    Great job and fast response!

    Yes I’m aware that small part could not be processed. It is fine for me because I need to work with that offset.

    Off topic question: I have noticed that version 8.994 has different tool database file then the 8.993. Now I found out that version 8.995 has got also a different tool database file because it is empty when I lunch an application?

  10. Marius Stanciu

    Off topic question: I have noticed that version 8.994 has different tool database file then the 8.993. Now I found out that version 8.995 has got also a different tool database file because it is empty when I lunch an application?

    Changes, changes …. I do try to optimize things as much as I can. And the current Tools Database is not to be used, I believe that it needs to be reworked due of the changes I’ve done after 8.994. So are the Tcl commands. Actually versions 8.992, 8.993, 8.994 and 8.995 are transition versions, I actually am trying to depart from FlatCAM philosophy and move to something better (from my point of view).

  11. Maciej Andrzejewski reporter
    • changed status to open

    Same bug on slightly different gerber - CNC job: Internal error occured.
    Im attaching project with gerber and tool database.

    https://drive.google.com/file/d/1hjbTjXhYr1KveC3ABjC3qOvVJ0_aLhbK/view?usp=sharing

    Error console:

    [ERROR] An internal error has occurred. See shell.
Object (cncjob) failed because: 'tools_drill_toolchange' 

Traceback (most recent call last):
 File "/opt/FlatCAM_beta_MariusStanciu/appObjects/AppObject.py", line 168, in new_object
 return_value = initialize(obj, self.app)
 File "/opt/FlatCAM_beta_MariusStanciu/appPlugins/ToolMilling.py", line 3137, in job_init_multi_geometry
 dia_cnc_dict['gcode_parsed'] = new_cncjob_obj.gcode_parse(tool_data=tools_dict[tooluid_key]['data'])
 File "/opt/FlatCAM_beta_MariusStanciu/camlib.py", line 6515, in gcode_parse
 if tool_data["tools_drill_toolchange"] is True:
KeyError: 'tools_drill_toolchange'

  12. Marius Stanciu

    Hi,

    Did you use the Tools Database?
    LE: The Tools Database is not to be used, currently the program has breaking changes which require the Tools Database code to be updated,

  13. Maciej Andrzejewski reporter

    Hi,

    Yes, I have used Tool Database.

    If I won't use it I get same error with offset as before.

    Ill try to make another screencast later this day.

  14. Marius Stanciu

    As I said, Tools Database is defective currently. Using it can create all sort of errors, like you already encountered. It’s work in progress. Keep in mind that this version is not final is just my playground. You may use it and may work today, tomorrow it might not work anymore.

  15. Log in to comment