Geometry translate based on element name

Can someone give me a hint why this script is not working like I want;
I have three different line names and they need to be placed at three different hights, but wathever I do, they are all placed at the same hieght.

thanks for you help!

It seems that the Z value has changed: could you add a screenshot showing those lines?

yes they are changed indeed but al by 2400 instead of 2200 for the lines that you see in the list. All lines are moved to 2400.
If I use my codeblock with just one string the output is correct everytime, but with a list not.

Try first to change the lacing to longest in the Geometry.Translate node

three different lines (blue, green, red / SPOED, CYTO, GENERAAL)
and I need to place them at three different hights

@jkolthof Try making these changes in your codeblock
ImperativeBlock

that didn`t help.

Or use DesignScript syntax.
image

1 Like

what do you mean with lacing to the longest?

@jkolthof Alternately you can replace your Imperative Code block with one line

output = input1=="SPOED"?2000:input1=="CYTO"?2200:2400;

Edit: This suggestion is the same as that provided by @Nick_Boyts above

1 Like

cool, this works. I don`t know why, but it does.

thanks for helping!

It’s just a nested If statement.

input == 1 ? "This" : "That";

input == 1 ? is the query, followed by the True value "This" and the False value "That".

yes, but why it acts different than my codeblock?

It could also work like so:
image

@jkolthof For your code block to work you’d need to do something like this …

input1;
output = [Imperative]
{
a = {};
b = 0;
for (c in input1)
	{
		if (c == "SPOED")
		{
			a[b] = 2000;
		}
		elseif (c == "CYTO")
		{
			a[b] = 2200;
		}
		else
		{
			a[b] = 2400;
		}
		b = b +1;
	}
return = a;
};

thanks very much.! I see you have to create a new list.

I my codeblock it outputed only the last vallue and not a list.

1 Like