Navigation

    • Register
    • Login
    • Search
    1. Home
    2. mrpinoux
    mrpinoux

    mrpinoux

    @mrpinoux

    0
    Reputation
    5
    Posts
    5
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online
    Website mr-pinoux.com/ Location Los Angeles

    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups
    mrpinoux Follow

    Best posts made by mrpinoux

    This user does not have any upvoted posts yet.

    Latest posts made by mrpinoux

    Visibility Toggle

    I'm adding a script, added as a valuable shortcut in my everyday workflow here :

    It basically allows you to select any object, and assigned to the letter H, Hide or Reveal your selected object. Like in Maya. Very Useful.

    Not sure it is the best way to do it, that's why I'm posting it here.

    import c4d
    from c4d import gui
    
    def main():
    
        allobj = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_CHILDREN)
        obj = object()
        for obj in allobj:
            editor = obj[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR]
            render = obj[c4d.ID_BASEOBJECT_VISIBILITY_RENDER]
    
            if editor == 1 or render == 1:
                newstate = 2
            else:
                newstate = 1
    
            obj[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = newstate
            obj[c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = newstate
    
    
    if __name__=='__main__':
        main()
        c4d.EventAdd()
    
    
    posted in Cinema 4D SDK •
    RE: Solo Toggle

    @mrpinoux
    That's great, I ended up using :

    import c4d
    from c4d.modules import snap
    
    def main():
        bc = snap.GetSnapSettings(doc)
        currentMode = bc[c4d.VIEWPORT_SOLO_MODE]
        if currentMode == None:
            c4d.CallCommand(431000060) #  Viewport Solo Hierarchy
        elif currentMode == c4d.VIEWPORT_SOLO_MODE_OFF:
            c4d.CallCommand(431000060) #  Viewport Solo Hierarchy
        elif currentMode == c4d.VIEWPORT_SOLO_MODE_HIERARCHY:
            #bc[c4d.VIEWPORT_SOLO_MODE] = c4d.VIEWPORT_SOLO_MODE_OFF
            c4d.CallCommand(431000058) # Viewport Solo Off
        c4d.EventAdd()
    
    if __name__=='__main__':
        main()
    

    Thanks again!

    posted in Cinema 4D SDK •
    RE: Solo Toggle

    @mrpinoux Adding that my first attempt came from :
    https://youtu.be/0SNhZgmGd2k?t=1126

    posted in Cinema 4D SDK •
    RE: Solo Toggle

    @Cairyn
    Thank you for your feedback!

    I just watched : https://www.cineversity.com/vidplaylist/introduction_to_python_in_c4d/introduction_to_python_in_c4d_part_3c

    And I'm obviously still a newbie.

    One question : how do you know that the VIEWPORT_SOLO_xxx constants are found under the snap settings in the first place?

    I tried looking for this here :
    https://developers.maxon.net/docs/Cinema4DPythonSDK/html/search.html?q=VIEWPORT_SOLO&check_keywords=yes&area=default

    and it returned nothing.

    Just trying to get the proper reflexes to figure shit up by myself when possible 🙂

    posted in Cinema 4D SDK •
    Solo Toggle

    Hi!

    So my goal is to create a simple command to toggle the solo function, instead of one command to solo, and one command to solo_off.

    How can I go to create a python script in order to toggle these two commands :
    431000059, # Viewport Solo Single
    431000058) # Viewport Solo Off

    So far, my attempt has been not working :

    import c4d
    from c4d import gui
    
    def main():
        #obj = doc.GetActiveObject()
        #print(obj)
        values = (431000059, # Viewport Solo Single
                            431000058) # Viewport Solo Off
        done = False
        for num,x in enumerate(values):
            if x == doc.GetAction():
                new_v = values[(num+1)%len(values)]
                doc.SetAction(new_v)
                done = True
                break
            
        if not done:
            doc.setAction(values[0])
            
        c4d.EventAdd()
    
    
    if __name__=='__main__':
        main()
        c4d.EventAdd()
    

    So you can tell that I don't really know what I'm doing.

    How can I tell python to look at the current obj selected? Then how can I tell it to execute the solo function?
    Where can I find what environment the solo command lives in, as it doesn't seems to be with the doc.GetAction().

    Any help to connect the dots would be very much appreciated.

    Thanks!

    posted in Cinema 4D SDK •