Post Processing Error - FreeCAD v0.20

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
SaazyPants
Posts: 10
Joined: Wed Nov 24, 2021 4:07 pm

Post Processing Error - FreeCAD v0.20

Post by SaazyPants »

Afternoon All,

I seem to be having an issue post processing a simple pocket program with the new version of FreeCAD (v0.2).

Code: Select all

OS: KDE Flatpak runtime (GNOME/gnome)
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git)
Build type: Release
Branch: (HEAD detached at 0.20)
Hash: 68e337670e227889217652ddac593c93b5e8dc94
Python 3.9.9, Qt 5.15.5, Coin 4.0.0, Vtk 8.2.0, OCC 7.6.2
Locale: English/United States (en_US)
When proceeding to post process my file, I'm getting the following error:

Code: Select all

20:42:17  snapmaker_freecad_post gcode postprocessor loaded.
20:42:17  snapmaker_freecad_post gcode postprocessor loaded.
20:42:17  Show editor = 1
20:42:17  postprocessing...
20:42:17  Running the Python command 'Path_Post' failed:
Traceback (most recent call last):
  File "/app/freecad/Mod/Path/PathScripts/PathPost.py", line 437, in Activated
    (fail, rc, filename) = self.exportObjectsWith(slist, job)
  File "/app/freecad/Mod/Path/PathScripts/PathPost.py", line 216, in exportObjectsWith
    gcode = processor.export(objs, filename, postArgs)
  File "/app/freecad/Mod/Path/PathScripts/PathPostProcessor.py", line 105, in export
    return self.script.export(obj, filename, args)
  File "/app/freecad/Mod/Path/PathScripts/post/snapmaker_freecad_post.py", line 194, in export
    job = PathUtils.findParentJob(obj)
  File "/app/freecad/Mod/Path/PathScripts/PathUtils.py", line 405, in findParentJob
    for i in obj.InList:

'_TempObject' object has no attribute 'InList'
The post processing fails, meaning no file is generated with G-Code. In order to post and run this particular program on my equipment, I had to switch to an older version of FreeCAD (v0.19), open the file up and run the post processing script.

Code: Select all

OS: EndeavourOS (LeftWM/leftwm)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24415 (Git)
Build type: Release
Branch: makepkg
Hash: 476ecf091941bead59b14e44afa6064d5a66afa3
Python version: 3.10.5
Qt version: 5.15.4
Coin version: 4.0.1
OCC version: 7.5.3
Locale: English/United States (en_US)
Posted fine and ran fine / as expected on the equipment. The current SnapMaker 2.0 post processing file that I'm using does indeed work. I've used it on previous FreeCAD builds without any troubles. Any thoughts as to what is going on here?

Just for reference in case it's helpful, the machine running v0.20's stats are below. I can provide stats if needed for the machine running v0.19.
  • OS: Manjaro Linux x86_64
    Kernel: 5.15.50-1-MANJARO
    DE: GNOME 42.2
    CPU: Intel i5-6500 (4) @ 3.600GHz
    GPU: NVIDIA GeForce GTX 970
    Memory: 3038MiB / 15953MiB
Cheers,
Saazy

Code: Select all

if ($hungry) { eat(); } else { sleep(); }
spanner888
Posts: 327
Joined: Tue May 28, 2019 10:51 am

Re: Post Processing Error - FreeCAD v0.20

Post by spanner888 »

Can you check if this error also occurs on a common 'builtin' postprocessor, such linuxcnc or grbl?

It would also be helpful if you could supply test file & steps that duplicates the error.
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Post Processing Error - FreeCAD v0.20

Post by sliptonic »

And maybe attach the post-processor. I don't think that's one of ours.
SaazyPants
Posts: 10
Joined: Wed Nov 24, 2021 4:07 pm

Re: Post Processing Error - FreeCAD v0.20

Post by SaazyPants »

Evening,

First, my apologies it took so long to respond. I was out of state traveling for work.

I just tried posting this using the FreeCAD included marlin.py post processor and it appears to have posted successfully without error. (I could have sworn I tried this last week and received an error... *shrug*). I've attached the SnapMaker's post file for review that gave the error in the original post. I did test it again this evening and the same error comes up.

The file that I'm working with to test this can be found https://drive.google.com/file/d/1BtiSyc ... sp=sharing. In order to recreate the error:
  1. Copy the attached "snapmaker_freecad_post.py" to your FreeCAD's installations "Post" folder. The exact location will vary based on your distribution and installation method
  2. Open the "Test-Plate-Cut.FCStd" file in FreeCAD and confirm that the "Job" is setup to use the "snapmaker_freecad_post.py" as your post processor by double clicking on "Job" from the tree, navigating to the "Output" tab and selecting the appropriate processor from the drop down menu. Click OK once done.
  3. Select the Path bench and click the Post Process option from the menu.
  4. Select a location and name for your post file and click save
  5. The Report view should now have the error messages as posted and you should not have received any confirmation dialogue with the Gcode for review. Navigating to the selected save location results in no post file being saved.
