The setup() method is not supposed to be called when a node is added. Otherwise setup() must be written in a way that it can easily be called multiple times without side effects.
If there is a general setup procedure of a tool, for example, adding options, this has to be done in init(). init() is called when the tool instance is created. Note that in the init function, you have no access to the option values yet. If you need to apply some logic on the option values that can not be covered by a template string, you have to implement init to create the dynamic options and setup to change the values based on the current configuration.
The
setup()
method is not supposed to be called when a node is added. Otherwisesetup()
must be written in a way that it can easily be called multiple times without side effects.If there is a general setup procedure of a tool, for example, adding options, this has to be done in
init()
.init()
is called when the tool instance is created. Note that in theinit
function, you have no access to the option values yet. If you need to apply some logic on the option values that can not be covered by a template string, you have to implementinit
to create the dynamic options andsetup
to change the values based on the current configuration.