How can I drive the Switch nodes True/False value?

In the compositor I would like to add a driver to the Switch Node. I want to watch a frame value from a VSE strip.
When the current frame count equals the Strip start frame I want to switch the node.

Here is an example of what I hope to achieve:

• When current frame is less than abs(var)+var_001 then pass no picture,

• if current frame is greater than abs(var)+var_001 then switch source through.

Of course what I have entered is unformatted nonsense. And the switch node expects to return a true or false, not a value.

*nb: abs(var) changes negative number to integer.

Can I define the abs(var)+var_001 (it is the VSE strip trimmed start time) as a function of some sort to call elsewhere? It's a pain to define it all the time.

• abs(var) doesn't change a value into an integer value (which are only natural numbers), but gives their absolute value, which is the same like multiplying by -1 if negative or in other words removing the negative sign if applicably. – Samoth Mar 3 '16 at 13:03
• Oh and the "trimmed start time" of a Strip is probably already available to you via its frame_final_start attribute. – Samoth Mar 3 '16 at 13:50
• Thanks for the tip, I was only grabbing paths from the variables exposed in the Strip Properties, I never thought to use any of the other properties. – 3pointedit Mar 6 '16 at 22:18
• To find out, which attributes exist from a given Property, just copy the Path like bpy.data.scenes['Scene'].sequence_editor.sequences_all[0]. including the following . into a Python Console Editor view and hit Ctrl + Space. The autocompletion feature will suggest you all available ones. – Samoth Mar 7 '16 at 10:03
• Is there something you're still missing in my answer below? – Samoth Mar 7 '16 at 22:19

It works for me with the plain Expr: abs(var) < frame. So basically you just need a Boolean expression (omit the if in your expression) for it to drive the Switch. Basically any numerical result below 1.0 will result in Off and starting from 1.0 and above will result in On.

You can put something like (abs(var) < frame) and (abs(var) + var_001 > frame) into the box to evaluate only True during the duration of your Strip after you changed your var_001 to the frame_final_duration.

Furthermore you could Copy'n'Paste drivers if you want to use them again.

When you want to use your own function to add more complicated stuff like conditional expressions, stick to the Example code in the documentation about the Driver Namespace:

This script will add a function to the driver namespace, which can then be used in the expression driver_func(frame):

import bpy

def driver_func(val):
return val * val    # return val squared


• Can also use 1 if (expr) else 0 .. unnecessary for booleans handy for returning other values, eg 10 if(var > frame) else 99 – batFINGER Mar 3 '16 at 13:36
• See what you mean, it either works as you say or throws an error TypeError: bpy_struct: item.attr = val: SomeObjectType.some_bool_prop expected True/False or 0/1, not float Think I'll stick with using 0/1 or True/False for on / off. – batFINGER Mar 5 '16 at 15:18