Announcement

Collapse
No announcement yet.

V-Ray render settings and python

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • V-Ray render settings and python

    Hi!
    In all our template files we use relative render paths. but in some cases we need absolute paths to save images correctly.
    I've been trying to create a script where i can replace the relative vray output path with an absolute path that keeps the tokens. I've used an existing script i found on github that works fine with cinema 4d s built it look like the file path attribute is not a string.

    I attacedd the script below. can someone help me with this? I'm a bit confused about interfacing with vray through python.​

  • #2
    Sry missed the file.... Can't upload txt or py so please see the following wetransfer link
    https://we.tl/t-4B7AleuOcI

    Comment


    • #3
      Hi akos_kiss, the file output attribute is actually a Filename, but the Cinema 4D python API has Filenames interchangeable with strings. In other words, the problem in your script is not the parameter type, but rather from where you are trying to read and write the parameter. I'll try to explain in details, based on your script.

      The standard Cinema 4D output settings are part of the RenderData. But different render engines (including V-Ray) are separate objects (called VideoPost) and have to be accessed from the RenderData by iterating over the VideoPost instances contained in it. Basically you need to find or insert the V-Ray video post with something like this:
      Code:
      def getOrInsertVRayVideoPost(document: c4d.BaseDocument):
          renderData: c4d.RenderData = document.GetActiveRenderData()
          if not renderData:
              return None
          videoPost: c4d.BaseVideoPost = renderData.GetFirstVideoPost()
          while videoPost is not None:
              # V-Ray VideoPost
              if videoPost.GetType() == 1053272:
                  break
              videoPost = videoPost.GetNext()
          if not videoPost:
              # Create new V-Ray video post
              videoPost=c4d.documents.BaseVideoPost(1053272)
              if videoPost:
                  renderData.InsertVideoPost(videoPost, None)
          return videoPost​
      Once you have the V-Ray video post instance, you can read and write parameters to it, preferably using the GetParameter(..) and SetParameter(..) functions. I'm attaching the full example python script to my post (as .txt): change_vray_output.txt

      I hope this helps you in your endeavours.
      Deyan Hadzhiev
      Developer
      chaos.com

      Comment


      • #4
        Hi deyan.hadzhiev Thank you so much for the clarification! I think this will make it a lot easier Our template has the render settings set up but the when using the render queue or a render farm we have to switch form relativ paths to absolute file paths and this script will make it a lot easier with the v-ray output system.

        Comment

        Working...
        X