Fill a newly created parameter node

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,

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

Thank you, this worked well.

1 Like