Cinema 4D Tutorial – Traffic Lights

Here is a quick post to share a piece of python code that I use in nearly every C4D scene these days. It is really simple and all it does is take the current state of the objects “Visible in Editor” parameter and apply it to the same objects “Visible in Render” parameter.

I use this to hide objects that I don’t want to render. You can of course simply keyframe both parameters, but this means you only need to key the Visible in Editor parameter. Another option is to use a Display tag which will also allow you to keyframe the object visibility. So it is nothing revolutionary that I’m offering (sorry about that ;)

The reason I use this is simply because you have a visual indicator in the Object Manager of the current state of an objects visibility, you don’t get this with the Display Tag unfortunately. Would be kinda cool if the eyeball closed to indicate visibility, similar to PS layer switches.

Anyway here’s the code, simply copy and paste this into a Python Tag and then choose File > Save Tag Preset in the Object Manager. The tag will be there for you every time you need it.

Start copying here…

import c4d
#Welcome to the world of Python

def main():

# get object tag is attached to
obj = op.GetObject()

# get visibility from editor
visibility = obj[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR]

# pass editor visibility to renderer visibility
obj[c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = visibility

…Stop copying here

Thanks to Patrick Goski who actually wrote this little snippet of code.

By the way if you get errors when you copy and paste this, it may be because of the formatting, so make sure you don’t use tabs and that it looks like this..

Cinema 4D Tutorial - Traffic Lights - Python Tag

Python Tag


Cinema 4D Tutorial – Traffic Lights

Author: admin

10 Comments

  1. Andy
    Andy On January 27, 2012 at 9:46 pm Reply

    Thanks for sharing this, Tim!

    Are you going to NAB this year?

    • Tim
      Tim On February 1, 2012 at 8:16 am Reply

      Not sure if I’ll be there or not right now..

  2. dahh
    dahh On February 9, 2012 at 2:19 am Reply

    Why not just alt + click (mac) on the stop watches?

    • Tim
      Tim On February 23, 2012 at 11:16 am Reply

      @dahh because this tag allows you to only keyframe one dot, alt click changes them both but you would still need to key both dots (if you wanted to see in the editor what was going to render).

  3. AJ
    AJ On February 23, 2012 at 10:19 am Reply

    Hey Tim, just saw this post and thought I would share a little Xpresso preset I made that Ive been using in almost all my projects. Its just a simple On/Off switch for objects, but best of all its keyframeless! You can get it here if your interested: http://ajhaines.com/c4d-preset-onoff-switch

    • Tim
      Tim On February 23, 2012 at 11:16 am Reply

      @AJ Looks cool, thanks for sharing.

  4. rich nosworthy
    rich nosworthy On February 28, 2013 at 9:41 am Reply

    This is actually awesome! When you’ve gotta keyframe more than a couple of objects on and off, its so tedious without this.

    Thanks Tim

  5. rich nosworthy
    rich nosworthy On February 28, 2013 at 9:46 am Reply

    Actually tho, just trying this in R14 and getting an error

    SyntaxError: obj = op.GetObject()

    Line 7 Position 3

    Wonder if the python api’s changed slightly in R14

    • Tim
      Tim On February 28, 2013 at 9:54 am Reply

      @Rich I just tried it and it works ok for me in R14. Python is really fussy about line spaces, so perhaps you typed it incorrectly.

  6. rich nosworthy
    rich nosworthy On February 28, 2013 at 10:31 am Reply

    Damn sorry tim, your right, forgot python needs the correct indents (as I now see you pointed out above!). Thanks again

Leave a Reply