# Can a driver use the current frame number as input?

I'd like to render an object only at Frame 20. The common approach seems to be set 3 keyframes at Frame 19, 20, and 21. It's not too bad, but I really wonder if I can just use the current frame number as driver input. If it is possible a single driver is enough to express "only render at Frame 20".

This is the little code you have to set on a driver on the Render icon to get the object rendered only at frame 20.

• I assume that works because toggles are effectively boolean properties? Oct 4 '21 at 17:43
• Yes, every on-off button is boolean, where 0.0 is off and any other value is on. Oct 4 '21 at 17:44
• The only downside I see to this is that the object remains visible in the viewport but disappears in the render, which can confuse people debugging animation in render view, but you could apply the same driver to the viewport toggle, I suppose Oct 4 '21 at 17:48
• Yes, it's usual to copy and paste the same driver on both. Oct 4 '21 at 17:49
• While I was trying out my identical-answer-to-yours, I found 'Temporarily Hide in Viewport' is not keyable....I wonder if there's a getaround.. Oct 4 '21 at 19:29

There are many ways to do this. One of the easiest is to use the frame number as an input to control transparency in a shader:

Here, the purple value field is purple because it has a driver which I've created by typing #frame into the field. This is a short cut for using the frame number. Set the frame value you want the object to appear as the second value field. If you're using this in EEVEE set the Blend Mode of the material to Alpha Clip.

You could type #frame == 25 directly into the Alpha input and it would create this driver:

but then it's pretty obscure what's going on.

Driver expressions are explained in the manual. You need to be aware of certain caveats but they are basically any Python expression that the driver can decode.

you can add a custom property (i named mine "prop") and then add a driver on the camera icon of your object and insert this into your driver:

• I didn't realize the expression in driver is literally python expression. Many thanks. Oct 4 '21 at 17:12
• Or you could use the much simpler frame == var Oct 4 '21 at 17:23
• @LaiYu-Hsuan Here is the Driver expression manual section Oct 4 '21 at 17:26
• Also, the expression above contradicts the driver manual recommendation that 'Drivers should access object data via Driver Variables, rather than direct references in the Python expression, in order for dependencies to be correctly tracked.' Your driver expression can lead to unexpected behavior. Oct 4 '21 at 17:54