Operator Problems

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

Thanks for the reply David. I thought it may have something to do with lacing and trying out what you suggest, Im only getting more lists in lists. Maybe Im approaching this incorrectly, just need to pull items from two lists based on True/False

try this:

indx = test ? 0 : 1 ;
rslt = [ trueSet , falseSet ] [ indx ] ;

Hi Jacob,
Im still getting Lists in lists. This is probably easily done in python but feel designscript should suffice

Hi @gduffy6SEQG,

Are you willing to share your graph? There might be an easier way of going about this.

Hi,

A basic sample explains it here. I want Lists 2&3 to join based on List1 boolean to create List 4.

# 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
1 Like

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

1 Like