C# scripting component on Mac

I’ve noticed on the most recent Grasshopper version on Mac the presence of the Python scripting component. When can we expect to see the C# scripting component on Grasshopper for Mac?

Thanks!

Porting the c# scripting component is on the list of issues to resolve. When it gets resolved, we’ll be sure to let you know!

1 Like

It’s good to know! Thanks! I’m eager for that one!

Our initial C# script components are in the latest RhinoWIP. Please give them a try.

1 Like

Those are great news! I’ll give it a try.

is there a boilerplate or some sample scripts? When I open the component the template is empty and the code I pasted seems having lots of syntax issues.

thanks !

Since this is still being worked on, there are several things that will change. For now, this is an image which compares the windows version to the mac version:

So the space to write code is in the scope of the RunScript method which defines the input and output parameters.

private void RunScript(object x, object y, ref object A)
{
    //Write your code here
}

At the moment, you do not see that. I’ve not changed the types to the default x and y inputs, and thus they are of type object. There is one output A defined by default. You can change the number of inputs and outputs, as well as the type of input. If you change the input types, you would not see them as type object as in the code above, but as the type that you specify. In the future, this will be made clearer.

In the meantime, let us know what type of code you are trying to run and we’ll see how we can help you.

thanks for the reply, interesting to see how scripting matures. I am starting to use Gh, so plenty of work ahead.
To this issue, there may be an issue with how .net/mono is referenced by the plugin, see the error in the picture. I get different result than you.

both including the RunScript declaration and omitting it, any other hint about the cause of it ?

Remove the ().

thanks! that did work.

I need to study what are the different methods and classes you have accessible on mac release compared to windows.

For example, this other example did not work. Is any documentation available regarding API and sdk for mac specific use?

This should be the same. The issue is that you need tell the component what the inputs are. Are they single values, lists, data trees? Are they integers, double, lines, surfaces? On the windows version, this info shows up in the editor. In the future, it should show up on the Mac editor.
Right-click on the inputs and change their type to double (the type hint submenu).
That being said, you can go to http://developer.rhino3d.com/wip/api and choose the RhinoCommon Mac WIP to see the latest docs for the platform.

Thanks for the link and type indication!

Hello!

First if all, the C# component has great potential, so big thx for that!

Any chance to use an external editor like TextMate (https://macromates.com)?

How to work with custom classes? I can write classes in the ‘overrides’ section of the gh c# editor, but they’re accessible from the same component only. Other components within the same gh project will get instances created from these classes as objects only. Is there a way to share classes among multiple c# components?

Not at the moment, not with the embedded C# editor - which is quite limited in functionality right now on macOS.

It sounds like you want to write a custom component, rather than just do some C# “scripting.” Have you found these guides?

The “Installing Tools (Mac)” guide for Grasshopper needs to be updated, but the steps for RhinoCommon should work, until we’ve had a chance to update them.

Does that help? That way you can write core code that is shared between different components.

AFAIK, no. This is the same as in the Windows c# editor. If you want to pass custom classes around you’ll need to write a custom assembly (GHA)

Hello!

How to implement the function of //Custom additional code// in mac c# script editor?

1 Like

Hello! I just started using the C# component on mac (Rhino6). I am following Long Nguyen’s tutorial on YouTube and I noticed that when I open the C# Script Editor on gh, it is completely empty whereas Long’s editor shows a lot of default code. The weird thing is that whenever I get an error, it shows “line 73” or something like that even if my code is only a few lines long, so I’m assuming that the default code is actually there even if I cant see it.

Yeah! It’s lame! I have gotten used to it, but after a 4 years and still no code suggestion, incorrect line numbering and with the two latest rhino versions a strange formatting issue. Every time I open the script editor I get a large gray area around the white code editor.

The mac C# script editor really needs some love!

1 Like

Thanks for replying. I have one question: Is there a way to write code in different scopes without seeing the default code on the editor? i.e. writing persistent data.

Same question here. How to write custom additional code on Mac version?