Toggle Viewport Solo On/Off with a script

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

 
Thread Tools Display Modes
  02 February 2018
Toggle Viewport Solo On/Off with a script

Hi,

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 command431000059 and431000058 in the python documentation.
Is there a way around this?

Thank you.
 
  02 February 2018
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.
 
  02 February 2018
Originally Posted by LukeLetellier: 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.
 
  02 February 2018
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__':
 main()


Handle Viewport Solo Hierarchy as needed.
 
  02 February 2018
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.
 
  02 February 2018
Originally Posted by bentraje: May I ask if there is a catalogue/listing for the command numbers in C4D? I can't seem to find them.

The Customize Command dialog shows the IDs when you select the command.
 
  02 February 2018
Originally Posted by LukeLetellier: 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.
Not really, magic solo also disables all xparticle emitters everytime you use it on any object in the scene
__________________
artstation
Close, open-relationship: C4D / Zbrush
Hate / love: Maya / Houdini
Former gf: XSI
 
reply share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 08:04 AM.


Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.