Geometry translate based on element name


#1

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!


#2


#3

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


#4

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.


#5

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


#6

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


#7

@jkolthof Try making these changes in your codeblock
ImperativeBlock


#8

that didn`t help.


#9

Or use DesignScript syntax.
image


#10

what do you mean with lacing to the longest?


#11

@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


#12

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


#13

thanks for helping!


#14

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".


#15

yes, but why it acts different than my codeblock?


#16

It could also work like so:
image


#17

@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;
};

#18

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.