Git Product home page Git Product logo

snapmaker2postprocessor's Introduction

Snapmaker2Postprocessor

Overview

This project provides a postprocessor for the Path Workbench of FreeCAD compatible with the CNC module of Snapmaker 2.0 (and possibly newer) machines.

It converts FreeCAD internal GCODE generated by the Path Workbench into GCODE suitable for Snapmaker 2.0 machines. Its functions cover:

  • Snapmaker CNC commands
  • tool change between operations (by inserting a HMI pause (M76))
  • drilling (by converting G81-G83 commands)
  • thumbnail generation for HMI
  • rapid moves (speed is not added by FreeCAD to GCODE)

Usage

Move the Snapmaker_2_CNC_post.py file to the FreeCAD macros directory. It should appear within the list of postprocessors of the Path workbench.

Check the wiki if you need more information.

Refer to FreeCAD documentation on how to use a postprocessor.

Limitations

This postprocessor has been tested on FreeCAD 0.20, 0.21 and 0.22 shipped with python3.8+. Generated GCODE should work on any Snapmaker 2 and newer machine, but has only been tested on the following ones:

  • A350
  • A250
  • Artisan

No warranty of any kind is provided, so be cautious as you use this postprocessor at your own risks. If you encounter any bug, please open an issue.

Credits

Parts of this postprocessor have been inspired by the Marlin postprocessor shipped along with FreeCAD.

License

This repository and its content are licensed under the EUPL-1.2-or-later.

Check https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12

This license is deemed to be compatible with the one used by FreeCAD.

snapmaker2postprocessor's People

Contributors

clsergent avatar itmaze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

snapmaker2postprocessor's Issues

Problem with hanging freecad build 0.21.2 (linux)

Hi, I have been running into an issue with this on freecad build 0.21.2 where the system hangs when using the post processor, i have tried to diagnose it myself but unfortunately there is no output on the python console in freecad or the freecad console itself, is this something you can look into?

it looks like the system is trying to do something as i can see CPU and memory allocation so i'm not if its stuck in a loop, also im not a freecad pro so maybe its something im doing incorrectly, do i need to add further arguements to the post processor in freecad? i have seen in the file you have one for the artisan which is what i have so i set that as the machine

Thank you

Feature Request: Boundary Checking

Whilst post processing the G-Code from FreeCAD it should be possible to track the movements in the various axes to determine if they exceed the physical dimensions of the Snapmaker for which the G-Code is intended.

Things that will need to be considered:

  • There's likely no origin defined
  • Each Snapmaker model has different dimensions
  • The stops on the device are soft stops by default, but they can be disabled for a larger work area
  • It probably needs to take the form of an alert rather than an error, along the lines of: "It appears that your model exceeds the physical boundaries of your device."
  • It could probably accumulate moves and store them in terns of min and max for each axis. If the difference between these exceeds the device extent, issue a warning.
  • Bezier and other curves will need to be accommodated, since even if Snapmaker G-Code doesn't support it today, it can be enabled and might be standard at some point.
  • Boundaries might also be configurable to accommodate setups with different requirements.

Cannot import modules on 0.21

Hi,
thanks for making this post! I tried using it on 0.21, but I get
FreeCAD modules could not be imported. Only help is available.

G83 drilling issue

I'm raising this as an issue, but really it's a place to have a discussion. The prompt was a log entry in FreeCAD during PostProcessing: "Command ignored: G83", which turned out to be a drilling operation which was most of the job at hand. I understand that SnapMaker (and Marlin) G-Code does not support G83 and that's fine, but it raised this issue.

I was using my A350 in CNC "mode", but I also want to be able to post process Laser and 3D printing from within FreeCAD.

I understand that each mode has specific requirements and I wondered if there is value in creating three separate post processing modules, one for each mode. Perhaps it should be per module, differentiating between the 1600 mW and 10 W laser and the Single vs Dual-Extruder, perhaps take into account the 4th axis rotary module, etc.

The point being that making a single Post Processor that handles all this seems less than ideal.

In addition, there is no reason that I can think that a G-Code like G83 can't be replaced by a few lines of G-Code and thus adding G83 support to the hardware. Note that G83 is just an example. You're alreading replacing unsupported tool changes with a pause, so this idea is already happening.

I understand that this is a non-trivial process. I'm a 40-year software development professional, but my journey into SnapMaker and G-Code is still very young.

I realise that "patches welcome" is a perfectly valid response, but I'm hoping to learn if this is worthwhile before digging in too deep.

Kind regards,
Onno

Error with version 0.20.2

