GH_CPython
GH_CPython copied to clipboard
Default values for inputs
What a great plugin! I was wondering though if there is a way of setting the default values for the inputs? Many thanks, N/
Hi @buka71,
You can set them inside the python code, once you initiate the component, you might need to delete the default input _input
and add other inputs e.g. x, y, width, ...
.
Hi yes, but if I set their initial values of the inputs with the body, the input from the components that attach to them gets overwritten. If I have _x as a variable within the list of my inputs and I set _x = 5, the value that gets connected to the _x gets overwritten (If I don't, the input behaves as expected, i.e. inherits whatever I connect to it). I was wondering if there is a way of setting an initial value for _x which gets used in case nothing gets connected to that node, but gets overwritten by whatever then connects to _x.
Empty inputs are set to None
, so for an optional parameter x with a default value of 5 you could write something like:
if x is None:
x = 5