Command line arguments for Mac

Hi @dan @CallumSykes
Kudos to the updated docs - it’s been a while since I set up a project that needed Mac specific work but the docs made it very straightforward to set up the debugger with VSC. My only present qualm is that when you hit a breakpoint, the Grasshopper window stays topmost and needs to be dragged out of view to use VS effectively.

Command line launch arguments

Firstly - the docs mention using /nosplash etc. as command line args in the code comments for launch.json. I needed to use -- as a prefix, so these could be updated if that is a general case.

Secondly, when using the following:

--nosplash --notemplate --runscript=\"Grasshopper\"

I get the following command history:

Command: "Grasshopper"
Unknown command: "Grasshopper"

Subsequently, Grasshopper fails to launch.
Of course then typing the Grasshopper command manually launches it just fine.

Do I need to do something different to get Grasshopper loaded before runscript executes?

Thanks!

Good catch. I’ll update now. I’ll also add a link to this doc instead

There is also a Grasshopper for Mac guide I updated which has this little nugget in the launch.json and works nicely.

    "args": ["-runscript=_Grasshopper"],

The dotnet templates are being updated soon to include these .vscode files to make all of this easier :slight_smile:

Ah, great! And having them in the templates will be useful.

This does work – it turns out the syntax is quite picky! What did not work:

"args": ["-runscript \"Grasshopper\""],
"args": ["-runscript='_Grasshopper'"],
"args": ["-runscript=\"_Grasshopper\""],

And it also surprises me that this does work without any quote encapsulation:

"args": ["-runscript=Line 0 1,1,1"],

Suggesting that -runscript must be the last argument?

Anyhow, all good now :slight_smile:
Thanks

The syntax sure is picky. I also tried similar things and I was kind of amazed it seems like avoiding quotes works best on mac? Hopefully this thread will be useful to other in the future. Most likely myself.

And now, the same question for Windows
I have been using VS2022 and thought I’d try VS Code for debugging Rhino/GH plugins.

In VS2022 the launchSettings.json works fine:

{
  "profiles": {
    "Plugin": {
      "commandName": "Executable",
      "executablePath": "C:\\Program Files\\Rhino 8\\System\\Rhino.exe",
      "commandLineArgs": "/runscript=\"_Grasshopper\" /nosplash"
    }
  }
}

However in VS code I can’t seem to get the syntax correct.
Using the base configuration:


    {
      "name": "Run Rhino 8 (Windows)",
      "type": "coreclr",
      "request": "launch",
      "preLaunchTask": "build-plugin-netcore",
      "program": "${env:ProgramFiles}/Rhino 8/System/Rhino.exe",
      "args": ["..."],
      "cwd": "${workspaceFolder}",
      "stopAtEntry": false,
      "console": "internalConsole",
      "env": {
        "RHINO_PACKAGE_DIRS": "${workspaceFolder}/bin/Debug/"
      }
    }

On it’s own, this works, and the splash is skipped
"args": ["/nosplash"]

However, this does not work (and the splash is shown)
"args": ["/nosplash /notemplate"]

And none of these work, either:
"args": ["/runscript=_Grasshopper"] (No message)
"args": ["/runscript=\"_Grasshopper\""] (No message)
"args": ["runscript=_Grasshopper"] (File type not supported)
"args": ["-runscript=_Grasshopper"] (No message)
"args": ["--runscript=_Grasshopper"] (No message)
"args": "/runscript=_Grasshopper" (No message)

The solution

Got there eventually, so will leave the above for posterity. VS must do something strange when concatenating the arguments. The working syntax was to use do use string rather than string[]:

"args": "/nosplash /notemplate /runscript=\"_Grasshopper\""

And, for completeness, this also resolves the quotes not parsing on Mac, too, so the following works there:

"args": "-nosplash -notemplate -runscript=\"_Grasshopper\""
1 Like

Is there an equivalent environment variable to set a grasshopper plugin search directory? Akin to:

"env": {
    "RHINO_PACKAGE_DIRS": "${workspaceFolder}/bin/Debug/"
    }

At the moment I still use GrasshopperDeveloperSettings but it would be much nicer if this automatically pointed to the project I am debugging.

You should be able to use this exact syntax to point at your Grasshopper directory, it worked in my test example (at least on mac)

If you need to use multiple args I would think you’d need to use something more like

"args": ["/nosplash", "/notemplate", "/runscript=\"_Grasshopper\""]

But it’s really good to know I can just avoid using the array syntax [] and just go for a simple string, I’ll probably use that syntax going forwards

Correct. This does work. Thankyou :slight_smile:

The equivalent for launchSettings.json in VS2022 is:

{
  "profiles": {
    "Plugin": {
      "commandName": "Executable",
      "executablePath": "C:\\Program Files\\Rhino 8\\System\\Rhino.exe",
      "commandLineArgs": "/runscript=\"_Grasshopper\" /nosplash",
      "environmentVariables": {
        "RHINO_PACKAGE_DIRS": "$(ProjectDir)\\bin\\Debug"
      }
    }
  }
}
1 Like