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

    Python API OpenGL Information

    Cinema 4D SDK
    r23 python
    2
    7
    1.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      wuzelwazel
      last edited by

      I wanted to try making a small python control panel to monitor viewport OpenGL memory usage. I was also going to explore methods to force a reduction in VRAM usage.

      However, I've noticed several pieces that seem to be missing or non-functional in the Python API and was hoping I could get some info on them.

      First it seems that several of the flags returned by c4d.GeGetSystemInfo() are missing from the python API. The only ones that appear to exist are c4d.SYSTEMINFO_NOGUI and c4d.SYSTEMINFO_OSX. I was hoping that c4d.SYSTEMINFO_OPENGL would be in there.

      Second and more importantly I can't seem to get any information that's useful in my case from c4d.storage.GeGetMemoryStat(). The BaseContainer returned seems to only have values for c4d.C4D_MEMORY_STAT_MEMORY_INUSE and c4d.C4D_MEMORY_STAT_MEMORY_PEAK. All of the other keys return 0 or the keys don't exist in the BaseContainer at all. The latter is the case for c4d.C4D_MEMORY_STAT_OPENGL_USED and c4d.C4D_MEMORY_STAT_OPENGL_ALLOCATED which are the ones I was hoping for.

      1 Reply Last reply Reply Quote 1
      • ferdinandF
        ferdinand
        last edited by

        Hello @wuzelwazel,

        thank you for reaching out to us. Regarding the first part of your question, you have to use GeGetCinemaInfo() in R21+ which is the replacement for GeGetSystemInfo(), see end of the post for details.

        About the second part of your question. I can confirm that c4d.storage.GeGetMemoryStat() will indeed not properly populate the returned container. I will have to investigate why this is happening, which might take some time.

        Cheers,
        Ferdinand

        import c4d
        
        def main():
            # GeGetSystemInfo() has been deprecated in R21, see:
            #   https://developers.maxon.net/docs/cpp/2023_2/
            #   page_changes_in_r21.html#section_changesinr21022_getsysteminfo
            is_opengl = c4d.GeGetCinemaInfo(c4d.CINEMAINFO_OPENGL)
            print ("is_opengl:", is_opengl)
        
        if __name__=='__main__':
            main()
        

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • W
          wuzelwazel
          last edited by

          @zipit thank you so much! c4d.GeGetCinemaInfo() makes sense. Unfortunately the current Python documentation is a bit misleading as c4d.GeGetSystemInfo() is not listed as deprecated and the description for c4d.GeGetCinemaInfo() makes it sound like it's exclusively for determining if the current C4D session is NFR.

          Thank you very much for looking into c4d.storage.GeGetMemoryStat(). I'm excited to work on my little OpenGL control panel and stretch my GUI knowledge further 😂 👍

          1 Reply Last reply Reply Quote 0
          • ferdinandF
            ferdinand
            last edited by ferdinand

            Hi @wuzelwazel,

            this is unfortunately a shortcoming of Python bindings at the moment and this issue will be fixed in an upcoming version of the Python API.

            As a workaround you could use for now one of the 3rd party libraries listed in the Python Package Index (or anywhere else when you are brave) to get the gpu information you need. The first thing that comes up on PyPI is gpuinfo, but it does not instill much confidence, since it basically just runs a command line tool (see get_info()). Handling all the different GPU architectures is the problem here, and should be done by yourself if you want some sort of reliability. Or alternatively wait for a fix in Cinema's Python bindings.

            Cheers
            Ferdinand

            MAXON SDK Specialist
            developers.maxon.net

            1 Reply Last reply Reply Quote 0
            • W
              wuzelwazel
              last edited by

              Thanks again for the update. GPUtil came up as an option when I was researching external modules but it only works with NVIDIA hardware. That might not be so bad for now especially as the Python check for GPU hardware vendor in Cinema 4D does seem to be working.

              I'll mark this as solved for now. I look forward to the API updates!

              1 Reply Last reply Reply Quote 0
              • W
                wuzelwazel
                last edited by

                @ferdinand it looks like this hasn't changed in S24. Is there an expected timeline for a fix to these bindings?

                Thanks!

                1 Reply Last reply Reply Quote 0
                • ferdinandF
                  ferdinand
                  last edited by

                  Hello @wuzelwazel,

                  thank you for reaching out to us. I am sorry if I gave you the impression that this will be fixed with S24. This issue is still on our radar, but it does not have the highest priority. I am also unfortunately not a liberty to give you a time frame when this will be done.

                  Thank you for your understanding,
                  Ferdinand

                  MAXON SDK Specialist
                  developers.maxon.net

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post