If, elseif statement Error occur

Hi dynamo forum.

Im work with dynamo for modeling rebar automatically.

All I want to do is return the List via boolean statement.

The image below is what i write for my purpose, but the codeblock do not return the right thing.

As you can see variable booleanCheck is true, and it must return Curvestartpoint via codeblock.

but codeblock return null.

and I changed the input each other (istrue to null list and isfalse to startpoint list) but the same error occur.

what can i do?

Need your help

Changing ‘a=[Imperative]’ to ‘return=[Imperative]’ should do the trick. The ‘a’ is meaningless here.

1 Like

Dear @Hamish .

Thanks for your opinion but it donot work

I have made some codeblock which return something via condition but Kind of this error is first.

Can you teach me some more tricks?

Ah sorry then - first thing that caught my eye when I had a quick look at it, I’m no master with DesignScript. Calling ‘return = [Imperative]’ may be for when it’s part of a custom function rather than just a code block. Looks like your setup will work fine with the OOTB “If” node though if you need a quick solution.

Looking closer now, I think its likely a list level issue as if I copy your code block with simple inputs it’s fine, but if I throw it a list of booleans it breaks. I’d probably still lean towards using the OOTB if node, or simplifying your designscript to a single line command e.g:

1 Like

elseif is used in addition to else, not without

check;
iftrue;
iffalse;
[Imperative]
{
	if (check)
	{
		return iftrue;
	}
	else
	{
		return iffalse;
	}
};
3 Likes

Thanks! It works great!

1 Like

I have meet same error, and solve via this solution really appreciate you!

To fundamentally solve this issue.
We need to input flatten boolean, not as listed item like “[0] true”.