Node default input another node

Hi, how do I get the default to be the python code if the user doesn’t put something in?

Instead of putting the ‘if node’ in there, put both items into the next Python node.

elevationType = IN[5]
if elevationType == None: elevationType = IN[5]

Note that as you’re passing a nested list of var things get more complex, so be sure that your ElevationType node is outputting the right structure. My gut says you want that input to be ‘var’.

1 Like

Use the python script to test

if IN[0]:
    OUT = IN[0]
else:
    OUT = "My default"

also set default in the input node
image

2 Likes

Python comparison syntax for None uses the is and is not operators - see PEP 8

I’m pretty confused sorry. Do you mean the main python node?

While generally I don’t like Pep 8 (and don’t bother to follow it’s recommendations at all as it isn’t applied within the community and IMO is actually not helpful for the majority of the Dynamo community), that’s a good call here.

Yes. Put those lines in the Python Script node (using whatever variable you call out in the code rather than what I named it).

Like this? :sweat_smile:

Yes, I’m not too fussed about being pythonic, I just use Ruff in VSCode and forget about it

1 Like

Like this?

image

Yes - looks like it. If that doesn’t work, then my guess is there is an issue with the list structure (see my previous comment on var[]..[]).

should the input be blue though for the default input? The list structure is just one input not in a list
image

Not at a PC, but try changing the input mode to:
elementTypes: var = null //add a description too

Slowly maybe getting it, appreciate the patients. Put the node on default input but it didn’t run when its a node. When its taken out the node and run in the project it works. Is the default input a list?

Editing a node from a project is a bit annoying. Its always autosaving to the project name. Not sure if you know a way to stop that?
ElevationByCropCurves.dyf (17.5 KB)

ok changing it to an elementtype input stuffed it up wanting specific inputs for everything I think. Back to var and its working again. Thanks for the help!

Sadly a long standing bug. Can you log it to the GitHub as an issue so we can get the Dev team’s attention?

1 Like