Skip to content

v1_1_24: various patches for bugs 🐛

Compare
Choose a tag to compare
@9and3 9and3 released this 20 May 20:38
· 74 commits to main since this release

This Release introduces various fixes:

thread-safe: A new thread is added to the windows form to select the file. This should avoid the freezing of the canvas.

better-naming: the btn is now changed to a more understandable name select_file

now the error is catched and error is thrown by giving back a failure. So for now we cannot run two instances of script-sync rhino but at least this case is handled.

try
{
    TcpListener check = new TcpListener(IPAddress.Parse(Ip), Port);
    check.Start();
    check.Stop();
}
catch (Exception e)
{
    if (e.Message.Contains("Only one usage of each socket address"))
    {
        RhinoApp.WriteLine("Error: there are two instances of Rhino running script-sync, only one is allowed.");
    }
    else
    {
        RhinoApp.WriteLine("Error: " + e.Message);
    }
    return Rhino.Commands.Result.Failure;
}

now the error has a traceback that shows the line and module generating the error as well as all the traceback log, this is an example:

1. Error running script (PythonException): script-sync::Error in the code: invalid syntax (my_module.py, line 3)
Traceback (most recent call last):
  File "rhinocode:///grasshopper/1/e324c158-c009-4f19-b311-f20f3ae7d386/7243b0c7-8b8c-47fa-8009-1ad5b42499bc", line 383, in safe_exec
  File "rhinocode:///grasshopper/1/e324c158-c009-4f19-b311-f20f3ae7d386/7243b0c7-8b8c-47fa-8009-1ad5b42499bc", line 345, in reload_all_modules
  File "C:\Users\andre\.rhinocode\py39-rh8\lib\importlib\__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)
  File "<frozen importlib._bootstrap>", line 613, in _exec
  File "<frozen importlib._bootstrap_external>", line 846, in exec_module
  File "<frozen importlib._bootstrap_external>", line 983, in get_code
  File "<frozen importlib._bootstrap_external>", line 913, in source_to_code
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "F:\script-sync\GH\PyGH\test\my_module.py", line 3
    print("script-sync::Hello from my_module.py")a
                                                 ^
SyntaxError: invalid syntax

Now the output parameters do not stick anymore between the recomputation of the component. This is done by emptying the locals dict in the exec() function.

The output nested lists now are automatically converted to GHTrees but only for 2 level of depth