Path Workbench Code restructuring - heads up

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!
Russ4262
Posts: 941
Joined: Sat Jun 30, 2018 3:22 pm
Location: Oklahoma
Contact:

Re: Path Workbench Code restructuring - heads up

Post by Russ4262 »

chrisb wrote: Thu Mar 16, 2023 9:36 am Here is my complete modified script including the modified message in case the file exists: ...
Great!
With your permission, I converted it to version 5, replaced the V4 file posted earlier, and did a little more refactoring for cleanup. I also copied the usage examples from the Windows batch file and included them in the header portion of the script to assist non-Windows users.

Thanks and have a great day.

Russell
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: Path Workbench Code restructuring - heads up

Post by chrisb »

GeneFC wrote: Thu Mar 16, 2023 2:11 pm I think it would be a good idea to modify the very first post in this topic to include the latest version of the JobFixer.

That will make it more easily discoverable.
That's what I had suggested a bit further up from the other side, I was just waiting for things to settle. I will create a new sticky topic with just a single script, without naming it xxxCopy, and with instructions for Linux, Windows and macOS.

Did you test the latest version?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Path Workbench Code restructuring - heads up

Post by GeneFC »

chrisb wrote: Thu Mar 16, 2023 4:49 pm Did you test the latest version?
I just tested, and it did not work for me. Using Python 3.8.10.

First try gave

Code: Select all

Traceback (most recent call last):
  File "JobFixerCopy_V5.py", line 344, in <module>
    execute()
  File "JobFixerCopy_V5.py", line 317, in execute
    args = getCommandLineArgs()
  File "JobFixerCopy_V5.py", line 266, in getCommandLineArgs
    parser = argparse.ArgumentParser(
TypeError: __init__() got an unexpected keyword argument 'exit_on_error'
I removed the 'exit_on_error' and then I got

Code: Select all

Using suffix:  _current
Input file: Dome Former-Round-Path.FCStd
      Output: Dome Former-Round-Path_current.FCStd
cleaning ObjectData
module draftobjects.clone not substituted
cleaning ViewProviderData
      ERROR: local variable 'modstring' referenced before assignment
I gave up at that point.

Gene
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: Path Workbench Code restructuring - heads up

Post by chrisb »

GeneFC wrote: Thu Mar 16, 2023 7:24 pm I gave up at that point.
So we better wait before moving the script to a more prominent place.

Can you provide the failing file? Can you paste the commandline here?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Path Workbench Code restructuring - heads up

Post by GeneFC »

chrisb wrote: Thu Mar 16, 2023 8:07 pm Can you provide the failing file? Can you paste the commandline here?
I do not think it ever got to the actual file.

The command was simply the BAT file included with the JobFixer. Done in the Windows GUI, not the command line.

I have used the old JobFixerCopy (version 1) a few times, with no problems. I am not quite sure what the latest fix is supposed to do.

I will do a bit more digging, but not today.

Gene
Russ4262
Posts: 941
Joined: Sat Jun 30, 2018 3:22 pm
Location: Oklahoma
Contact:

Re: Path Workbench Code restructuring - heads up

Post by Russ4262 »

GeneFC wrote: Thu Mar 16, 2023 7:24 pm ... I just tested, and it did not work for me. Using Python 3.8.10.

First try gave ...
Turns out the 'exit_on_error' argument was not added until Python 3.9. So, understandably it causes and error for your version. I added a Python version check and 'if...else...' block to alter code execution depending on version info. For Python < 3.9, argparse will exit the script upon error, even if contained within a 'try...except...' block.

GeneFC wrote: Thu Mar 16, 2023 7:24 pm ... and then I got ...
I see the 'for' loop has a 'try ... except ...' statement that is incompletely formed with a 'pass' statement for the 'except' clause. I have fixed this issue by adding the 'else' clause to contain the remainder of the instructions intended to follow the successful 'try' clause. This means if the 'except' clause is triggered, the additional instructions will not be run for that iteration of the loop.

I will again swap out Version 6 for V5 earlier in this thread.

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

Re: Path Workbench Code restructuring - heads up

Post by GeneFC »

Russ4262 wrote: Thu Mar 16, 2023 10:24 pm I will again swap out Version 6 for V5 earlier in this thread.
Version 6 worked perfectly for me.

I do not use standalone Python for anything else, so I had only an older version.

Guess I need to update. :oops:

Gene
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: Path Workbench Code restructuring - heads up

Post by chrisb »

Russ4262 wrote: Thu Mar 16, 2023 10:24 pm I will again swap out Version 6 for V5 earlier in this thread.
Now that this script is extensively tested by at least two forum members we can go one step further.
Russ, is it ok for you if I create a new pinned topic which contains just one post with a link to this one for further diuscussions? The new topic should have 4 sections:

1) Always the most recent version of the JobFixer script, i.e. currently JobFixerCopy_V6.py
2) section for Windows users with a dedicated description and helpers such as the batch file
3) section for Linux users
4) section for macOS users.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Path Workbench Code restructuring - heads up

Post by GeneFC »

chrisb wrote: Sat Mar 18, 2023 11:06 pm create a new pinned topic which contains just one post
I would immediately lock the topic so that it does not get quickly diluted with various "it doesn't work comments." Those should go into a new topic.

Gene
Russ4262
Posts: 941
Joined: Sat Jun 30, 2018 3:22 pm
Location: Oklahoma
Contact:

Re: Path Workbench Code restructuring - heads up

Post by Russ4262 »

chrisb wrote: Sat Mar 18, 2023 11:06 pm ... Russ, is it ok for you if I create a new pinned topic which contains just one post with a link to this one for further diuscussions? ...
I am content with this idea.

GeneFC wrote: Sat Mar 18, 2023 11:28 pm ... I would immediately lock the topic ...
I will not be able to update the script or details later since I am unable to access locked threads. A forum admin will have to do so.

Russell
Post Reply