# Rhino 8 How to use input code in Grasshopper script component

**URL:** <https://discourse.mcneel.com/t/rhino-8-how-to-use-input-code-in-grasshopper-script-component/169547>\
**Category:** Scripting\
**Tags:** windows\
**Created:** [November 19, 2023, 10:50am UTC](https://discourse.mcneel.com/t/rhino-8-how-to-use-input-code-in-grasshopper-script-component/169547 "2023-11-19T10:50:49Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![kitjmv](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/kitjmv/32/510467_2.png) [@kitjmv](https://discourse.mcneel.com/u/kitjmv)\
**Post date:** [November 19, 2023, 10:50am UTC](https://discourse.mcneel.com/t/rhino-8-how-to-use-input-code-in-grasshopper-script-component/169547/1 "2023-11-19T10:50:50Z")

</div>

Hello,  
I don’t know if it’s a bug or if I don’t know how to use the component but the component can’t read the “Input” input:

  
jmv

---

<div class="post-metadata">

**Author:** ![Mahdiyar](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/mahdiyar/32/472862_2.png) [@Mahdiyar](https://discourse.mcneel.com/u/Mahdiyar)\
**Post date:** [November 19, 2023, 3:31pm UTC](https://discourse.mcneel.com/t/rhino-8-how-to-use-input-code-in-grasshopper-script-component/169547/3 "2023-11-19T15:31:38Z")

</div>

According to the error text, it is necessary to set the override language on the parameter

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/d/f/b/dfb3134693417ce1db66513ab4a6c7944992b772.png)

You can also set it to automatic and then add the following line at the beginning of your code:

```csharp
//#! csharp

```

```python
#! python

```

 ![script](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/a/f/5/af56f343a18c34d2fe3169101251e0aab5b26c9e.png)

---

<div class="post-metadata">

**Author:** ![kitjmv](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/kitjmv/32/510467_2.png) [@kitjmv](https://discourse.mcneel.com/u/kitjmv)\
**Post date:** [November 19, 2023, 4:00pm UTC](https://discourse.mcneel.com/t/rhino-8-how-to-use-input-code-in-grasshopper-script-component/169547/4 "2023-11-19T16:00:35Z")

</div>

Thank you @Mahdiyar !  
You know all the tricks of this new component!! 🙂

Setting the language with either method effectively suppresses error messages. But unfortunately the component does not seem to be executed and it does not create any results:

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/9/a/a/9aac45d22d30b0d35ed8304a19956b9678ba3384.png)

---

<div class="post-metadata">

**Author:** ![RIL](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ril/32/477371_2.png) [@RIL](https://discourse.mcneel.com/u/RIL)\
**Post date:** [November 19, 2023, 11:01pm UTC](https://discourse.mcneel.com/t/rhino-8-how-to-use-input-code-in-grasshopper-script-component/169547/5 "2023-11-19T23:01:03Z")

</div>

> [@kitjmv](#):
>
> the component does not seem to be executed and it does not create any results

I also experienced this last week - a C# component suddenly stopped working while I was coding in it. Just dead. The component didn’t respond even after closing and restarting Rhino.

There’s too much magic going on in the component during development, it lags and it become unstable. Less magic would be better I think.

//Rolf

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/477962_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [November 20, 2023, 11:25pm UTC](https://discourse.mcneel.com/t/rhino-8-how-to-use-input-code-in-grasshopper-script-component/169547/6 "2023-11-20T23:25:18Z")

</div>

@kitjmv Currently you can NOT use a `ScriptInstance` implementation as an input code mostly due to the fact that `ScriptInstance` can implement `BeforeSolve` and `AfterSolve` methods but the script itself is only accessible when the main component is trying to solve.

You should be able to use a normal C# script like this as input:

```csharp
// #! csharp
using System;

a = Math.Abs((double)x) + Math.Abs((double)y);

```

 ![Rhino_AZ4gVmsut2](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/4/f/3/4f364186ebaeee04b1056a602d05f161d962ee41.png)

There was a bug in processing `// #! csharp` directive that I’m fixing for the next build. Thank you!

[RH-78488](https://mcneel.myjetbrains.com/youtrack/issue/RH-78488) Script fails to determine language from lang id specifier line

---

<div class="post-metadata">

**Author:** ![kitjmv](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/kitjmv/32/510467_2.png) [@kitjmv](https://discourse.mcneel.com/u/kitjmv)\
**Post date:** [December 2, 2023, 4:50am UTC](https://discourse.mcneel.com/t/rhino-8-how-to-use-input-code-in-grasshopper-script-component/169547/7 "2023-12-02T04:50:26Z")

</div>

Hello @eirannejad,  
It works correctly.  
Unfortunately, editing the code in a dedicated editor like VSCode returns errors because the input and output parameters (`x`, `y`, à`) are not declared.  
jmv

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/477962_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [December 4, 2023, 6:33pm UTC](https://discourse.mcneel.com/t/rhino-8-how-to-use-input-code-in-grasshopper-script-component/169547/8 "2023-12-04T18:33:43Z")

</div>

Ya it’s gonna be a while until I get to incorporate all of this in the vscode plugin 😃 I’ll think of something to make these input and output parameters availabe in the main ScriptEditor so you can edit from there

---

<div class="post-metadata">

**Author:** ![kitjmv](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/kitjmv/32/510467_2.png) [@kitjmv](https://discourse.mcneel.com/u/kitjmv)\
**Post date:** [September 28, 2024, 8:22am UTC](https://discourse.mcneel.com/t/rhino-8-how-to-use-input-code-in-grasshopper-script-component/169547/10 "2024-09-28T08:22:38Z")

</div>

Hello @eirannejad  
Is this feature still relevant?  
It seems to me that it is no longer possible to link source code to components?

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/477962_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [September 28, 2024, 4:48pm UTC](https://discourse.mcneel.com/t/rhino-8-how-to-use-input-code-in-grasshopper-script-component/169547/11 "2024-09-28T16:48:13Z")

</div>

I haven’t gotten a chance to work on the vscode plugin but it is still on my list

---

<div class="post-metadata">

**Author:** ![kitjmv](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/kitjmv/32/510467_2.png) [@kitjmv](https://discourse.mcneel.com/u/kitjmv)\
**Post date:** [September 28, 2024, 10:04pm UTC](https://discourse.mcneel.com/t/rhino-8-how-to-use-input-code-in-grasshopper-script-component/169547/12 "2024-09-28T22:04:07Z")

</div>

🙂 No, we are not on the VSCode thread.  
I was talking about the script entry in a Grasshopper component.  
It seems that it has disappeared in the commercial version of Rhino 8.  
 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/7/8/a/78a9b6d25b2ebdf9cf313d546ab78bce1e968a2f.png)

---

<div class="post-metadata">

**Author:** ![11159](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/11159/32/765292_2.png) [@11159](https://discourse.mcneel.com/u/11159)\
**Post date:** [September 28, 2024, 11:44pm UTC](https://discourse.mcneel.com/t/rhino-8-how-to-use-input-code-in-grasshopper-script-component/169547/13 "2024-09-28T23:44:29Z")

</div>

Hello,  
Shift + Right mouse button click.

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/477962_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [September 29, 2024, 12:44am UTC](https://discourse.mcneel.com/t/rhino-8-how-to-use-input-code-in-grasshopper-script-component/169547/14 "2024-09-29T00:44:42Z")

</div>

Nah it’s all there. We decided to keep the context menu simple but as @11159 mentioned you can get that with Shift+Click. Here is a bunch more stuff there that [are described in this 👉 guide](https://developer.rhino3d.com/guides/scripting/scripting-gh-python/)

---

<div class="post-metadata">

**Author:** ![kitjmv](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/kitjmv/32/510467_2.png) [@kitjmv](https://discourse.mcneel.com/u/kitjmv)\
**Post date:** [September 29, 2024, 12:54am UTC](https://discourse.mcneel.com/t/rhino-8-how-to-use-input-code-in-grasshopper-script-component/169547/15 "2024-09-29T00:54:41Z")

</div>

Hi @eirannejad  
Really, the new script editor looks great.  
I just spent a week configuring the toolbars in Rhino 8 and I have the impression that the new editor is going to be a big part to learn.  
I can’t wait to use it! Congratulations on the work!!!

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/477962_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [September 29, 2024, 12:58am UTC](https://discourse.mcneel.com/t/rhino-8-how-to-use-input-code-in-grasshopper-script-component/169547/16 "2024-09-29T00:58:06Z")

</div>

Thank you 😃

---

<div class="post-metadata">

**Author:** ![bbalbastre](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/bbalbastre/32/643080_2.png) [@bbalbastre](https://discourse.mcneel.com/u/bbalbastre)\
**Post date:** [June 3, 2025, 9:24am UTC](https://discourse.mcneel.com/t/rhino-8-how-to-use-input-code-in-grasshopper-script-component/169547/17 "2025-06-03T09:24:30Z")

</div>

Regarding the `ScriptInstance` limitation is that something that can be worked around? Would it be possible to modify the code in a way that avoids this issue?

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/477962_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [June 3, 2025, 3:54pm UTC](https://discourse.mcneel.com/t/rhino-8-how-to-use-input-code-in-grasshopper-script-component/169547/18 "2025-06-03T15:54:31Z")

</div>

It is certainly possible but hasn’t had much request to make it work. I reopened the ticket below. Would you mind telling me about your use case?

[RH-81986](https://mcneel.myjetbrains.com/youtrack/issue/RH-81986) Support ScriptInstance in input scripts

---

<div class="post-metadata">

**Author:** ![bbalbastre](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/bbalbastre/32/643080_2.png) [@bbalbastre](https://discourse.mcneel.com/u/bbalbastre)\
**Post date:** [June 4, 2025, 11:22am UTC](https://discourse.mcneel.com/t/rhino-8-how-to-use-input-code-in-grasshopper-script-component/169547/19 "2025-06-04T11:22:02Z")

</div>

@eirannejad the reason is that my team and I are working on a project, and we’ve created a template for starting new scripts. This template includes some C# code. The problem is that once people start using the template, I can’t update the component anymore because it’s already embedded in their files.

So, I thought about storing the C# code on a shared server instead. That way, the component can reference the code from the server. This would allow me to update the code whenever needed, and those changes would automatically apply to all files using the template.

I am also opened to suggestions

[C# component in multiple GH files: how to keep updated? - Grasshopper - McNeel Forum](https://discourse.mcneel.com/t/c-component-in-multiple-gh-files-how-to-keep-updated/205389)

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/477962_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [June 4, 2025, 5:50pm UTC](https://discourse.mcneel.com/t/rhino-8-how-to-use-input-code-in-grasshopper-script-component/169547/20 "2025-06-04T17:50:29Z")

</div>

Sounds like a Grasshopper plugin would be a better choice instead of using scripted components especially if you are already writing this in C#

---

<div class="post-metadata">

**Author:** ![Anthony\_Chu1](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/anthony_chu1/32/748161_2.png) [@Anthony\_Chu1](https://discourse.mcneel.com/u/Anthony_Chu1)\
**Post date:** [August 24, 2026, 4:20pm UTC](https://discourse.mcneel.com/t/rhino-8-how-to-use-input-code-in-grasshopper-script-component/169547/21 "2026-08-24T16:20:45Z")

</div>

The VS Code diagnostics happen because `x`, `y`, and the output variables are free variables in the standalone file; VS Code cannot see the wrapper that Grasshopper creates at runtime.

[Ghost Writer](https://www.food4rhino.com/en/app/ghost-writer) approaches this by generating a complete project with an explicit `Run(...)` or `run(...)` method signature matching the component ports. The IDE therefore sees declared arguments and project references, and saving the file updates the live Grasshopper component.

It is a per-component project workflow rather than one central script automatically updating every component in every company file. Disclosure: I’m the developer.
