Hi, Im trying to use the Ternary Operator (?) to use an item from 1 list if its true otherwise pull from other list. However it will only evaluate based on the shorter list. My resulting list has only 4 items which corresponds to my false list. If I pull the ‘b’ value it will evaluate all and use ‘null’ for false.
What am I doing wrong ?
Try changing the lacing strategy on the code block. The primer explains how to do it : DesignScript Syntax | The Dynamo Primer
try this:
indx = test ? 0 : 1 ;
rslt = [ trueSet , falseSet ] [ indx ] ;
Hi @gduffy6SEQG,
Are you willing to share your graph? There might be an easier way of going about this.
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('DSCoreNodes')
import DSCore
from DSCore.List import *
# Inputs
short_list = IN[0]
a_list = IN[1]
b_list = IN[2]
# Output list
result = []
min_a = 0
min_b = 0
# Loop check for each point in the short list
for s in short_list:
# List for distances
if s == "True":
min_inda = DSCore.List.GetItemAtIndex(a_list,min_a)
result.append(min_inda)
#min_a +=1
else:
min_indb = DSCore.List.GetItemAtIndex(b_list,min_b)
result.append(min_indb)
min_b +=1
min_a +=1
# Output the results
OUT = result
Thank you, the python code does it for me. Appreciate your time.
It seems that without some knowledge of python, I’ll just keep hitting road blocks within dynamo. Must put in the hours to learn