Hi
Thanks a lot for your work. I just found your repositiory and tried it with the actual Version 0.20.2 27.12.2022

here are my versions

`
OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.2.29603 (Git)
Build type: Release
Branch: (HEAD detached at 0.20.2)
Hash: 930dd9a76203a3260b1e6256c70c1c3cad8c5cb8
Python 3.10.8, Qt 5.15.4, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
Locale: German/Germany (de_DE)
Installed mods:

  • LCInterlocking
    `

I got this error messages:
`
16:21:19 post: Snapmaker2(D:/OneDrives/OneDrive - La Gondola Barocca/_PCBüroLustheim/Eigene Dateien/CAD, Designer, Publisher/_CNC-Fräsungen/Vakuumplatte/vakuumplatte200x200.clsergentSnapmaker.cnc, )
16:21:19 Running the Python command 'Path_Post' failed:
Traceback (most recent call last):
File "C:\Program Files\FreeCAD\FreeCAD_0.20.2-2022-12-27-conda-Windows-x86_64-py310\Mod\Path\PathScripts\PathPost.py", line 437, in Activated
(fail, rc, filename) = self.exportObjectsWith(slist, job)
File "C:\Program Files\FreeCAD\FreeCAD_0.20.2-2022-12-27-conda-Windows-x86_64-py310\Mod\Path\PathScripts\PathPost.py", line 216, in exportObjectsWith
gcode = processor.export(objs, filename, postArgs)
File "C:\Program Files\FreeCAD\FreeCAD_0.20.2-2022-12-27-conda-Windows-x86_64-py310\Mod\Path\PathScripts\PathPostProcessor.py", line 105, in export
return self.script.export(obj, filename, args)
File "C:\Program Files/FreeCAD/FreeCAD_0.20.2-2022-12-27-conda-Windows-x86_64-py310/Mod/Path/PathScripts/post\Snapmaker2_post.py", line 640, in export
post.export(objects, filename, argstring)
File "C:\Program Files/FreeCAD/FreeCAD_0.20.2-2022-12-27-conda-Windows-x86_64-py310/Mod/Path/PathScripts/post\Snapmaker2_post.py", line 546, in export
if self.conf.thumbnail and (thumbnail := getThumbnail(self.job)):
File "C:\Program Files/FreeCAD/FreeCAD_0.20.2-2022-12-27-conda-Windows-x86_64-py310/Mod/Path/PathScripts/post\Snapmaker2_post.py", line 109, in getThumbnail
for model in job.Model.Group:

'NoneType' object has no attribute 'Model'
`

Thanks for having a lot at this.

Josef

Error in parse_args after starting the postprocessor - FreeCAD 0.21.2

Hello!
I wanted to use the postprocessor again with the current freeCAD version 0.21.2. Unfortunately I get an error message again

FreeCAD installation:

OS: Windows 11 build 22631
Word size of FreeCAD: 64-bit
Version: 0.21.2.33771 (Git)
Build type: Release
Branch: releases/FreeCAD-0-21
Hash: b9bfa5c5507506e4515816414cd27f4851d00489
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.3
Locale: German/Germany (de_DE)
Installed mods: 
  * A2plus 0.4.60n
  * Help 1.0.3
  * InventorLoader 1.3.0
  * LCInterlocking
  * sheetmetal 0.2.63

my Path workflow

- current version of Snapmaker_2_CNC_post.py copied to the directory 
`C:\Users\Sepp\AppData\Local\Programs\FreeCAD 0.21\Mod\Path\Path\Post\scripts`
- Started FreeCAD 0.21.2
- Opened file with some ShapeStrings
- Path Workbench called up
- New job created with one Shapestrings selected
- Changed output to this postprocessor with option --no-thumbnail

Then I get the following errors

