[Update] ScriptParasite 2: Compatibility with Rhino 8 script editors

Hi all,

I’ve just released a new version of ScriptParasite 2, that can connect to the newer C# and now also Python components. It’s currently available through the package manager as ScriptParasite 2, and obviously, only available for Rhino 8.

This allows you 2-way synchronisation between Rhino and more capable editors such as VSCode, Rider, Visual studio, to do quick prototyping with scripts, and allow easier access to functions such as code completion, AI editting and similar things.

The script parasite for the older versions also remains available as a seperate package.

It’s also available on food4rhino, but with the current requirements for differing builds and .net framework/.net core situations I highly recommend using the package manager over manually installing this.

Disclaimer:

It should be compatible with Rhino for Mac, but I do not own a mac, so I have no way of really testing this. Python support seems to work pretty well as well, but as I do not use python that much, I can’t really tell if this will work.

Let me know what you think!

9 Likes

Christmas come early! Thanks for this it is so valuable. @arendvw Really appreciate your effort in making these great plugins.

1 Like

Just tested it on Mac and it works like a charm! I’ve been wanting to transition to using Mac for a long while, and scripting components was always an issue. Thanks again!

1 Like

Thanks so much for checking, this is super valueable!

Do the right click (open folder/file) actions also work?

Open File worked, no issues. With Open Folder, I couldn’t see any response.

(I should also note that as with the previous version, that on Mac, when plugged into a Legacy C# it crashes Rhino. The new C# nodes are no problem.)

Hi @arendvw nice to see this working again, now we can use the scripts with much wider variety of tools! One questions, how do we reference the rhino SDKs in the external files? I see the project file is no longer created so we have to make a new one?

Hey anton, good question!

I’ll try to add it back. Right now this should work:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net90</TargetFramework>
    <LangVersion>11</LangVersion>
    <NoWarn>CS7011</NoWarn>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="GH_IO">
      <HintPath>C:\Program Files\Rhino 8\Plug-ins\Grasshopper\GH_IO.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="Grasshopper">
      <HintPath>C:\Program Files\Rhino 8\Plug-ins\Grasshopper\Grasshopper.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="RhinoCommon">
      <HintPath>C:\Program Files\Rhino 8\System\netcore\RhinoCommon.dll</HintPath>
      <Private>False</Private>
    </Reference>
  </ItemGroup>
</Project>

But just referencing the RhinoCommon and Grasshopper packages as nuget should also work.

1 Like

Hi @arendvw , maybe a silly question but not sure why I can’t see ScriptParasite 2 on package manager or on Food4Rhino. I can only see this one and the latest version in this is from 2023. Do I need a specific version of Rhino 8 to be able to have it? I am currently on Rhino 8.14. But regardless I was assuming I would be able to see it on Food4Rhino. Thanks!

I’ve just uploaded it. Regardless, the preferred way of installing it is using the package manager in Rhino, because there are 4 different versions for different combinations of rhino/mac and dotnet frameworks.

Do you mean that if ScriptParasite 2 is plugged into an old component it crashes? Or the old library crashes?

Thanks that helped

Hi, I’m a complete beginner when it comes to coding. I find it much more convenient to work in VS Code, partly because of Codex or Copilot, which help me analyze and explain code snippets in a comfortable way.

Would it be possible to have autocompletion in VS Code work just like it does in the native Grasshopper Script Component? I think this might be related to the issue I paste below. Maybe over the years something has changed, and it would now be easier to implement. It would be wonderful if, when working in VS Code with Script Parasite, we didn’t lose any of the features offered by the Grasshopper Script Component.

GHpython VScode AutoComplete - Grasshopper - McNeel Forum

Having autocomplete as such is helpful for the beginners.

Hi Barden, thanks for asking.

For python I’m not sure, but for C# it’s really doable (It’s the reason I wrote this in the first place, without autocomplete coding is a lot less efficient). My experience is that autocomplete and code navigation in VSCode is really good.

For VSCode, these are the prerequisites:

Install vscode
Download & Install vscode

Install .NET SDK
Install .NET SDK 9 for the latest rhino 8 version. Older versions might require .net sdk 7 or 8.
Browse all .NET versions to download | .NET

Install C# Dev Kit extension for VSCode
C# Dev Kit - Visual Studio Marketplace

Place a project file called scripts.csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net90</TargetFramework>
    <LangVersion>11</LangVersion>
    <NoWarn>CS7011</NoWarn>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="GH_IO">
      <HintPath>C:\Program Files\Rhino 8\Plug-ins\Grasshopper\GH_IO.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="Grasshopper">
      <HintPath>C:\Program Files\Rhino 8\Plug-ins\Grasshopper\Grasshopper.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="RhinoCommon">
      <HintPath>C:\Program Files\Rhino 8\System\netcore\RhinoCommon.dll</HintPath>
      <Private>False</Private>
    </Reference>
  </ItemGroup>
</Project>

This will link to your current Rhino Version and autocomplete automatically.

Other popular editor for C# are JetBrains Rider (not free) and Microsoft Vistual Studio (available for free for most)

1 Like

On Mac, whether Script Parasite v1, or v2, if connected to a Legacy C# component, crashes Rhino. v2 works fine with the Rhino 8 new C# Script Component.

Hi @arendvw

Sorry to bother you, but there is one other issue:

Script Parasite v1 would give a class name with an additional number-code of something like:

public abstract class Script_Instance_98c00 : GH_ScriptInstance...
(so each class was different)

Now the names for the Parasite v2 classes are all:

public class Script_Instance : GH_ScriptInstance

This produces a lot of errors in VS Code due to:

‘Script_Instance’ does not implement inherited abstract member ‘GH_ScriptInstance.InvokeRunScript (IGH_Component, object, int, List, IGH_DataAccess)’ [GrasshopperScripts]

Is this this stemming from the new C# Script component or is it relative to something in Parasite v2 itself?

Any pointers would be great!

Thanks,

Ash

1 Like

Ah, yeah, this makes sense. For all intends and purposes ScriptParasite 1 was way more complex. For 2, I can leave most code alone.

I’ll add something that:

  • Creates a GH_ScriptInstance mock class (does not really have to do anything, just provide stubs for relevant data)
  • I think adding a namespace would help here. I need to check what helps here, I try to touch the input/output as less as possible.
1 Like

Allright, V2 should not really be able to connect to a legacy component anyway, so there’s one bug.

Did you catch any error messages when it crashes?

No, unfortunately not. It just did that thing where it pauses, grimaces and disappears.

Hello @arendvw . Many thanks for getting script parasite to work again. I’ve finally got around to working with grasshopper more and will be using C# and script parasite. One question in relation to adding the ItemGroups for Rhino and Grasshopper: I was using VScode before with the old parasite and now am using VStudio community edition 2022. I understood how to add the ItemGroups in VScode and if I had a .csproj file in VStudio I could add them there. But all I see with the new parasite is a .cs file which is fine, I can open it with Studio and make edits and when I save them they show up in the C# component in GH. But if I want to compile in VStudio?

My question is should I make a blank project in VStudio and then add the .cs file generated by the new parasite? I’m a little bit of a dummy when it comes to nuget and have not completely learned how to make VStudio dance and sing.
Once again, thanks for all your work.

Joe

Hey Joe, I think the solution is here, copy paste the csproj and it should work:

Note: You can get design time support (completion during editting), but you can’t compile this into a .dll this way.