Path Workbench Code restructuring - heads up

This isn’t a complete solution but it’s something. Maybe someone smarter than me can improve it.

Attached file JobFixer.py is a standalone python script.

execute it like this

JobFixer.py -i <inputfilename> -o <outputfilename.FCStd>

This will attempt to fix the jobs and write the result to outpufilename.FCStd.

How it works
At the beginning of the file are two dictionaries. These are used to map the old module names to the new reorganized modules. The script works directly on the GuiDocument.xml file and the Document.xml file inside the FreeCAD project. It basically does a simple substitution – look up the old name, and stick in the new name.
It will output in the console the name of any module that it doesn’t find a match for. Non-Path objects are normal. If you find Path related objects listed, those need to be added to the map and the process restarted.

Caveats:

  1. The substitution maps may be incomplete or wrong.
  2. The viewproviders for operations don’t work. Double clicking on the operation won’t bring up the task panel. You can still modify the operation through the property pane and it appears to work.
  3. It’s very experimental. Make sure to back up your original files.

Even with the broken viewproviders, it might be useful to add new operations and copy the properties to rebuild your documents.
Discussion of ViewProvider limitations:
The script works by searching the XML for a Property whose name is ‘Proxy’. Then searching for the “module” attrib and replacing it.

In the old scheme, the operations had a viewprovider whose module is “PathScripts.PathOpGui”. This is a base class. The viewprovider is actually provided through PathScripts.PathSlotGui, for instance. Simply substituting in the new string, “Path.Op.Gui.Base” doesn’t work. It still tries to find the viewprovider in the PathScripts.PathOpGui, presumably because that’s encoded in the pickled object.

I don’t see a way around this. Like I said, maybe someone smarter than me does.
JobFixer.py (5.01 KB)