Dynamo code block function return strange things

Hi, I’m currently progress in auto rebar modeling using dynamo for my project.

Cause of some reason I use pre-defined code block function for return stirrup rule by column type.

I was intend to get

[-480,-780,-1080,-1380,-1680,-1980,-2280,-2580] for type 1
and
[-480,-780,-1080,-1380,-1680,-1980,-2280,-2580, -2880, -3180, -3480, -3780, -4080, -4380] for type 6

But what I get after run dynamo is
[-480,-780,-1080,-1380,-1680,-1980,-2280,-2580] for type 1
and
[-480,-780,-1080,-1380,-1680,-1980,-2280,-2580] for type 6 ( Can notice that number of data is 16, if it return properly it would be 22)

I already check argument for call function (type 1 and type 6 are used).

How can I get correct return from code block function?

You will need to define an Imperative Function

def stirrupRules(type)
{
    return [Imperative]
    {
	    if (type == 1)
	    {
	    	return [-480,-780,-1080,-1380,-1680,-1980,-2280,-2580];
	    }
	    elseif (type == 6)
	    {
	        return [-480,-780,-1080,-1380,-1680,-1980,-2280,-2580, -2880, -3180, -3480, -3780, -4080, -4380];
	    }
	    else
	    {
	    	return [-480,-780,-1080,-1380,-1680];
	    }
	};
};
2 Likes

Thanks @Vikram_Subbaiah :).

Now it work Correctly.

1 Like

Seems like you’re trying to build a dictionary? Just for reference you could do it with OOTB nodes as well :slight_smile:

1 Like

What i want to do was “Give column type (from A to F) to function and get each types stirrup height” I solve those problem via vikram thanks for your interest.

Happy new year!