Hi @AndyPayne
I’m trying to evaluate a Grasshopper definition that contains a Python script component.
import compute_rhino3d.Util
import compute_rhino3d.Grasshopper as gh
compute_rhino3d.Util.url = "http://localhost:5000/"
tree = gh.DataTree("tree")
tree.Append([0], [])
response = gh.EvaluateDefinition(
R"C:\Users\johan\Desktop\test\compute_python_in_gh.gh", [tree]
)
print(response)
compute_python_in_gh.gh (5.8 KB)
It works fine without the script component, but when the script is added, it throws the following error:
Traceback (most recent call last):
File "C:\Users\johan\Desktop\kortgrundlag.backend\.venv\Lib\site-packages\requests\models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\johan\Desktop\kortgrundlag.backend\temp.py", line 9, in <module>
response = gh.EvaluateDefinition(
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\johan\Desktop\kortgrundlag.backend\.venv\Lib\site-packages\compute_rhino3d\Grasshopper.py", line 57, in EvaluateDefinition
response = Util.ComputeFetch(url, args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\johan\Desktop\kortgrundlag.backend\.venv\Lib\site-packages\compute_rhino3d\Util.py", line 35, in ComputeFetch
return r.json()
^^^^^^^^
File "C:\Users\johan\Desktop\kortgrundlag.backend\.venv\Lib\site-packages\requests\models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
It also works with the C# component. Is this a bug, or am I missing something?
Rhino: 8.12 Windows
Compute: 8.0.0.0
Best,
Johan