RhinoCompute client side error reading .gh script

when sending a grasshopper script saved as “.gh” to rhinocompute, it complains as follows:

Traceback (most recent call last):
  File "c:\dev\_TDA\tda_rh_compute_tests_suite\gh_cloud_py\bridges_bim_model.py", line 47, in <module>
    output = gh.EvaluateDefinition(gh_file, input_tree)
  File "c:\dev\_TDA\tda_rh_compute_tests_suite\.venv\lib\site-packages\compute_rhino3d\Grasshopper.py", line 51, in EvaluateDefinition
    definition = ghx.read()
  File "C:\Python\Python38\lib\codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
  File "C:\Python\Python38\lib\encodings\utf_8_sig.py", line 69, in _buffer_decode
    return codecs.utf_8_decode(input, errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd4 in position 0: invalid continuation byte

Once saved as “.ghx” it works fine but the ghx file size is almost 30 times bigger. Any ideas as to why it doesn’t work as “.gh”?

I’m trying to figure out why you are hitting line 51 when using a file with a .gh extension. The code was written to do different things based on the file extension. What is the path that you are using for your definition?

@stevebaer - I figured it out.
The string comparison here needs to be case insensitive.

Our path to the gh file ended with GH (in uppercase).
Which also explains why it was kicking into evaluating the branch for .ghx files

Thanks for letting me know. I added this to our bug tracker as something to fix at

1 Like