Toggle Viewport Solo On/Off with a script



By default, you’d have to go on two keys. One is to enable it and the other to turn it off.
I would like to have it in one script. Where it goes like this

(1) Determine if viewport solo is turn on;
(2) if it is, turn it off.
(3) else, turn it on.

The problem I have is I can’t find the command in Python documentation. The script console gives me this:

    c4d.CallCommand(431000059, 431000059) # Viewport Solo Single
    c4d.CallCommand(431000058, 431000058) # Viewport Solo Off

I cannot find the command 431000059 and 431000058 in the python documentation.
Is there a way around this?

Thank you.


Use Nitroman’s free Magic Solo plugin instead, and map that to a keyboard shortcut? I can’t live without that thing. So such better than default C4D solo.


Thanks for the response Luke. But this is also scripting learning experience for me. So, the script format would really be helpful.


What you’re looking for is the command “IsCommandChecked” which tests whether a command is currently checked (duh!)
This will enable you to tell the state and trigger the on/off commands accordingly.

import c4d
from c4d import gui

def main():
    if c4d.IsCommandChecked(431000061) :
        print "Solo Selection is on" # just for information

    if c4d.IsCommandChecked(431000059) :
        print "Solo Single is on"
        c4d.CallCommand(431000058)  # Viewport Solo Off
    else :
        print "Solo is not on"
        c4d.CallCommand(431000059)  # switch it on
if __name__=='__main__':

Handle Viewport Solo Hierarchy as needed.


Hi Cairyn,

Your script works. Thank you very much.

May I ask if there is a catalogue/listing for the command numbers in C4D? I can’t seem to find them.

Thank you.


The Customize Command dialog shows the IDs when you select the command.


Not really, magic solo also disables all xparticle emitters everytime you use it on any object in the scene


Thanks for the response!