GH_CPython icon indicating copy to clipboard operation
GH_CPython copied to clipboard

Default values for inputs

Open natalia-wz opened this issue 5 years ago • 3 comments

What a great plugin! I was wondering though if there is a way of setting the default values for the inputs? Many thanks, N/

natalia-wz avatar Nov 05 '19 16:11 natalia-wz

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, ... .

MahmoudAbdelRahman avatar Nov 14 '19 02:11 MahmoudAbdelRahman

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.

natalia-wz avatar Nov 14 '19 09:11 natalia-wz

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

mrtnbrst avatar Sep 02 '20 19:09 mrtnbrst