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. dskeith
    3. Best
    • Profile
    • Following 0
    • Followers 0
    • Topics 9
    • Posts 22
    • Best 3
    • Controversial 0
    • Groups 0

    Best posts made by dskeith

    • RE: R20 Script State Function
      1. Only passing True, False and c4d.CMD_ENABLED|c4d.CMD_VALUE will effect the icon state correct? it can't be done outside of the state() function?

      Yes. You may be able to perform calculations elsewhere and store a state value in the document's container that you access in the state() method, but I don't believe you can change the state elsewhere.

      1. I noticed when I put a print function inside of the state() function it seemed to loop endlessly? if I use this code:

      Yes, it's "looping" every time the Cinema 4D interface updates/redraws.

      Background

      The state() function is seemingly run every time Cinema 4D's interface is redrawn. It's really there for determining whether a command that requires an object be selected is enabled or not. As it's run so frequently, any code you put in there could slow down all of C4D, so ensure that your state check is actually important, and if so, do your check as quickly as possible.

      Example

      For example, a script that prints the name of the selected object should only be enabled when an object is selected.

      """Name-en-US: Echo Name
      Description-en-US: Opens a message dialog with the name of the selected object.
      """
      
      import c4d
      from c4d import gui
      
      def state():
          """Gray out icon if no objects are selected, or more than one object is selected.
          """
      
          # `op` is a variable provided by C4D that represents the selected object.
          # I'm not certain, but I think this is faster than call doc.GetActiveObject()
          # but it will return `False` if more than one object is selected.
          if op is not None:
              return c4d.CMD_ENABLED
          
          else:
              return False
      
      def main():
          """Open a dialog with the selected object's name.
          """
          
          if op is None:
              return
      
          active_obj_name = op.GetName()
          gui.MessageDialog("You selected: " + active_obj_name)
      
      if __name__=='__main__':
          main()
      

      References

      • Python API Docs: c4d.plugins.CommandData.GetState
      • C++ API Docs: Command Data Class
      posted in Cinema 4D SDK
      dskeithD
      dskeith
    • c4dpy.exe and VS Code on Windows?

      Hi,

      Has anyone had any luck getting R21's c4dpy.exe to work with the current release of VS Code? I've followed the installation instructions but I'm consistently prompted to "Select Python Interpreter", even though I've set "python.pythonPath": "C:/Program Files/Maxon Cinema 4D R21/c4dpy.exe" in the VS Code application and workspace settings.

      I've been able to get it running in PyCharm, but VS Code doesn't seem to recognize c4dpy.exe as a valid python interpreter.

      Any suggestions or insights would be greatly appreciated.
      Thanks,

      Donovan

      posted in Cinema 4D SDK python windows r21
      dskeithD
      dskeith
    • RE: Copying All Compatible Properties from One Object to Another?

      Realizing I never responded to this Thank you @m_magalhaes, @mikegold10, and @PluginStudent.

      I ended up manually making a list of the parameters I wanted to copy and iterating through all of them. Not ideal, but at least glad to know there wasn't an automated method I was missing.

      posted in Cinema 4D SDK
      dskeithD
      dskeith