Using Geometry Translate in If Statement

#1

So my goal is to create a geometry translation of a mass element dependent on a conditional statement. However, it generates the translation before the If statement occurs, the result of which is the If statement is immaterial to the geometry translation’s appearance.

Is there a way to isolate the translation to occur only after the If statement? Thank you.

0 Likes

#2

Why not make the input of the geometry.translate’s Z dependent on the if, where if (whatever) is true, output is 2000, but if false, output is 0.

0 Likes

#3

For more explanation, the If node basically does both true and false inputs first, and then determines which one you want to be outputted by the node. The translation happens before the If node is even evaluated so that is why yours is not working.

I believe if you did it in a codeblock using the bool?Geometry.Translate(etc):originalGeometry; syntax might give you the outcome you want, where the actual translation does not occur unless it is true.

0 Likes

#4

Ah yes. I was able to fix this by just making the z Translation the parameter that is dependent on the if statement, as kennyb6 said. Then the Geometry Translation can be placed on the other side. Thank you!

1 Like

#5

Glad you worked this out. I did want to point out a two quick things I noticed as I read this thread at AU.

First, the option you posted was actually working as submitted - the issue you saw was you had both sides of the statement had the geometry preview on. Disable the previews for the geometries before the If node and you would have been good as you were, though this solution given likely saves you some processing time in the end as it halves the amount of geometry.

The other bit to point out is that you can modify the if statement to call both functions in a single design script line to get what may be a faster processing time. The statement would read something like this:

X > 7 ? 
TargetElement.Geometry.Translate(0, 0, 2000) : 
TargetElement.Geometry;
3 Likes

#6

Thank you for the reply. I really have to get used to the concept of Dynamo previews.

0 Likes