Exported job template fails on job-create-with-template. 'type must be int, not str'

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!
Post Reply
awgrover
Posts: 1
Joined: Sun Nov 01, 2020 10:39 pm

Exported job template fails on job-create-with-template. 'type must be int, not str'

Post by awgrover »

Overview:
  • Export a job template with OpDefault StepOver
  • Create a new job using that template
  • Fails with exception below
Stable

Code: Select all

OS: Ubuntu 18.04.6 LTS (ubuntu:GNOME/ubuntu)
Word size of FreeCAD: 64-bit
Version: 0.20.1.29410 (Git) AppImage
Build type: Release
Branch: (HEAD detached at 0.20.1)
Hash: f5d13554ecc7a456fb6e970568ae5c74ba727563
Python 3.10.5, Qt 5.15.4, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.2
Locale: English/United States (en_US)
Installed mods: 
  * ShortCuts
  * Help 1.0.3
and Weekly

Code: Select all

OS: Ubuntu 18.04.6 LTS (ubuntu:GNOME/ubuntu)
Word size of FreeCAD: 64-bit
Version: 0.21.30256 (Git) AppImage
Build type: Release
Branch: master
Hash: 55866fd62221beadad3cfd60915278b156609a66
Python 3.10.6, Qt 5.15.4, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.2
Locale: English/United States (en_US)
Installed mods: 
  * ShortCuts
  * Help 1.0.3
  • Also fails to indicate which template value is bad
  • Other cases not tested, it seems likely that other Op Default settings have the same problem.
  • I noticed that other "int" values that are saved in the template as strings, and that they work on import (e.g. Tolerance).

Detailed Steps:
  • Create a new freecad file
  • Create a job with Stepover
    • create a part-design body with a primitive box. We only need it as a dumy for the job.
    • change to Path workbench
    • select the body
    • create a job
    • set the OpDefaults:"Op Pocket Shape":StepOver to 90
    • Close task with "ok"
    • Save with some name like "import-crash-test"
  • Export a job template with StepOver
    • edit the job
    • from the General tab, section "Template Export"
    • make sure "Setup Sheet" is checked
    • click export
    • choose some name like "import-crash-test"
    • should be saved in the Freecad Macros folder
    • click the task "ok"
  • Test job-creation with template
    • select the body
    • create a job, but choose the template saved above, e.g. "import-crash-test"
    • job creation fails. Displays an exception in the Report View (show below). Does not indicate which template value is bad.
  • Test job-creation with workaround
    • Edit the .freecad/Macros/job_import-crash-test.json
    • (or used the minimal job.json below which only has the StepOver value).
    • Change

      Code: Select all

      "StepOver": "90"
      to

      Code: Select all

      "StepOver": 90
      . i.e. remove quotes.
    • create a job, but choose the template saved above, e.g. "import-crash-test"
    • succeeds with no error, opening a task gui.
    • examine the OpDefaults:"Op Pocket Shape":StepOver, should be 90
In 0.20.1:

Code: Select all

10:53:39  PathJobGui.ERROR: {'sclassname': 'N4Base9TypeErrorE', 'sErrMsg': 'type must be int, not str', 'sfile': '', 'iline': 0, 'sfunction': '', 'swhat': 'type must be int, not str', 'btranslatable': False, 'breported': False}
10:53:39  Traceback (most recent call last):
10:53:39    File "/tmp/.mount_freecacZe8XQ/usr/Mod/Path/PathScripts/PathJobGui.py", line 1641, in Create
    obj = PathJob.Create("Job", base, template)
10:53:39    File "/tmp/.mount_freecacZe8XQ/usr/Mod/Path/PathScripts/PathJob.py", line 866, in Create
    obj.Proxy = ObjectJob(obj, models, templateFile)
10:53:39    File "/tmp/.mount_freecacZe8XQ/usr/Mod/Path/PathScripts/PathJob.py", line 241, in __init__
    self.setFromTemplateFile(obj, templateFile)
10:53:39    File "/tmp/.mount_freecacZe8XQ/usr/Mod/Path/PathScripts/PathJob.py", line 596, in setFromTemplateFile
    self.setupSheet.setFromTemplate(attrs[JobTemplate.SetupSheet])
