Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login
    1. Maxon Developers Forum
    2. mrpinoux
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 5
    • Best 0
    • Controversial 0
    • Groups 0

    mrpinoux

    @mrpinoux

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

    mrpinoux Unfollow Follow

    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
      mrpinouxM
      mrpinoux
    • 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
      mrpinouxM
      mrpinoux
    • RE: Solo Toggle

      @mrpinoux Adding that my first attempt came from :

      posted in Cinema 4D SDK
      mrpinouxM
      mrpinoux
    • 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/py/2023_2/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
      mrpinouxM
      mrpinoux
    • 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
      mrpinouxM
      mrpinoux