Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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

    SetActiveRenderData Does Not Work As Expected?

    Cinema 4D SDK
    r21 python
    2
    3
    371
    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.
    • B
      bentraje
      last edited by

      Hi,

      I have a code that

      1. saves the current render data setting
      2. modifies render data
      3. restores #1 render data

      The problem is in #3. Render data is not restored. It stays as in #2

      You can check the code here:

      import c4d
      
      # Main function
      def main():
          
          doc = c4d.documents.GetActiveDocument()
          rd_saved = doc.GetActiveRenderData()
          
          rd = doc.GetActiveRenderData()
      
          rd[c4d.RDATA_RENDERENGINE]  = c4d.RDATA_RENDERENGINE_PREVIEWHARDWARE
          rd[c4d.RDATA_XRES] = 200
          rd[c4d.RDATA_YRES] = 200
          rd[c4d.VP_PREVIEWHARDWARE_ANTIALIASING] = 3
              
      
          doc.SetActiveRenderData(rd_saved)
      
      
      # Execute main()
      if __name__=='__main__':
          main()
      

      Is there a way around this?

      Thank you

      1 Reply Last reply Reply Quote 0
      • P
        PluginStudent
        last edited by

        RenderData objects are objects stored with the BaseDocument, representing a set of render settings.

        GetActiveRenderData() returns a reference to such an object. So calling GetActiveRenderData() twice just returns two references to the same object.

        If you want to store the previous state, you could simply get a clone:

        rd_saved = doc.GetActiveRenderData().GetClone()
        

        and use that clone to restore the original state:

        rd_saved.CopyTo(rd, c4d.COPYFLAGS_NONE)
        

        But without knowing what you actually want to achive, it is hard to say if that is a good solution or not.

        Also, assuming this is a Script Manager script: doc = c4d.documents.GetActiveDocument() is useless.

        1 Reply Last reply Reply Quote 2
        • B
          bentraje
          last edited by

          @PluginStudent

          Thanks for the explanation.
          Your solution works as expected 🙂

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