post: Snapmaker_2_CNC(D:\OneDrives\OneDrive - La Gondola Barocca\_PCBüroLustheim\Eigene Dateien\CAD, Designer, Publisher.nc, --no-thumbnail)
09:47:57  Post Processor: Snapmaker_2_CNC_post
09:47:57  Postprocessing...
09:47:57  Running the Python command 'Path_Post' failed:
Traceback (most recent call last):
  File "C:\Users\Sepp\AppData\Local\Programs\FreeCAD 0.21\Mod\Path\Path\Post\Command.py", line 583, in Activated
    result, gcode, name = self.exportObjectsWith(sublist, partname, job, idx)
  File "C:\Users\Sepp\AppData\Local\Programs\FreeCAD 0.21\Mod\Path\Path\Post\Command.py", line 518, in exportObjectsWith
    gcode = processor.export(objs, filename, postArgs)
  File "C:\Users\Sepp\AppData\Local\Programs\FreeCAD 0.21\Mod\Path\Path\Post\Processor.py", line 80, in export
    return self.script.export(obj, filename, args)
  File "C:\Users/Sepp/AppData/Local/Programs/FreeCAD 0.21/Mod/Path/Path/Post/scripts\Snapmaker_2_CNC_post.py", line 749, in export
    return post.export(objects, filename, argstring)
  File "C:\Users/Sepp/AppData/Local/Programs/FreeCAD 0.21/Mod/Path/Path/Post/scripts\Snapmaker_2_CNC_post.py", line 625, in export
    self.configure(*shlex.split(argstring))
  File "C:\Users/Sepp/AppData/Local/Programs/FreeCAD 0.21/Mod/Path/Path/Post/scripts\Snapmaker_2_CNC_post.py", line 437, in configure
    self.conf = parser.parse_args(args=args)
  File "C:\Users\Sepp\AppData\Local\Programs\FreeCAD 0.21\bin\lib\argparse.py", line 1768, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "C:\Users\Sepp\AppData\Local\Programs\FreeCAD 0.21\bin\lib\argparse.py", line 1800, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "C:\Users\Sepp\AppData\Local\Programs\FreeCAD 0.21\bin\lib\argparse.py", line 2006, in _parse_known_args
    start_index = consume_optional(start_index)
  File "C:\Users\Sepp\AppData\Local\Programs\FreeCAD 0.21\bin\lib\argparse.py", line 1946, in consume_optional
    take_action(action, args, option_string)
  File "C:\Users\Sepp\AppData\Local\Programs\FreeCAD 0.21\bin\lib\argparse.py", line 1874, in take_action
    action(self, namespace, argument_values, option_string)
  File "C:\Users\Sepp\AppData\Local\Programs\FreeCAD 0.21\bin\lib\argparse.py", line 1045, in __call__
  
0

Errors as soon as I select this postprocessor

Hi,
I have already used this postprocessor successfully in an earlier version of FreeCAD and was very satisfied. After some FreeCAD updates I wanted to create the next CNC job for Snapmaker. Unfortunately, I am now getting error messages again.

FreeCAD installation:
OS: Windows 11 build 22621
Word size of FreeCAD: 64-bit
Version: 0.21.1.33668 +26 (Git)
Build type: Release
Branch: (HEAD detached at 0.21.1)
Hash: f6708547a9bb3f71a4aaade12109f511a72c207c
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.3
Locale: German/Germany (de_DE)
Installed mods:

  • A2plus 0.4.60n
  • Help 1.0.3
  • InventorLoader 1.3.0
  • LCInterlocking
  • sheetmetal 0.2.63

Postprocessor installation:

  • current version of Snapmaker_2_CNC_post.py copied to the directory
    C:\Users\Sepp\AppData\Local\Programs\FreeCAD 0.21\Mod\Path\Path\Post\scripts
  • Started FreeCAD 0.21.1
  • Opened file with some ShapeStrings
  • Path Workbench called up
  • New job created, Shapestrings selected
  • Changed output to this postprocessor

Then I get the following errors

09:30:13 Traceback (most recent call last): File "C:\Users\Sepp\AppData\Local\Programs\FreeCAD 0.21\Mod\Path\Path\Main\Job.py", line 552, in onChanged processor = PostProcessor.load(obj.PostProcessor) File "C:\Users\Sepp\AppData\Local\Programs\FreeCAD 0.21\Mod\Path\Path\Post\Processor.py", line 47, in load exec("import %s as current_post" % postname, namespace) File "<string>", line 1, in <module> File "C:\Users\Sepp\AppData\Local\Programs\FreeCAD 0.21\bin\Lib\site-packages\shiboken2\files.dir\shibokensupport\__feature__.py", line 142, in _import return original_import(name, *args, **kwargs) File "C:\Users/Sepp/AppData/Local/Programs/FreeCAD 0.21/Mod/Path/Path/Post/scripts\Snapmaker_2_CNC_post.py", line 197, in <module> class Command: File "C:\Users/Sepp/AppData/Local/Programs/FreeCAD 0.21/Mod/Path/Path/Post/scripts\Snapmaker_2_CNC_post.py", line 216, in Command def addParameter(self, parameter, value: str | int | float = ''): <class 'TypeError'>: unsupported operand type(s) for |: 'type' and 'type'

Crash when model is supplied on FreeCAD command line

In trouble-shooting #3 I discovered that if you supply the filename on the command line to launch FreeCAD (freecad top_plate.FCStd), the post processor crashes with the following error:

