Manipulate list of rotation angles

Hi all,

My last topic left me with a new question
I have a list of rotation angles, that i would like to manipulate in two ways.
First list:
If angle = 0, 90, 180, 270 or 360 degrees, replace this value by 0.
If the angle has another value then the above, replace it by the negative equivalent (45 to -45).
Second list:
If angle = 0, 90, 180, 270 or 360 degrees, replace this value by 0.
If the angle has another value then the above, don’t change it.

All help is much appreciated.
Thanks in advance,
Mark

For simplicity I would use python.

inAngles = IN[0]
outAngles = []

for n in inAngles:
	if n%90 == 0:
		outAngles.append(0)
	else:
		outAngles.append(-n)

OUT = outAngles

For your second list, you just need to replace the -n for n on the else block.:slight_smile:

2 Likes

Hi @alvpickmans,

Your solution looks very promising. I’m always surpised what a few lines of code can do :thumbsup:
But there seems to be one little issue.
It looks like the input (list) from the codeblock behaves a little different then the one from the Element.Location node.
Visually there seems to be no difference in the input lists, but the output is not the same.

Any ideas how to solve this?
Create Cuboid_v04a.dyn (21.4 KB)

Kind regards,
Mark

Have you tried to round numbers before the python script?

1 Like

I think @erfajo might be on the right way in here. Try to round the output before. Be aware that if your value is, for example, 359.60 and you round it without decimals it will compute 360 and therefore return 0. It all depends or what you are trying to get :slight_smile:

Hi guys,

You were right, the rounding did the trick
@alvpickmans, thank you very much for solving my original question.
@erfajo, your finetuning is also much appreciated, thanks a lot.

Kind regards,
Mark

1 Like