Grasshopper exception occured when using path inputs

Hi
I am trying to make my grasshopper file into an app.
The file works if i run it using rhino.Compute, however through the viktor worker i get an system.ArguementException about a non-recognised escape token.
The input is literally copied from the original string input in the grasshopper file.
Can someone help me?

rhino.Compute console:

grasshopper:

I know that i can just reverse the “/” to solve the escape character and then it all works but what is the worker doing with the input to make it not work?

Hi @NBouwman,

I think you sort-of answered your own question here, you’ll have to revert your slashes :slight_smile:

You cannot use backslashes for Rhino Compute. Your input string will have to look like C:/Users/myusername/Documents. Note that this also counts for the GetFilePath component. The reason for this is that we have to serialize the inputs to a JSON.

I was just discussing this with a friend.
If i run the file still using Rhino.Compute, and not through viktor then it works with the slashes either way.
We considered that maybe it was because the viktor worker uses linux which doesnt accept backslashes. Is that true?

Yes I understand your confusion here.

I expect that you mean to run it through Hops, in which case that is true. Hops doesn’t have to serialize the data to a JSON, and can just create the DataTree objects per input (as both GH and Hops are built in C#).

To call Rhino.Compute from Python, we cannot just send over DataTree items. Therefore, we have to translate all the data to a format that both Python and C# can understand, which is, in this case, strings. And a backslash in Python has some double meaning in strings, hence your “Escape error”.

Technically you could also work with 4 backslashes as an input, but in that case the single forward slash is a much easier fix.

1 Like