For quite some time I have run into issues with the IF node in Dynamo. It seems to have issues when you are presenting lists of different lengths. To avoid this I have created a little Python script that does the work for me. The python code might not be to pretty but so far it works.
My IF node keeps evolving I have removed the previous lines and replaced them:
“””
LIST: Replacement of Dynamo IF node
“””
__author__ = Daniel Gijsbers
__version__ = ‘2.0.0’
# Enable Python support and load DesignScript library
import clr
clr.AddReference(‘DSCoreNodes’)
import DSCore
from DSCore import *
# The inputs to this node will be stored as a list in the IN variables.
ToF = IN[0] # a boolean
List1 = IN[1]
List2 = IN[2]
Result = []
if ToF == True:
Result.append(List1)
else:
Result.append(List2)
# Making use of Design script for flattening
OUT = List.Flatten(Result,2) # The second input allows for the level of flattening
The code >
My IF node keeps evolving I have removed the previous lines and replaced them:
“””
LIST: Replacement of Dynamo IF node
“””
__author__ = Daniel Gijsbers
__version__ = ‘2.0.0’
# Enable Python support and load DesignScript library
import clr
clr.AddReference(‘DSCoreNodes’)
import DSCore
from DSCore import *
# The inputs to this node will be stored as a list in the IN variables.
ToF = IN[0] # a boolean
List1 = IN[1]
List2 = IN[2]
Result = []
if ToF == True:
Result.append(List1)
else:
Result.append(List2)
# Making use of Design script for flattening
OUT = List.Flatten(Result,2) # The second input allows for the level of flattening
The code >
The output of this node goes into another Python node that creates worksets.
Credit to John from sixtysecondrevit for that bit of Python Code.
Dynamo IF node