Code Restructuring - JobFixer Script

I suffered for a long time, the pockets did not work.
There are several typos

"PathScripts.PathPocketShape": "Path.Op.Pocket",

instead of

"PathScripts.PathPocketShape": "Path.Op.PocketShape",

and

"PathScripts.PathPocketShapeGui": "Path.Op.Gui.Pocket",

instead of

"PathScripts.PathPocketShapeGui": "Path.Op.Gui.PocketShape",

Russ4262, if you don’t mind, correct these points too, please.

It does only if you accept i with the tab key (at least here on firefox).

Thank you chrisb :slight_smile:

Morning.
I added the reference in both ‘objectmaps’ and ‘viewprovidermaps’ because the reference should appear in both sections. I recommend a refactoring for the Array.py file since it contains both the object class and the viewprovider class, but this recommendation is extraneous to this thread.


The Pocket/PocketShape redirection should be corrected. The error appeared to be that both were being mapped to Pocket (3D Pocket).

Thanks for suggesting the addition and corrections. I will replace V8 with V9 in the original post [OP] of this thread.

To Whomever:
The pinging feature is not pinging me, so anyone using it with my username is doing so in vain. Perhaps there is a forum setting I would have to enable in my account settings.

Cordially,
Russell

Check these in your User Control Panel. The Mention settings are used for pinging:

How does this script get executed? I’ve not been able to find anything written for the average non-programmer person to fix their pre-0.21 files…

Edit: I’m using Windows 10 v.22H2



thanks!

Thank you Russ4262

And I’am here again with some fixes :slight_smile:

First in cleanupBase64String function. An error occurs in the function when the string contains null instead of a string.
After line 107 we need replace null with None.

if not string.startswith("{") or not string.endswith("}"):
        # print(f"original string: {string}")
        return base64_string

string = string.replace("null", "None")

dictStr = eval(string)

The second point is this: the tool stores the path to the figure and a description of the parameters of the tool itself. In my file there is an indication of the old version. I think this should be corrected automatically (but maybe I’m wrong).
In case you agree I prepared a fix (of mediocre quality, but it works :slight_smile: )
Function cleanupDoc, approximately line 180

                # Eif
            # Etry
        # Efor
        
        # It is for ToolBit (example C:/Program Files/FreeCAD 0.20/Mod\Path\Tools\Shape\endmill.fcstd)
        res = child.findall("./Properties/Property[@name='BitShape']/String")
        for r in res:
            try:
                valuestring = r.attrib["value"]
            except:
                pass
            else:
                if "/freecad 0.20/mod" in valuestring.lower():
                    r.attrib["value"] = valuestring.replace("/FreeCAD 0.20/Mod", "/FreeCAD 0.21/Mod")
                # Eif
            # Etry
        # Efor

        # It is for ToolBit (example C:/Program Files/FreeCAD 0.20/Mod/Path/Tools/Bit/5mm_Drill.fctb)
        res = child.findall("./Properties/Property[@name='File']/String")
        for r in res:
            try:
                valuestring = r.attrib["value"]
            except:
                pass
            else:
                if "/freecad 0.20/mod" in valuestring.lower():
                    r.attrib["value"] = valuestring.replace("/FreeCAD 0.20/Mod", "/FreeCAD 0.21/Mod")
                # Eif
            # Etry
        # Efor
        
    # Efor
    newXML = ET.tostring(root)
    return newXML

I understand that this method of indicating corrections is not very clear, so I am attaching the resulting file.

I installed python version 3.
Then open the folder that contains the file that needs to be corrected.
Press the Shift key together with the right mouse button and select Open Command Prompt.
And run the script

python "C:\Users\YOUR USER HERE\Downloads\JobFixer_V9\JobFixer.py" -d ".\" --s "_fixed"

To get help use the -h or --help option:
python3 JobFixer.py -h

Also, there is a bat file included in the download and there are a few examples listed in that file.

Thanks for this very helpful tool first.
But when using it the Boundary Dressup was not converted.

Job Fixer, 2023-09-24 using Python 3.10.12
Input file: Mosaikkreuz.FCStd
      Output: Mosaikkreuz-0.21-X.FCStd
cleaning ObjectData
module draftobjects.clone not substituted
module PathScripts.PathDressupPathBoundary not substituted
module PathScripts.PathDressupPathBoundary not substituted
cleaning ViewProviderData
module PathScripts.PathDressupPathBoundaryGui not substituted
module None not substituted
module PathScripts.PathDressupPathBoundaryGui not substituted
module None not substituted

I fixt it by adding this two lines in JobFixer.py

objectmaps = {
...
    "PathScripts.PathDressupPathBoundary": "Path.Dressup.Boundary",
...
}

viewprovidermaps = {
...
    "PathScripts.PathDressupPathBoundaryGui": "Path.Dressup.Gui.Boundary"
...
}

It seems to work now but is this all, is this correct or is there anything else to do? I also added the changed JobFixer.py file