Jump to content


RobertL

Visible/invisible toggle script

Recommended Posts

Hi there,

 

I have found a few solutions, but I can't simplify it to the way I want.

What I want is toggle between to modes:

1 = both option are grey

2= both option are red.

So I don't need the green state.

Anyone has a niffy little script for such?

(In terms of multi-selection just take the state of the first selected.. so no real inverse)

Share this post


Link to post
Share on other sites

Have you searched the site ? I posted this question about 2 weeks ago, and got a reply with the answer from Hrvoje.

 

Just about to run out the door, hence why I don't have time to find it for you...

 

CBR

Share this post


Link to post
Share on other sites

This should work :)

 

import c4d

def main():

    selected = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_CHILDREN)

    for obj in selected:
        if obj[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] == 0 or obj[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] == 2:
           obj[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = 1    
        else:
           obj[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = 0 


if __name__=='__main__':
    main()
    c4d.EventAdd()

 

Share this post


Link to post
Share on other sites
  • Topic Author
  • Thanks!

    Changed it a bit:

     

    import c4d

    def main():

        selected = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_CHILDREN)

        for obj in selected:
            if obj[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] == 0 or obj[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] == 2:
               obj[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = 1
               obj[c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = 1
            else:
               obj[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = 2
               obj[c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = 2


    if __name__=='__main__':
        main()
        c4d.EventAdd()

    Share this post


    Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

    • Recently Browsing   0 members

      No registered users viewing this page.

    ×