# Default values of ghpython inputs

**URL:** <https://discourse.mcneel.com/t/default-values-of-ghpython-inputs/71010>\
**Category:** Grasshopper Developer\
**Created:** [September 15, 2018, 5:15pm UTC](https://discourse.mcneel.com/t/default-values-of-ghpython-inputs/71010 "2018-09-15T17:15:25Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivelin.peychev](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ivelin.peychev/32/676038_2.png) [@ivelin.peychev](https://discourse.mcneel.com/u/ivelin.peychev)\
**Post date:** [September 15, 2018, 5:15pm UTC](https://discourse.mcneel.com/t/default-values-of-ghpython-inputs/71010/1 "2018-09-15T17:15:25Z")

</div>

Hi,

Is it possible to set the default values of a scripting component from inside the code in such a way that when hovering over the input the hint displays that default value?

Second question is related to the first one. Can I set the type?

NOTE: Assume that component will be compiled to .ghpy.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![piac](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/piac/32/769366_2.png) [@piac](https://discourse.mcneel.com/u/piac)\
**Post date:** [September 17, 2018, 3:17pm UTC](https://discourse.mcneel.com/t/default-values-of-ghpython-inputs/71010/2 "2018-09-17T15:17:49Z")

</div>

There are docstrings, see **point 1.4** of [Tutorial: creating a Grasshopper component with the Python GHPY compiler](https://discourse.mcneel.com/t/tutorial-creating-a-grasshopper-component-with-the-python-ghpy-compiler/38552).

The Grasshopper SDK also allows for directly setting the Description property of Inputs/Outputs, as noted by Mostapha [here](https://www.grasshopper3d.com/forum/topics/changing-the-description-of-and-input-output-in-python).

---

<div class="post-metadata">

**Author:** ![ivelin.peychev](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ivelin.peychev/32/676038_2.png) [@ivelin.peychev](https://discourse.mcneel.com/u/ivelin.peychev)\
**Post date:** [September 17, 2018, 3:25pm UTC](https://discourse.mcneel.com/t/default-values-of-ghpython-inputs/71010/6 "2018-09-17T15:25:02Z")

</div>

I know about the description, I meant about actual value/type.

I’m using your script for compiling do I need to connect containers (like Number) with some value in it while compiling?

---

<div class="post-metadata">

**Author:** ![piac](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/piac/32/769366_2.png) [@piac](https://discourse.mcneel.com/u/piac)\
**Post date:** [September 17, 2018, 4:21pm UTC](https://discourse.mcneel.com/t/default-values-of-ghpython-inputs/71010/7 "2018-09-17T16:21:23Z")

</div>

Ah, the default content, OK.

That you can set with the ‘Advanced compilation mode/Copy compilable code’ option, after you copy the code and before you compile it manually. Inside the RegisterInputParam() call, you are allowed to set defaults via the [https://developer.rhino3d.com/api/grasshopper/html/T\_Grasshopper\_Kernel\_GH\_Component\_GH\_InputParamManager.htm](https://developer.rhino3d.com/api/grasshopper/html/T_Grasshopper_Kernel_GH_Component_GH_InputParamManager.htm) `pManager` instance that you are given.

If you need a sample, please copy your `def RegisterInputParams(self, pManager):` here.

Thanks,

Giulio

–  
Giulio Piacentino  
for Robert McNeel & Associates  
[giulio@mcneel.com](mailto:giulio@mcneel.com)

---

<div class="post-metadata">

**Author:** ![ivelin.peychev](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ivelin.peychev/32/676038_2.png) [@ivelin.peychev](https://discourse.mcneel.com/u/ivelin.peychev)\
**Post date:** [September 17, 2018, 5:34pm UTC](https://discourse.mcneel.com/t/default-values-of-ghpython-inputs/71010/8 "2018-09-17T17:34:06Z")

</div>

Thanks Giulio,

I guess I’m not gonna be able to simply use your compiling.gh scripts.

I’ll have to use something else using [System.IO](http://System.IO) and acutally providing the .py files in order to automate all this.

---

<div class="post-metadata">

**Author:** ![piac](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/piac/32/769366_2.png) [@piac](https://discourse.mcneel.com/u/piac)\
**Post date:** [September 17, 2018, 5:58pm UTC](https://discourse.mcneel.com/t/default-values-of-ghpython-inputs/71010/9 "2018-09-17T17:58:03Z")

</div>

> [@ivelin.peychev](#):
>
> acutally providing the .py files in order to automate all this.

For now, just save the files in a folder. When you have tons of files to update, it will be clear what type of meta-script will be needed.

If you need to edit the `def RegisterInputParams(self, pManager):` function (provide defaults, change some behavior, etc), you will need to edit your compiled code anyways before going to compile it. So it’s just better to use the folder with the .py files as source, edit it to your needs, and compile that. Do not use the evaluated component as base all the time. That is OK if you do not compile your code.

---

<div class="post-metadata">

**Author:** ![ivelin.peychev](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ivelin.peychev/32/676038_2.png) [@ivelin.peychev](https://discourse.mcneel.com/u/ivelin.peychev)\
**Post date:** [September 17, 2018, 6:25pm UTC](https://discourse.mcneel.com/t/default-values-of-ghpython-inputs/71010/10 "2018-09-17T18:25:34Z")

</div>

> [@piac](#):
>
> Do not use the evaluated component as base all the time

What do you mean by “evaluated component”?

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/2/3/2356ed5b3e8a198cd02686f2efc664f9ad87275d.png) This?

I’m not using that, I’m compiling my own stuff.

---

<div class="post-metadata">

**Author:** ![ivelin.peychev](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ivelin.peychev/32/676038_2.png) [@ivelin.peychev](https://discourse.mcneel.com/u/ivelin.peychev)\
**Post date:** [September 17, 2018, 6:29pm UTC](https://discourse.mcneel.com/t/default-values-of-ghpython-inputs/71010/11 "2018-09-17T18:29:47Z")

</div>

Secondary question:  
How can I change the output path?  
There’s no method inside assemblySettings where I can set a path, instead of using `assemblySettings.GenerateDefaultPath()`

---

<div class="post-metadata">

**Author:** ![piac](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/piac/32/769366_2.png) [@piac](https://discourse.mcneel.com/u/piac)\
**Post date:** [September 17, 2018, 7:03pm UTC](https://discourse.mcneel.com/t/default-values-of-ghpython-inputs/71010/12 "2018-09-17T19:03:27Z")

</div>

> [@ivelin.peychev](#):
>
> What do you mean by “evaluated component”?

I mean the GhPython component on a Grasshopper canvas. I suggest to just use .py files as the source repository.

> [@ivelin.peychev](#):
>
> How can I change the output path?

You set the file name in point 2.5 of the tutorial:

```auto
import clr

clr.CompileModules("Axes.p2.7.5.0.ghpy", "Axes.py", "Axes_helper.py")

```

after the local assembly is saved to disk, you can move the file to any location.  
Again, those methods you are trying to use are simply used for the automatic one-click compilation, they are not meant for advanced customization.

---

<div class="post-metadata">

**Author:** ![ivelin.peychev](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ivelin.peychev/32/676038_2.png) [@ivelin.peychev](https://discourse.mcneel.com/u/ivelin.peychev)\
**Post date:** [September 17, 2018, 7:14pm UTC](https://discourse.mcneel.com/t/default-values-of-ghpython-inputs/71010/13 "2018-09-17T19:14:11Z")

</div>

> [@piac](#):
>
> after the local assembly is saved to disk, you can move the file to any location.

That’s kind of it, I don’t want to have to move the file, I want it to be in my project folder ready to be zipped and shipped.

> [@piac](#):
>
> Again, those methods you are trying to use are simply used for the automatic one-click compilation, they are not meant for advanced customization.

Can I make it a wish then? Why provide such a beautiful thing like compiling-sdk.gh then restrict it, not provide enough methods to make it more advanced?

All that modifying the code editing the py files, copy compilation code all this could be automated with just a few scripting components in GH. This way you can have a GH definition for each project containing the latest version of your components (assembly, plug-in, whatever).  
The update/upgrade of your project will be a single click. Isn’t that we’re all after, “…making the world a better place…”? 😉

---

<div class="post-metadata">

**Author:** ![piac](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/piac/32/769366_2.png) [@piac](https://discourse.mcneel.com/u/piac)\
**Post date:** [August 17, 2020, 6:15pm UTC](https://discourse.mcneel.com/t/default-values-of-ghpython-inputs/71010/14 "2020-08-17T18:15:17Z")

</div>

Split this topic on August 17, 2020, 6:15pm UTC

3 posts were split to a new topic: [Creating a default value for a GHPY compiled component](https://discourse.mcneel.com/t/creating-a-default-value-for-a-ghpy-compiled-component/107245)
