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

    stream the viewport to python api that sends an image back and use that as a texture

    Cinema 4D SDK
    python
    2
    4
    919
    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.
    • T
      thomas
      last edited by

      Hey Forum

      Here is what I am trying to do:

      1. capture the current viewport as an image
      2. send it to a Python API
      3. wait for the API to send an image back
      4. use this image as a texture.

      I realise my question involves a few steps and is complicated. I think some bits I'll be able to figure out. I think the external API bit sending and receiving will be easier, but I don't know much about the APIs in c4d. I am pretty good at Python and coding, but I have never worked with the API. I looked at the documentation and the GitHub examples but couldn't see any examples for the viewport and capturing it as an image.

      Right now, I would like to start at step 01. Can you capture a viewport or, alternatively the render view? Can you capture (save an image) from any c4d window? For example from the RS or Arnold viewport even?

      thank you,
      T

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

        Hello @thomas,

        Welcome to the Plugin Café forum and the Cinema 4D development community, it is great to have you with us!

        Getting Started

        Before creating your next postings, we would recommend making yourself accustomed with our Forum and Support Guidelines, as they line out details about the Maxon SDK Group support procedures. Of special importance are:

        • Support Procedures: Scope of Support: Lines out the things we will do and what we will not do.
        • Support Procedures: Confidential Data: Most questions should be accompanied by code but code cannot always be shared publicly. This section explains how to share code confidentially with Maxon.
        • Forum Structure and Features: Lines out how the forum works.
        • Structure of a Question: Lines out how to ask a good technical question. It is not mandatory to follow this exactly, but you follow the idea of keeping things short and mentioning your primary question in a clear manner.

        About your First Question

        I have trouble understanding what you mean with the loaded terms stream, send, and receive. I assume you want to simply get access to the framebuffer of a viewport to use it as a texture.

        1. Viewports are represented by the inheritance chain c4d.BaseView<-c4d.BaseDraw where most of the functionalities is realized in c4d.BaseDraw, a canvas like type with which you can draw into a viewport.
        2. In C++ there is BaseDraw::GetViewportImage which exposes the current color framebuffer state of the viewport as an maxon::ImageRef. This method has not been wrapped for Python.
        3. But you can simply render the document using the hardware preview renderer. The topic has been discussed before for example here.
        4. You could then reference the render result file on disk as a texture.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • T
          thomas
          last edited by

          hi Ferdinand.

          thanks so much for your help. This will be enough to get me going for now.

          1 Reply Last reply Reply Quote 0
          • T
            thomas
            last edited by

            Hi @ferdinand, your links really helped me a lot, and I managed to write a script that starts a render and sends the rendered image to a web service.

            Can the SDK grab the live preview image from the redshift IPR? I assume not looking at the documentation: https://developers.maxon.net/docs/py/2023_2/search.html?q=redshift&check_keywords=yes&area=default

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