R21 Script question


In R20 I downloaded some scripts to toggle filters. (camera, grid, light, etc.)
The scripts don’t work in R21 anymore.
What is wrong with it?

import c4d
from c4d import gui

def main():
c4d.CallCommand(70000, 911) # Camera

if name==‘main’:


I guess the IDs in CallCommand may have changed, or the command has changed, or you messed up the indentations, or whatever. In general, using CallCommand() is only second choice because it’s hard to read, difficult to keep track of, and unfathomable in finding bugs…

Here is a script that uses standard functionality to toggle the Camera filter of the current viewport:

import c4d
from c4d import gui

def main():
    bd = doc.GetActiveBaseDraw()
    if bd == None :
        print "No BaseDraw!"
    displayFilter = bd.GetDisplayFilter()
    if displayFilter & c4d.DISPLAYFILTER_CAMERA:
        print "Grid off!"
    else :
        print "Grid on!"

if __name__=='__main__':

Incidentally, I have just started a C4D API Python programming series on my ARFFA Patreon. Starting October 7th with episode (00):

Many posts there (duh, currently all) are open for all visitors, but as the effort put into that series depends on patrons, I would not mind if people decide to support :slight_smile:


Thanks a lot Cairyn.