# Dynamically setting input defaults for a ghpython component

**URL:** <https://discourse.mcneel.com/t/dynamically-setting-input-defaults-for-a-ghpython-component/92640>\
**Category:** Grasshopper\
**Created:** [November 23, 2019, 12:16pm UTC](https://discourse.mcneel.com/t/dynamically-setting-input-defaults-for-a-ghpython-component/92640 "2019-11-23T12:16:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kane\_Borg](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/kane_borg/32/674831_2.png) [@Kane\_Borg](https://discourse.mcneel.com/u/Kane_Borg)\
**Post date:** [November 23, 2019, 12:16pm UTC](https://discourse.mcneel.com/t/dynamically-setting-input-defaults-for-a-ghpython-component/92640/1 "2019-11-23T12:16:56Z")

</div>

What is the syntax used to set a default input in ghpython?  
How do you access pManager to set the default input value for that Param?

Grasshopper.Kernel.Parameters.Param\_GenericObject("", “”, “”, ??.GH\_ParamAccess, input\_value)

I need to set it so that when the gh file is reopened the last set default is still there.

---

<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:** [November 23, 2019, 3:19pm UTC](https://discourse.mcneel.com/t/dynamically-setting-input-defaults-for-a-ghpython-component/92640/2 "2019-11-23T15:19:43Z")

</div>

I am not exactly sure what you are after, but you can have access to `pManager` when you compile the script yourself, after copying the compilable code.

---

<div class="post-metadata">

**Author:** ![Joseph\_Oster](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/joseph_oster/32/549124_2.png) [@Joseph\_Oster](https://discourse.mcneel.com/u/Joseph_Oster)\
**Post date:** [November 23, 2019, 5:06pm UTC](https://discourse.mcneel.com/t/dynamically-setting-input-defaults-for-a-ghpython-component/92640/3 "2019-11-23T17:06:07Z")

</div>

Not Python but…

> [@Default value in Cluster](https://discourse.mcneel.com/t/default-value-in-cluster/92375/5):
>
> If this was a matter of replacing nulls, you could try to see if Combine works. It operates on multiple inputs and outputs the first input value which isn’t null: [cluster defaults.gh](https://discourse.mcneel.com/uploads/short-url/iQJH4PYCSkg8QdLE9OnxhpvCCcx.gh) (11.9 KB) However this doesn’t just provide a single default value, it will also overwrite any actual nulls you’re inputting.

[![](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/8/e/8ede05732aa17dc2b5af5f9183272f6db4d8bdf5.png) ](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/8/e/8ede05732aa17dc2b5af5f9183272f6db4d8bdf5.png)

---

<div class="post-metadata">

**Author:** ![Kane\_Borg](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/kane_borg/32/674831_2.png) [@Kane\_Borg](https://discourse.mcneel.com/u/Kane_Borg)\
**Post date:** [November 24, 2019, 9:51am UTC](https://discourse.mcneel.com/t/dynamically-setting-input-defaults-for-a-ghpython-component/92640/4 "2019-11-24T09:51:06Z")

</div>

Aware of this method but I specifically need a ghpython solution for a compiled component.

---

<div class="post-metadata">

**Author:** ![Kane\_Borg](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/kane_borg/32/674831_2.png) [@Kane\_Borg](https://discourse.mcneel.com/u/Kane_Borg)\
**Post date:** [November 24, 2019, 9:51am UTC](https://discourse.mcneel.com/t/dynamically-setting-input-defaults-for-a-ghpython-component/92640/5 "2019-11-24T09:51:40Z")

</div>

Any example for the syntax used in python to do this?

I have a simple component that updates the number of inputs depending on what is connected downstream, these inputs are set with default values so if the user does not connect anything to them the component takes the default values.
