DesignScript vc Formula (IF statement)


#1

After BiLT EUR 2018 thanks @solamour I am really keen on Design Script approach.
I tested my current codes and found one example with issue.
Any idea why my formula is not working any more? It used to work fine before. Now I am on Dynamo 1.3.3.411 and have to use alternative so for me will be great practise with Design Scripts.
This is super simple but can I simplified my code. Do I alway need have: result and data?

x;
y;
z;
data = [Imperative]
{
	if(x == true)
		{
			result = y;
		}
	else
		{
			result = z;
		}
	return = result;
};



#2

Hey,

I certainly get more true’s than i was expecting, it’s obviously matching the length of the longer input…

Hopefully @solamour can explain why…

I also find it interesting that the formula node doesn’t care whether True has a T or a t, and that it doesn’t care if it has a = or a ==.

Mark


#3

Incidently, if you aren’t aware, this is how Clockwork achieves the If with different list lengths…


#4

Hi @Michal_Dengusiak DS ternary operators cant return singletons and lists. The deepest rank will fix the replication (basically it defaults to ‘longest lacing’ using Dynamo terminology) which is why you get different results then the if statement, which can handle outputting singletons and lists from its arguments. I believe this is a limitation in DS - I reported it ages ago on the GitHub but it looks like nothings changed…


#5

thanks @Thomas_Mahon for your great session at BiLT EUR 2018…:grinning:
great this is logged now
this is interesting to see 486 Issues open under Dynamo GitHub today


#6

For using DesignScript I typically create an If statement as follows: