IFnode. Can I get full list out of it?

Gooe day guys ,

I used the IF node and noticed that it returns a list as big as the smallest one. Does someone know how to get the whole list ? Ive tried multiple combinations.


Please help.

A thing to note about the If node is that it evaluates both outcomes, regardless of the input. It may be that it tries to keep the lists of matching size so as to not mess up the conditions for following nodes…
If the true and false conditions are independent of each other, you can try using the ScopeIf node instead, which will first evaluate the condition and then the respective true or false input exclusively.

1 Like

Hi,

Have you tried the Imperative block ?

2018-09-26%2010_23_24-Dynamo

2018-09-26%2010_23_25-Dynamo

2 Likes

Or Python
image
image

Or clockwork node:
image
image

1 Like

image

Works perfectly. Thanx !!

@Avz & @verdi Be careful of using the OOTB “ScopeIf” node without knowing the implications of this… It is NOT behaving like all other nodes in Dynamo as it does not compute the untrue statement which might cause a failure in your Dynamo system.
The ScopeIf+ from clockwork however works like you would expect.

The “error” / danger of the scopeif node have been reported here:

Something I will test. Thanx for the headsup. If that is the case I will try the python script.

Point being, an imperative evaluation is required in some shape way or form :wink:

I nevertheless do think it’s strange though that the If node’s output is tied to the shortest input even when they’re entirely independent, and there are no lacing options…

I know about the “dangers” of the ScopeIf, which is why I expressly mentioned independent inputs.

1 Like

You can use lacing in a CodeBlock if you use the bool?a:b syntax :slight_smile: (e.g bool?a<1L>:b<1>)

(But I could not get it done even with this info).

This was new for me… but have a look: ( I know it is not the desired output but quite neat applying lacing to nodes who doesn’t have it) :wink:

5 Likes

Don’t know if this can be of any interest to somebody (it is to me haha). I created a new If function that does not encounter the same problem as one can encounter with the If node. You can use it if you don’t want to create a new Imperative block each time you want to use an If statement.

def If(boole : bool, value1:var[]..[], value2:var[]..[]){
	return = [Imperative]{
		if(boole){
			return = value1;
		}else{
			return = value2;
		}
	}
};

3 Likes

I love how elegant the clockwork code is…

It is indeed !

Just saw this post and thought I would toss my suggestion in. This is how I have gotten around the IF problem. its a couple of extra node but all OTB.

Thanks for the input :slight_smile: I guess it is the node version of the Clockwork node :smiley:

I think you are correct on that. I think it is also how Ayuda.ThisOrTaht is built from rhythm package.