Hi, I have been trying to have create code block in dynamo that takes 2 inputs (evaluates input 1 to see if it is greater than 8 or not; if greater than 8 then I want the software to apply a certain formula…if not want to do something else). But I seem to been having difficulty having the function run…it give me a null response…could you please help…please see below:
def FunctionName (input1,input2)
{
S=(input1>8? 1.5*(input1-8)(input2)+(8input2):input1*input2);
return=s;
};
r=FunctionName(11,2);
There are a number of problems:
-
You can’t use a ternary operator in associative DesignScript blocks. You need to declare a Imperative block instead. This applies to any if statement
-
Ternary operators currently don’t work in Imperative definitions anyway, the bug has been reported on Dynamo GitHub, so you need to use an if statement block instead
-
You have typo’s. ‘s
’ and ‘S
’ are two different objects
-
More typo’s: input2
and 8input2
-
missing a binary operator here (i assume you meant to multiply hence the typo of ‘8’?): (input1-8)(input2)
Check out the Dynamo DesignScript intro here
Thanks Thomas it was very helpful and solved the bug!!! I appreciate the help.