Created
June 26, 2017 12:35
-
-
Save MikeUdin/d3c9fd3814ed48cfc02907210cd46b9b to your computer and use it in GitHub Desktop.
Toggle visibility of the selected objects in Cinema 4D scene
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import c4d | |
# Toggle selected objects visibility in Editor and Renderer | |
# SHIFT - toggle visibility in Editor only | |
# CONTROL - toggle visibility in Renderer only | |
# Author: Mike Udin | |
# http://mikeudin.net | |
def main(): | |
objs = doc.GetActiveObjects(1) | |
if not objs: return | |
values = (2,#Default | |
0,#On | |
1)#Off | |
bc = c4d.BaseContainer() | |
pars = None | |
if c4d.gui.GetInputState(c4d.BFM_INPUT_KEYBOARD,c4d.BFM_INPUT_CHANNEL,bc): | |
#901 - c4d.ID_BASEOBJECT_VISIBILITY_EDITOR | |
#902 - c4d.ID_BASEOBJECT_VISIBILITY_RENDER | |
if bc[c4d.BFM_INPUT_QUALIFIER] == 1: | |
pars = [901] | |
if bc[c4d.BFM_INPUT_QUALIFIER] == 2: | |
pars = [902] | |
if bc[c4d.BFM_INPUT_QUALIFIER] == 0: | |
pars = [901,902] | |
if not pars: return | |
for par in pars: | |
vals = set([o[par] for o in objs]) | |
if len(vals) > 1: | |
for obj in objs: | |
obj[par] = 2 | |
for obj in objs: | |
for p in pars: | |
for num,v in enumerate(values): | |
if v == obj[p]: | |
new_v = values[(num+1)%len(values)] | |
obj[p] = new_v | |
break | |
c4d.EventAdd() | |
if __name__=='__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OK, thanks