Let me know if you guys need any further feedback or information. Also excuse the messy-ness of that 3D file, it's a proof of concept file :P

Cheers,
Saazy
Attachments
snapmaker_freecad_post.py
(13.11 KiB) Downloaded 83 times

Code: Select all

if ($hungry) { eat(); } else { sleep(); }
Noku
Posts: 8
Joined: Fri Nov 11, 2022 5:13 pm

Re: Post Processing Error - FreeCAD v0.20

Post by Noku »

Hello,
First time at Freecad forum, asking about snapmaker post processor.
The file above is binary equal with my file (from the snapmaker site).

I using Debian GNU/Linux 11 (bullseye)
The freecads are extracted from appimage (--appimage-extract) and running with NVIDIA parameters for view rendering

In Freecad 28193(Git) it works with no errors (no drill gcode but...)

Code: Select all

22:26:10  This job contains Legacy tools. Legacy tools are deprecated. They will be removed after version 0.20post: snapmaker_freecad(/home/user/3D/CNC02/Sfera_283.gcode, )
22:26:47  snapmaker_freecad_post gcode postprocessor loaded.
22:26:47  snapmaker_freecad_post gcode postprocessor loaded.
22:26:47  Show editor = 1
22:26:47  postprocessing...
22:26:49  done postprocessing.
In Freecad 30922(Git) opens a dialog window for type the folder and name after that, it gives only errors:

Code: Select all

22:28:36  post: snapmaker_freecad(/home/user/3D/CNC02/PartDesignExample021.gcode, )
22:28:36  Running the Python command 'Path_Post' failed:
Traceback (most recent call last):
  File "/home/user/.FreeCAD0.2.1_30922_app_ex/squashfs-root/usr/Mod/Path/Path/Post/Command.py", line 589, in Activated
    result, gcode, name = self.exportObjectsWith(sublist, partname, job, idx)
  File "/home/user/.FreeCAD0.2.1_30922_app_ex/squashfs-root/usr/Mod/Path/Path/Post/Command.py", line 523, in exportObjectsWith
    processor = PostProcessor.load(postname)
  File "/home/user/.FreeCAD0.2.1_30922_app_ex/squashfs-root/usr/Mod/Path/Path/Post/Processor.py", line 46, in load
    exec("import %s as current_post" % postname, namespace)
  File "<string>", line 1, in <module>
  File "/home/user/.FreeCAD0.2.1_30922_app_ex/squashfs-root/usr/lib/python3.10/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 139, in _import
    return original_import(name, *args, **kwargs)
  File "/home/user/.FreeCAD0.2.1_30922_app_ex/squashfs-root/usr/Mod/Path/Path/Post/scripts/snapmaker_freecad_post.py", line 30, in <module>
    from PathScripts import PostUtils

cannot import name 'PostUtils' from 'PathScripts' (/home/user/.FreeCAD0.2.1_30922_app_ex/squashfs-root/usr/Mod/Path/PathScripts/__init__.py)

Not so important but don`t know how to convert old .json tools to the new style?

Best regards
Noku
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Post Processing Error - FreeCAD v0.20

Post by GeneFC »

Noku wrote: Fri Nov 11, 2022 9:42 pm In Freecad 30922(Git) opens a dialog window for type the folder and name after that, it gives only errors:
The errors may come from the major refactoring that was done a few weeks ago.

https://forum.freecadweb.org/viewtopic.php?f=15&t=71610

The postprocessor probably needs to be updated.

You might try a different postprocessor, such as "refactored_linuxcnc_post" to see if the errors go away. I am not sure the g-code would be correct, but at least you can see if the error is due to the outdated postprocessor. The changes are fairly small, so you may be able to update the snapmaker postprocessor by yourself.

I cannot reach the FCStd file referenced above. Please attach your own file or provide a good link to a no-login file-sharing site.

Gene
bmsaus4ax
Posts: 258
Joined: Sat Nov 14, 2020 9:16 pm
Location: Bargara, Queensland, Australia UTC+10

Re: Post Processing Error - FreeCAD v0.20

Post by bmsaus4ax »

SaazyPants wrote: Sat Jul 16, 2022 3:36 am
The file that I'm working with to test this can be found https://drive.google.com/file/d/1BtiSyc ... sp=sharing.
.
Let me know if you guys need any further feedback or information. Also excuse the messy-ness of that 3D file, it's a proof of concept file :P

Cheers,
Saazy
I could not access your file on google but tested the post processor on a file of mine.
try editing the post.py file as

Code: Select all

#from PathScripts import PathUtils
import Path.Post.Utils as PostUtils
this output sound code on my file.

my own custom post processor required a slight variation on this but it seems all you need to do is get the correct import path and the alias.
(mine was "from Path.Post import Utils"
Noku
Posts: 8
Joined: Fri Nov 11, 2022 5:13 pm

Re: Post Processing Error - FreeCAD v0.20

Post by Noku »

Gene,

Wow, Thank You for the answer/advice, I tried to do so - compare both gcode files (after postprocessing:linuxcnc from new Freecad and snapmaker form freecad earlier version), and after some deleting (testing too in air - but later) they are the same.

I`m not a programmer, is not my thing for now, but this is "easy" to change some gcodes for me.