11:37:36  post: SnapMaker_A350_CNC(/home/onno/Documents/20230117.mounting-plate/top_plate.cnc, --no-thumbnail)
11:37:36  usage: snapmaker2_post [-h] [--header] [--no-header] [--comments] [--no-comments] [--comment-symbols COMMENT_SYMBOLS COMMENT_SYMBOLS] [--thumbnail]
                       [--no-thumbnail] [--line-numbers] [--no-line-numbers] [--line-start LINE_START] [--line-increment LINE_INCREMENT] [--remove-duplicates]
                       [--keep-duplicates] [--show-editor] [--no-show-editor] [--precision PRECISION] [--pause {M25,M76}] [--units {mm,in}] [--preamble PREAMBLE]
                       [--postamble POSTAMBLE] [--pre-operation PRE_OPERATION] [--post-operation POST_OPERATION] [--translate-drill-cycles]
                       [--no-translate-drill-cycles] [--tool-change [TOOL_CHANGE]] [--no-tool-change] [--tool-number] [--no-tool-number]
                       [--spindle-wait SPINDLE_WAIT] [--spacer SPACER] [--commands COMMANDS [COMMANDS ...]] [--final-position FINAL_POSITION]
11:37:36  snapmaker2_post: error: unrecognized arguments: top_plate.FCStd
11:37:36  Running the Python command 'Path_Post' failed:
Traceback (most recent call last):
  File "/tmp/.mount_freecavrWwC4/usr/Mod/Path/PathScripts/PathPost.py", line 437, in Activated
    (fail, rc, filename) = self.exportObjectsWith(slist, job)
  File "/tmp/.mount_freecavrWwC4/usr/Mod/Path/PathScripts/PathPost.py", line 216, in exportObjectsWith
    gcode = processor.export(objs, filename, postArgs)
  File "/tmp/.mount_freecavrWwC4/usr/Mod/Path/PathScripts/PathPostProcessor.py", line 105, in export
    return self.script.export(obj, filename, args)
  File "/home/onno/.FreeCAD/Macro/SnapMaker_A350_CNC_post.py", line 641, in export
    post = Postprocessor()
  File "/home/onno/.FreeCAD/Macro/SnapMaker_A350_CNC_post.py", line 306, in __init__
    self.configure()
  File "/home/onno/.FreeCAD/Macro/SnapMaker_A350_CNC_post.py", line 385, in configure
    self.conf = parser.parse_args(*args)
  File "/tmp/.mount_freecavrWwC4/usr/lib/python3.10/argparse.py", line 1829, in parse_args
    self.error(msg % ' '.join(argv))
  File "/tmp/.mount_freecavrWwC4/usr/lib/python3.10/argparse.py", line 2583, in error
    self.exit(2, _('%(prog)s: error: %(message)s\n') % args)
  File "/tmp/.mount_freecavrWwC4/usr/lib/python3.10/argparse.py", line 2570, in exit
    _sys.exit(status)

2

This error does not occur if the file is opened from within FreeCAD. The output file is set to top_plate.cnc.

Note that I've renamed the post processor on my system to SnapMaker_A350_CNC_post.py, this is the same file as Snapmaker2_post.py.

Multiplatform Support

Following @ITmaze suggestion, I open this discussion. Per his own words:

I'm raising this as an issue, but really it's a place to have a discussion. The prompt was a log entry in FreeCAD during PostProcessing: "Command ignored: G83", which turned out to be a drilling operation which was most of the job at hand. I understand that SnapMaker (and Marlin) G-Code does not support G83 and that's fine, but it raised this issue.

I was using my A350 in CNC "mode", but I also want to be able to post process Laser and 3D printing from within FreeCAD.

I understand that each mode has specific requirements and I wondered if there is value in creating three separate post processing modules, one for each mode. Perhaps it should be per module, differentiating between the 1600 mW and 10 W laser and the Single vs Dual-Extruder, perhaps take into account the 4th axis rotary module, etc.

The point being that making a single Post Processor that handles all this seems less than ideal.

In addition, there is no reason that I can think that a G-Code like G83 can't be replaced by a few lines of G-Code and thus adding G83 support to the hardware. Note that G83 is just an example. You're alreading replacing unsupported tool changes with a pause, so this idea is already happening.

I understand that this is a non-trivial process. I'm a 40-year software development professional, but my journey into SnapMaker and G-Code is still very young.

I realise that "patches welcome" is a perfectly valid response, but I'm hoping to learn if this is worthwhile before digging in too deep.

Kind regards, Onno

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.