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

    get the names of redshift multi passes AOV names from the render settings

    Cinema 4D SDK
    python 2023
    3
    6
    1.3k
    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

      I am looking for a way to read out the multipass names of my redshift rendersettings, such as 'Z' or 'depth'

      in the code below the script successfully gives me the path at the very last print statement. I am looking for the other MP filenames
      filepath 2: C:\Users\thoma\Dropbox\trauminc\projects\832-control_net\work\CG\c4d\balls\render\balls-v010\balls-v010.png, 1023671 defined in the render settings. such as balls-v010_depth0034

          def render(self, url):
          
          
          
                  print(f"are we rendering? {self.rendering}")
          
                  if self.rendering:
          
                      return 
          
                  
          
                  self.rendering = True
          
                  doc = c4d.documents.GetActiveDocument()
          
                  docClone = doc.GetClone()
          
                  rd = doc.GetActiveRenderData()
          
                  print(f"render data: {rd}")
          
                  print(f"multipass {rd.GetFirstMultipass()}")
          
                  bmPreview = c4d.bitmaps.BaseBitmap()
          
                  bmPreview.Init(int(rd[c4d.RDATA_XRES]), int(rd[c4d.RDATA_YRES]))
          
                  print("starting to render")
          
                  result = c4d.documents.RenderDocument(
          
                      docClone, rd.GetData(), bmPreview, c4d.RENDERFLAGS_EXTERNAL, th=None
          
                  )
          
                  if result == c4d.RENDERRESULT_OK:
          
                      filepath = rd[c4d.RDATA_PATH]
          
                      print(f"filepath: {filepath}")
          
                      if "$" in filepath:
          
                          filepath = self.resolve_and_normalize_path(filepath, doc, rd)
          
                      file_format = rd[c4d.RDATA_FORMAT]
          
                      print(f"file_format: {file_format}")
          
                      filepath += self.get_extension_for_format(file_format)
                      print(f"filepath 2: {filepath}, {file_format}")
          
                      bmPreview.Save(filepath, file_format)
          
                      self.send_image_to_server(filepath, URL)
      
                  self.rendering = False
          
          
          
              def resolve_and_normalize_path( self, tokenized_path, doc, rd):
          
                  # Define the rpData dictionary to resolve tokens
          
                  rpData = {
          
                      "_doc": doc,
          
                      "_rData": rd,
          
                      "_rBc": rd.GetData(),
          
                      # "_frame": 2,  # Replace this with the actual frame number if available
          
                      # Add any other needed data here
          
          
          
                  }
          
          
          
                  # Convert the tokens to their actual values
          
                  filepath = c4d.modules.tokensystem.StringConvertTokens(tokenized_path, rpData)
          
          
          
                  # Check if the filepath is absolute
          
                  if not os.path.isabs(filepath):
          
                      # If not, make it absolute
          
                      base_path = doc.GetDocumentPath()
          
                      filepath = os.path.join(base_path, filepath)
          
          
          
                  # Normalize the file path to use the standard slashes for your OS
          
                  filepath = os.path.normpath(filepath)
          
          
          
                  return filepath
      
      
      

      When I render via my plugin in RS, it renders one additional image with different colour settings. file: balls-v010.png in this image: Screenshot 2024-01-27 at 1.49.55 PM.png

      I have looked at https://github.com/PluginCafe/cinema4d_py_sdk_extended/blob/a12cca185a7a07fb20aa34520799b66007839e1e/scripts/05_modules/token_system/tokensystem_render_r17.py#L9 and its super helpful but doesn't help me with the AOVs

      DunhouD 1 Reply Last reply Reply Quote 0
      • DunhouD
        Dunhou @thomas
        last edited by

        Hi @thomas ,

        Here is a little function in my Renderer library, seems like what you want to do, hope it can helps😊

        Cheers~
        DunHou

        AOVs

        893f580c-5d6d-4b63-8216-ec634c899443-image.png

        Console

        --- REDSHIFTRENDER ---
        Name: Redshift
        Color space: ACEScg
        AOV count: 4
        -----------------------------------------------------------
        Name                  :Z
        Type                  :1
        Enabled               :Yes
        Multi-Pass            :Yes
        Direct                :No
        Direct Path           :$filepath$filename_$pass
        Direct Effective Path :
        -----------------------------------------------------------
        Name                  :Cryptomatte
        Type                  :42
        Enabled               :Yes
        Multi-Pass            :Yes
        Direct                :Yes
        Direct Path           :$filepath$filename_$pass
        Direct Effective Path :Untitled_4_AOV_Cryptomatte.exr
        -----------------------------------------------------------
        Name                  :Beauty
        Type                  :41
        Enabled               :Yes
        Multi-Pass            :Yes
        Direct                :No
        Direct Path           :$filepath$filename_$pass
        Direct Effective Path :
        -----------------------------------------------------------
        Name                  :Shadows
        Type                  :23
        Enabled               :Yes
        Multi-Pass            :Yes
        Direct                :No
        Direct Path           :$filepath$filename_$pass
        Direct Effective Path :
        --- REDSHIFTRENDER ---
        

        Codes

        import c4d
        from Renderer import Redshift
        
        def main() -> None:
            # Get the doc host the aovs, in this case th active doc
            doc: c4d.documents.BaseDocument = c4d.documents.GetActiveDocument()
            # Set redshift AOVHelper instance
            aov_helper = Redshift.AOV(doc)
            # Print current aov info
            aov_helper.print_aov()
            
        if __name__ == '__main__':
            main()
        

        https://boghma.com
        https://github.com/DunHouGo

        i_mazlovI 1 Reply Last reply Reply Quote 1
        • i_mazlovI
          i_mazlov @Dunhou
          last edited by

          Hi @thomas ,

          There's redshift python API that you can use for that. Please check the sample code snippet below that creates "Depth" AOV and then prints all of the existing AOVs into the console for the active document. I assume in the core @Dunhou uses this exact approach conveniently wrapped by the renderer library.

          Cheers,
          Ilia

          The sample code snippet:

          import c4d
          import c4d.documents
          import redshift
          
          def CreateAOVs(vpRS):
          	aovs = []
          	aov = redshift.RSAOV()
          	aov.SetParameter(c4d.REDSHIFT_AOV_TYPE, c4d.REDSHIFT_AOV_TYPE_DEPTH)
          	aov.SetParameter(c4d.REDSHIFT_AOV_ENABLED, True)
          	aov.SetParameter(c4d.REDSHIFT_AOV_NAME, "My Depth")
          	aovs.append(aov)
          
          	return redshift.RendererSetAOVs(vpRS, aovs)
          
          def PrintAOVs(vpRS):
          	aovs = redshift.RendererGetAOVs(vpRS)
          	for aov in aovs:
          		print("-----------------------------------------------------------")
          		print("Name                  :%s" % aov.GetParameter(c4d.REDSHIFT_AOV_NAME))			# The customized name of an AOV
          		print("Effective Name        :%s" % aov.GetParameter(c4d.REDSHIFT_AOV_EFFECTIVE_NAME))	# The customized name of the AOV or a sensible default when empty # Available from 2.6.50/3.0.10
          		print("Type                  :%d" % aov.GetParameter(c4d.REDSHIFT_AOV_TYPE))
          		print("Enabled               :%s" % ("Yes" if aov.GetParameter(c4d.REDSHIFT_AOV_ENABLED) else "No"))
          		print("Multi-Pass            :%s" % ("Yes" if aov.GetParameter(c4d.REDSHIFT_AOV_MULTIPASS_ENABLED) else "No"))
          		print("Direct                :%s" % ("Yes" if aov.GetParameter(c4d.REDSHIFT_AOV_FILE_ENABLED) else "No"))
          		print("Direct Path           :%s" % aov.GetParameter(c4d.REDSHIFT_AOV_FILE_PATH))
          		print("Direct Effective Path :%s" % aov.GetParameter(c4d.REDSHIFT_AOV_FILE_EFFECTIVE_PATH)) # Available from 2.6.44/3.0.05
          
          def main():
          	doc = c4d.documents.GetActiveDocument()
          	renderdata = doc.GetActiveRenderData()
          
          	# Get the Redshift videoPost and render settings
          	vprs = redshift.FindAddVideoPost(renderdata, redshift.VPrsrenderer)
          	if vprs is None:
          		return
          
          	# Switch renderer
          	renderdata[c4d.RDATA_RENDERENGINE] = redshift.VPrsrenderer
          
          	CreateAOVs(vprs)
          	PrintAOVs(vprs)
          
          	c4d.EventAdd()
          
          
          if __name__=='__main__':
          	main()
          

          MAXON SDK Specialist
          developers.maxon.net

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

            @Dunhou @i_mazlov, thanks so much both. This really helped.

            Where is the Redshift Python documentation, I tried the normal Redshift online help https://help.maxon.net/r3d/cinema/en-us/#search-python and the python plugin help.

            i_mazlovI 1 Reply Last reply Reply Quote 0
            • i_mazlovI
              i_mazlov @thomas
              last edited by

              Hi @thomas,

              I don't think there's a single place with aggregated Redshift Python API documentation. Such things are usually discussed on redshift forums.

              Cheers,
              Ilia

              MAXON SDK Specialist
              developers.maxon.net

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

                ok. I know not your department, but thats nuts.

                Thanks!

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