This file from google is not my, in my head was the snapmaker_freecad_post.py.

I have seen that there is something new, therefore I maked simple obiekts from scratch , or use examples from Freecad , result is the same (with errors using in Freecad 30922 the old snapmaker_freecad_post.py)
But thoose linuxcnc and refactored_linuxcnc gives what I need.

Earlier, I suggested that the code during the inspection (Inspect Path Commands) is the result of the Post Processor, and this is not the case :)

Thanks again!
Noku
Posts: 8
Joined: Fri Nov 11, 2022 5:13 pm

Re: Post Processing Error - FreeCAD v0.20

Post by Noku »

bmsaus4ax,

wow, thank You too, it took some time but now it works same like in old version of Freecad : )

I have this part, of the snapmaker post processor file, changed:

Code: Select all

from PathScripts import PostUtils
from PathScripts import PathUtils
so that it looks now like this:

Code: Select all

#from PathScripts import PostUtils
#from PathScripts import PathUtils

from PathScripts import PathUtils
import Path.Post.Utils as PostUtils
Thanks again too :)

Now I think my questions are solved.
SaazyPants
Posts: 10
Joined: Wed Nov 24, 2021 4:07 pm

Re: Post Processing Error - FreeCAD v0.20

Post by SaazyPants »

bmsaus4ax wrote: Fri Nov 11, 2022 11:07 pm
SaazyPants wrote: Sat Jul 16, 2022 3:36 am
The file that I'm working with to test this can be found https://drive.google.com/file/d/1BtiSyc ... sp=sharing.
.
Let me know if you guys need any further feedback or information. Also excuse the messy-ness of that 3D file, it's a proof of concept file :P

Cheers,
Saazy
I could not access your file on google but tested the post processor on a file of mine.
try editing the post.py file as

Code: Select all

#from PathScripts import PathUtils
import Path.Post.Utils as PostUtils
this output sound code on my file.

my own custom post processor required a slight variation on this but it seems all you need to do is get the correct import path and the alias.
(mine was "from Path.Post import Utils"
So I made the adjustments recommended here, with commenting out "from PathScripts import PathUtils" and added the import line as stated.

Code: Select all

#from PathScripts import PostUtils
from PathScripts import PathUtils

import Path.Post.Utils as PostUtils
I'm getting the following error when I try to select the snapmaker processor from the Job menu:

Code: Select all

17:35:47  Traceback (most recent call last):
  File "/app/freecad/Mod/Path/PathScripts/PathJob.py", line 562, in onChanged
    processor = PostProcessor.load(obj.PostProcessor)
  File "/app/freecad/Mod/Path/PathScripts/PathPostProcessor.py", line 47, in load
    exec("import %s as current_post" % postname, namespace)
  File "<string>", line 1, in <module>
  File "/app/lib/python3.9/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 142, in _import
    return original_import(name, *args, **kwargs)
  File "/app/freecad/Mod/Path/PathScripts/post/snapmaker_freecad_post.py", line 34, in <module>
    import Path.Post.Utils as PostUtils
  File "/app/lib/python3.9/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 142, in _import
    return original_import(name, *args, **kwargs)
<class 'ModuleNotFoundError'>: No module named 'Path.Post'; 'Path' is not a package
I'm not nearly familiar enough with FreeCAD to try and diagnose what the issue is. The only thing that comes to mind is that I'm running the FlatPak version which may have oddities as far as paths to files. I'm still experiencing the same symptom when I try to post the paths, as expected given the error above.

I did install FreeCAD from the repos and tried the same thing above to the same end...

Code: Select all

if ($hungry) { eat(); } else { sleep(); }
Post Reply