# Fill a newly created parameter node

**URL:** <https://discourse.slicer.org/t/fill-a-newly-created-parameter-node/10391>\
**Category:** Development\
**Created:** [February 22, 2020, 2:31am UTC](https://discourse.slicer.org/t/fill-a-newly-created-parameter-node/10391 "2020-02-22T02:31:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juicy](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@Juicy](https://discourse.slicer.org/u/Juicy)\
**Post date:** [February 22, 2020, 2:31am UTC](https://discourse.slicer.org/t/fill-a-newly-created-parameter-node/10391/1 "2020-02-22T02:31:20Z")

</div>

I have some confusion regarding the creation of a new parameter node for a scripted module.

I have seen in other modules that you can over-ride the base class createParameterNode method in the logic class so that you can add default parameters which are added to the parameter node when it is first created. This works well for when the module is first opened and the getParameterNode function is run. However, when I create a new parameter node from the parameter node combo box at the top of the GUI then the new parameter node is created completely blank. The issue here is I get errors when running the updateGUIFromParameterNode. For example the following line (which is used in a for loop):

`self.valueEditWidgets[parameterName].setValue(float(self.parameterNode.GetParameter(parameterName)))`

gives an error because a blank string cannot be converted to a float.

Is there some sort of standard practice to address this? Perhaps something in the SetParameterNode function which updates all the parameters based on the current state of the GUI when the parameter node was created using the combo box?

I was just asking as I don’t want to reinvent the wheel if someone else already has an elegant solution to this problem?

Thanks again,

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 22, 2020, 3:09am UTC](https://discourse.slicer.org/t/fill-a-newly-created-parameter-node/10391/2 "2020-02-22T03:09:02Z")

</div>

You need to initialize the parameter node with default values when the parameter node gets selected in the node selector:

> <https://github.com/Slicer/Slicer/blob/daecb6e24e83c02e990871b4db80e01c0e77d68a/Utilities/Templates/Modules/ScriptedDesigner/TemplateKey.py#L95>

---

<div class="post-metadata">

**Author:** ![Juicy](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@Juicy](https://discourse.slicer.org/u/Juicy)\
**Post date:** [February 22, 2020, 10:16am UTC](https://discourse.slicer.org/t/fill-a-newly-created-parameter-node/10391/3 "2020-02-22T10:16:23Z")

</div>

Thank you, this worked well.
