Closed sweco-begertjanvdb closed 4 years ago
Description / Explanation Seems like the script.load_json method returns just returns the data of a file as a string. Not as an object
file_loc = script.get_instance_data_file('temp, False) data = {'somelist': ['item1', 'item2'], 'not a list' : 99} script.dump_json(data, file_loc)
file_loc = script.get_instance_data_file('temp, False)
data = {'somelist': ['item1', 'item2'], 'not a list' : 99}
script.dump_json(data, file_loc)
loaded_data = script.load_json(file_loc)
I would expect loaded_data to be a dictionary, instead I just get the data as a string
Potential Fix PyRevit/script.py -> line 576 in the load_json method. replace: return json_file.read() with: return json.reads(json_file.read())
return json_file.read()
return json.reads(json_file.read())
Desktop (please complete the following information):
C:\Users\gvandenbroek>pyrevit env ==> Registered Clones (full git repos) ==> Registered Clones (deployed from archive/image) master | Deploy: "basepublic" | Branch: "master" | Version: "4.7.6" | Path: "C:\Users\gvandenbroek\AppData\Roaming\pyRevit-Master" ==> Attachments master | Product: "Autodesk Revit 2021" | Engine: 277 | Path: "C:\Users\gvandenbroek\AppData\Roaming\pyRevit-Master" | Manifest: "C:\Users\gvandenbroek\AppData\Roaming\Autodesk\Revit\Addins\2021\pyRevit.addin" master | Product: "Autodesk Revit 2020" | Engine: 277 | Path: "C:\Users\gvandenbroek\AppData\Roaming\pyRevit-Master" | Manifest: "C:\Users\gvandenbroek\AppData\Roaming\Autodesk\Revit\Addins\2020\pyRevit.addin" master | Product: "2019.2.2 Hotfix" | Engine: 277 | Path: "C:\Users\gvandenbroek\AppData\Roaming\pyRevit-Master" | Manifest: "C:\Users\gvandenbroek\AppData\Roaming\Autodesk\Revit\Addins\2019\pyRevit.addin" master | Product: "2018.3.3 Security Fix" | Engine: 277 | Path: "C:\Users\gvandenbroek\AppData\Roaming\pyRevit-Master" | Manifest: "C:\Users\gvandenbroek\AppData\Roaming\Autodesk\Revit\Addins\2018\pyRevit.addin" ==> Installed Extensions pyVK_ARCH | Type: Unknown | Repo: "" | Installed: "V:\OPS\_cad\_Revit\PyRevit\pyVK_ARCH.extension" pyVK_CORE | Type: Unknown | Repo: "" | Installed: "V:\OPS\_cad\_Revit\PyRevit\pyVK_CORE.extension" pyVK_DEV | Type: Unknown | Repo: "" | Installed: "C:\Users\gvandenbroek\Documents\Visual Studio 2019\git\PyRevitExtensions\pyVK_DEV.extension" pyVK_GERTJAN | Type: Unknown | Repo: "" | Installed: "C:\Users\gvandenbroek\Documents\Visual Studio 2019\git\PyRevitExtensions\pyVK_GERTJAN.extension" pyVK_MEP | Type: Unknown | Repo: "" | Installed: "V:\OPS\_cad\_Revit\PyRevit\pyVK_MEP.extension" pyVK_STRU | Type: Unknown | Repo: "" | Installed: "V:\OPS\_cad\_Revit\PyRevit\pyVK_STRU.extension" ==> Default Extension Search Path C:\Users\gvandenbroek\AppData\Roaming\pyRevit\Extensions ==> Extension Search Paths V:\OPS\_cad\_Revit\PyRevit C:\Users\gvandenbroek\Documents\Visual Studio 2019\git\PyRevitExtensions ==> Extension Sources - Default https://github.com/eirannejad/pyRevit/raw/master/extensions/extensions.json ==> Extension Sources - Additional ==> Installed Revits Autodesk Revit 2021 | Version: 21.1.0.108 | Build: 20200708_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2021" Autodesk Revit 2020 | Version: 20.2.20.31 | Build: 20200426_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2020" 2019.2.2 Hotfix | Version: 19.2.20.24 | Build: 20190808_0900(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2019" 2018.3.3 Security Fix | Version: 18.3.3.18 | Build: 20190510_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2018" ==> Running Revit Instances Error: Object reference not set to an instance of an object. Run with "--debug" option to see debug messages
anyway no big deal. Love your work. PyRevit is a dream!
@eirannejad this can be closed now
Description / Explanation Seems like the script.load_json method returns just returns the data of a file as a string. Not as an object
file_loc = script.get_instance_data_file('temp, False)
data = {'somelist': ['item1', 'item2'], 'not a list' : 99}
script.dump_json(data, file_loc)
loaded_data = script.load_json(file_loc)
I would expect loaded_data to be a dictionary, instead I just get the data as a string
Potential Fix PyRevit/script.py -> line 576 in the load_json method. replace:
return json_file.read()
with:return json.reads(json_file.read())
Desktop (please complete the following information):
C:\Users\gvandenbroek>pyrevit env ==> Registered Clones (full git repos) ==> Registered Clones (deployed from archive/image) master | Deploy: "basepublic" | Branch: "master" | Version: "4.7.6" | Path: "C:\Users\gvandenbroek\AppData\Roaming\pyRevit-Master" ==> Attachments master | Product: "Autodesk Revit 2021" | Engine: 277 | Path: "C:\Users\gvandenbroek\AppData\Roaming\pyRevit-Master" | Manifest: "C:\Users\gvandenbroek\AppData\Roaming\Autodesk\Revit\Addins\2021\pyRevit.addin" master | Product: "Autodesk Revit 2020" | Engine: 277 | Path: "C:\Users\gvandenbroek\AppData\Roaming\pyRevit-Master" | Manifest: "C:\Users\gvandenbroek\AppData\Roaming\Autodesk\Revit\Addins\2020\pyRevit.addin" master | Product: "2019.2.2 Hotfix" | Engine: 277 | Path: "C:\Users\gvandenbroek\AppData\Roaming\pyRevit-Master" | Manifest: "C:\Users\gvandenbroek\AppData\Roaming\Autodesk\Revit\Addins\2019\pyRevit.addin" master | Product: "2018.3.3 Security Fix" | Engine: 277 | Path: "C:\Users\gvandenbroek\AppData\Roaming\pyRevit-Master" | Manifest: "C:\Users\gvandenbroek\AppData\Roaming\Autodesk\Revit\Addins\2018\pyRevit.addin" ==> Installed Extensions pyVK_ARCH | Type: Unknown | Repo: "" | Installed: "V:\OPS\_cad\_Revit\PyRevit\pyVK_ARCH.extension" pyVK_CORE | Type: Unknown | Repo: "" | Installed: "V:\OPS\_cad\_Revit\PyRevit\pyVK_CORE.extension" pyVK_DEV | Type: Unknown | Repo: "" | Installed: "C:\Users\gvandenbroek\Documents\Visual Studio 2019\git\PyRevitExtensions\pyVK_DEV.extension" pyVK_GERTJAN | Type: Unknown | Repo: "" | Installed: "C:\Users\gvandenbroek\Documents\Visual Studio 2019\git\PyRevitExtensions\pyVK_GERTJAN.extension" pyVK_MEP | Type: Unknown | Repo: "" | Installed: "V:\OPS\_cad\_Revit\PyRevit\pyVK_MEP.extension" pyVK_STRU | Type: Unknown | Repo: "" | Installed: "V:\OPS\_cad\_Revit\PyRevit\pyVK_STRU.extension" ==> Default Extension Search Path C:\Users\gvandenbroek\AppData\Roaming\pyRevit\Extensions ==> Extension Search Paths V:\OPS\_cad\_Revit\PyRevit C:\Users\gvandenbroek\Documents\Visual Studio 2019\git\PyRevitExtensions ==> Extension Sources - Default https://github.com/eirannejad/pyRevit/raw/master/extensions/extensions.json ==> Extension Sources - Additional ==> Installed Revits Autodesk Revit 2021 | Version: 21.1.0.108 | Build: 20200708_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2021" Autodesk Revit 2020 | Version: 20.2.20.31 | Build: 20200426_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2020" 2019.2.2 Hotfix | Version: 19.2.20.24 | Build: 20190808_0900(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2019" 2018.3.3 Security Fix | Version: 18.3.3.18 | Build: 20190510_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2018" ==> Running Revit Instances Error: Object reference not set to an instance of an object. Run with "--debug" option to see debug messages
anyway no big deal. Love your work. PyRevit is a dream!