10:53:39    File "/tmp/.mount_freecacZe8XQ/usr/Mod/Path/PathScripts/PathSetupSheet.py", line 290, in setFromTemplate
    prop.setupProperty(
10:53:39    File "/tmp/.mount_freecacZe8XQ/usr/Mod/Path/PathScripts/PathSetupSheetOpPrototype.py", line 71, in setupProperty
    setattr(obj, name, value)
10:53:39  TypeError: {'sclassname': 'N4Base9TypeErrorE', 'sErrMsg': 'type must be int, not str', 'sfile': '', 'iline': 0, 'sfunction': '', 'swhat': 'type must be int, not str', 'btranslatable': False, 'breported': False}
10:53:39  
Using python api:

Code: Select all

line 2383, in create_job
    obj = PathScripts.PathJob.Create('Job', model_list, template)
  File "/tmp/.mount_freeca4Ub7TW/usr/Mod/Path/PathScripts/PathJob.py", line 866, in Create
    obj.Proxy = ObjectJob(obj, models, templateFile)
  File "/tmp/.mount_freeca4Ub7TW/usr/Mod/Path/PathScripts/PathJob.py", line 241, in __init__
    self.setFromTemplateFile(obj, templateFile)
  File "/tmp/.mount_freeca4Ub7TW/usr/Mod/Path/PathScripts/PathJob.py", line 596, in setFromTemplateFile
    self.setupSheet.setFromTemplate(attrs[JobTemplate.SetupSheet])
  File "/tmp/.mount_freeca4Ub7TW/usr/Mod/Path/PathScripts/PathSetupSheet.py", line 290, in setFromTemplate
    prop.setupProperty(
  File "/tmp/.mount_freeca4Ub7TW/usr/Mod/Path/PathScripts/PathSetupSheetOpPrototype.py", line 71, in setupProperty
    setattr(obj, name, value)
<class 'TypeError'>: {'sclassname': 'N4Base9TypeErrorE', 'sErrMsg': 'type must be int, not str', 'sfile': '', 'iline': 0, 'sfunction': '', 'swhat': 'type must be int, not str', 'btranslatable': False, 'breported': False}
in weekly build 0.21.30256 (Git) AppImage/Hash: 55866fd62221beadad3cfd60915278b156609a66

Code: Select all

10:39:35  PathJobGui.ERROR: {'sclassname': 'N4Base9TypeErrorE', 'sErrMsg': 'type must be int, not str', 'sfile': '', 'iline': 0, 'sfunction': '', 'swhat': 'type must be int, not str', 'btranslatable': False, 'breported': False}
10:39:35  Traceback (most recent call last):
10:39:35    File "/tmp/.mount_FreeCAbAsFIX/usr/Mod/Path/PathScripts/PathJobGui.py", line 1641, in Create
    obj = PathJob.Create("Job", base, template)
10:39:35    File "/tmp/.mount_FreeCAbAsFIX/usr/Mod/Path/PathScripts/PathJob.py", line 868, in Create
    obj.Proxy = ObjectJob(obj, models, templateFile)
10:39:35    File "/tmp/.mount_FreeCAbAsFIX/usr/Mod/Path/PathScripts/PathJob.py", line 241, in __init__
    self.setFromTemplateFile(obj, templateFile)
10:39:35    File "/tmp/.mount_FreeCAbAsFIX/usr/Mod/Path/PathScripts/PathJob.py", line 596, in setFromTemplateFile
    self.setupSheet.setFromTemplate(attrs[JobTemplate.SetupSheet])
10:39:35    File "/tmp/.mount_FreeCAbAsFIX/usr/Mod/Path/PathScripts/PathSetupSheet.py", line 290, in setFromTemplate
    prop.setupProperty(
10:39:35    File "/tmp/.mount_FreeCAbAsFIX/usr/Mod/Path/PathScripts/PathSetupSheetOpPrototype.py", line 71, in setupProperty
    setattr(obj, name, value)
10:39:35  TypeError: {'sclassname': 'N4Base9TypeErrorE', 'sErrMsg': 'type must be int, not str', 'sfile': '', 'iline': 0, 'sfunction': '', 'swhat': 'type must be int, not str', 'btranslatable': False, 'breported': False}
Using python api:

Code: Select all

  File "/tmp/.mount_FreeCAbAsFIX/usr/Mod/Path/PathScripts/PathJob.py", line 596, in setFromTemplateFile
    self.setupSheet.setFromTemplate(attrs[JobTemplate.SetupSheet])
  File "/tmp/.mount_FreeCAbAsFIX/usr/Mod/Path/PathScripts/PathSetupSheet.py", line 290, in setFromTemplate
    prop.setupProperty(
  File "/tmp/.mount_FreeCAbAsFIX/usr/Mod/Path/PathScripts/PathSetupSheetOpPrototype.py", line 71, in setupProperty
    setattr(obj, name, value)
<class 'TypeError'>: {'sclassname': 'N4Base9TypeErrorE', 'sErrMsg': 'type must be int, not str', 'sfile': '', 'iline': 0, 'sfunction': '', 'swhat': 'type must be int, not str', 'btranslatable': False, 'breported': False}
<Exception> ObjectIdentifier.cpp(1533): Document object 'SetupSheet' not found in 'SetupSheet.HorizRapid'
in property binding 'test_import_crash#TC__Default_Tool.HorizRapid'
Minimal extract of job_x.json that causes the error:

Code: Select all

{
  "SetupSheet": {
    "Pocket3D": {
      "StepOver": "90"
    }
  },
  "Version": 1
}
If you change

Code: Select all

"90"
to

Code: Select all

90
(remove quotes), then it will import the template.

Full job template:

Code: Select all

{
  "Fixtures": [
    {
      "G54": true
    }
  ],
  "OrderOutputBy": "Operation",
  "Post": "xopensbp",
  "PostArgs": "--comments",
  "SetupSheet": {
    "ClearanceHeightExpression": "OpStockZMax+${SetupSheet}.ClearanceHeightOffset",
    "ClearanceHeightOffset": "5.00 mm",
    "FinalDepthExpression": "OpFinalDepth",
    "HorizRapid": "9.87 mm/min",
    "Pocket Shape": {
      "CutMode": "Climb",
      "OffsetPattern": "ZigZag",
      "StepOver": "90",
      "ZigZagAngle": "45.0"
    },
    "Pocket3D": {
      "CutMode": "Conventional",
      "OffsetPattern": "ZigZag",
      "StepOver": "90"
    },
    "SafeHeightExpression": "OpStockZMax+${SetupSheet}.SafeHeightOffset",
    "SafeHeightOffset": "3.00 mm",
    "StartDepthExpression": "OpStartDepth",
    "StepDownExpression": "OpToolDiameter",
    "VertRapid": "2.00 mm/min"
  },
  "SplitOutput": false,
  "Stock": {
    "create": "FromBase",
    "version": 1,
    "xneg": "3.17 mm",
    "xpos": "3.17 mm",
    "yneg": "3.17 mm",
    "ypos": "3.17 mm",
    "zneg": "0.0 mm",
    "zpos": "1.0 mm"
  },
  "Tolerance": "0.01",
  "ToolController": [
    {
      "dir": "Forward",
      "hfeed": "111.76 mm/s",
      "hrapid": "0.16449999999999998 mm/s",
      "label": "1/4in Endmill015",
      "name": "__4in_Endmill002007",
      "nr": 2,
      "speed": 16000.0,
      "tool": {
        "attribute": {},
        "name": "1/4in Endmill047",
        "parameter": {
          "Chipload": "0.00 mm",
          "CuttingEdgeHeight": "25.40 mm",
          "Diameter": "6.35 mm",
          "Flutes": "2",
          "Length": "50.80 mm",
          "Material": "HSS",
          "ShankDiameter": "6.35 mm",
          "SpindleDirection": "Forward"
        },
        "shape": "endmill.fcstd",
        "version": 2
      },
      "version": 1,
      "vfeed": "55.88 mm/s",
      "vrapid": "0.03333333333333333 mm/s",
      "xengine": [
        {
          "expr": "${SetupSheet}.HorizRapid",
          "prop": "HorizRapid"
        },
        {
          "expr": "HorizFeed / 2",
          "prop": "VertFeed"
        },
        {
          "expr": "${SetupSheet}.VertRapid",
          "prop": "VertRapid"
        }
      ]
    }
  ],
  "Version": 1
}
Attachments
test-import-crash.FCStd
(17.49 KiB) Downloaded 8 times
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: Exported job template fails on job-create-with-template. 'type must be int, not str'

Post by mlampert »

I'll have a look once my compile finishes. Thanks for reporting.
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: Exported job template fails on job-create-with-template. 'type must be int, not str'

Post by mlampert »

Confirmed, I broke this with the introduction of the ToolBit editor.
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: Exported job template fails on job-create-with-template. 'type must be int, not str'

Post by mlampert »

Loading of "percent" properties was not handled correctly - StepOver is one of them.
https://github.com/FreeCAD/FreeCAD/pull/7455 PR-7455
Post Reply