Its a relativly simple thing I am stuck with
I cannot use multiple inputs in Python editor. For example just x = IN works, but if I use x=IN , y=IN, then I get error.
The error is that you’re trying to iterate over a list but you’re only providing a singleton. Are you sure
intB is a list?
my bad, you are correct. Could you please guide me how could I input a single Variable, Interger inside Pyhon IN node ? I tried IN()… doesnt work either
@hassan.orion you already did that by declaring “intB=IN”, assuming that intB is a single variable (an integer in your case).
As @goncalogbastos mentioned, your input is whatever you provide. You declare it as
intB is a singleton. The problem is that you then say
for x in intB, which means for each item
x within list
intB is not a list to iterate through. You want to get rid of the
for loop and use
intB instead of
As an aside, if you’re going to have multiple if statements in your loop, with the intention of only one of those conditions being satisfied, you should use
elif. The reason is that if you only use
if, the code will go through and check every single condition, if you use one
if followed by
elifs, it will stop as soon as one of those conditions is satisfied.
More of an explanation and a diagram towards the bottom of this page here.
To add to the suggestions, for most of my python based custom nodes I use these functions to force singletons into a list whenever iteration is involved:
# Define list/unwrap list functions def tolist(input): result = input if isinstance(input, list) else [input] return result def uwlist(input): result = input if isinstance(input, list) else [input] return UnwrapElement(result) # Preparing input from dynamo to revit element = IN elements = tolist(IN) uw_list = uwlist(IN)