Announcement

Collapse
No announcement yet.

How to get the path of a V-Ray output image by mel?

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

  • How to get the path of a V-Ray output image by mel?

    I want to show the path of an output image by post render mel.
    How to get the path of a V-Ray output image by mel?

    At mr or sw, it gets by "renderSettings -lastImageName".

    OakCorp Japan - Yuji Yamauchi
    oakcorp.net
    v-ray.jp

  • #2
    Image prefix :

    Code:
    def getVRayRealImageNamePrefix(prefix, renderLayer, camera):
        prefix = prefix.replace("<Layer>", renderLayer)
        prefix = prefix.replace("<layer>", renderLayer)
        prefix = prefix.replace("%Layer", renderLayer)
        prefix = prefix.replace("%layer", renderLayer)
        prefix = prefix.replace("%l", renderLayer)
    
        return mel.eval('vrayTransformFilename("%s", "%s", "", 0, 0)' % (prefix, camera))
    Folder :
    Code:
    def getFullCurrentImagesDir():
        return os.path.join(cmds.workspace(q=True, active=True), cmds.workspace("images", q=True, fre=True).strip())
    www.deex.info

    Comment


    • #3
      Thank you for defining by python.
      It is helpful.

      There is no command which gets the full path of an output image by the mel command of vray?

      OakCorp Japan - Yuji Yamauchi
      oakcorp.net
      v-ray.jp

      Comment


      • #4
        On the one hand, the MEL version will not be shorter than the python one. Just as long in the best case.
        On the other hand, however, you can query the actual UI controls where we already expand the keywoards and pre-pend the path and use something like this:

        DISCLAIMER: The below code uses the current internal naming of the VRay UI controls in Maya. There could or will come a time when we change the names of those controls and the below code will no longer work. The time and reason for changing this naming is entirely to our discretion. Use at your own risk.

        Code:
        global proc string vrayGetFullPath() {
            string $vrPathCtrl = `text -q -label vrayPathPreview`;
            string $vrPathClean = substring($vrPathCtrl, 7, size($vrPathCtrl));
            string $vrFileNameCtrl = `text -q -label vrayFilenamePreview`;
            string $vrFileNameClean = substring($vrFileNameCtrl, 12, size($vrFileNameCtrl));
            string $vrFullPath = $vrPathClean + "/" + $vrFileNameClean;
        
            return $vrFullPath;
        }
        Now you can just run vrayGetFullPath in MEL and it will return the full path/filename.ext to get the actual name of the file to be saved.
        Last edited by yolov; 15-06-2016, 01:46 PM.
        Alex Yolov
        Product Manager
        V-Ray for Maya, Chaos Player
        www.chaos.com

        Comment


        • #5
          Thank you very much.
          It is helpful.

          OakCorp Japan - Yuji Yamauchi
          oakcorp.net
          v-ray.jp

          Comment


          • #6
            The following messages will be shown if vrayGetFullPath() is called from PostRenderScript of MayaBatch.

            Code:
            Warning: line 2: Starting position (7) is invalid.  It must be in the range from 1 to the length of the string.  Clamping index to range.
            Warning: line 5: Starting position (12) is invalid.  It must be in the range from 1 to the length of the string.  Clamping index to range.
            Is there any solution?
            It works from PostRenderScript of GUI.

            OakCorp Japan - Yuji Yamauchi
            oakcorp.net
            v-ray.jp

            Comment


            • #7
              you need the definition of the function first, and call it after it is defined. So you probably need the entire script I posted. OR save it to a .mel file, put it in the maya script folder (so it's loaded in memory when maya loads) and then you can call only vrayGetFullPath() without the definition.
              Alex Yolov
              Product Manager
              V-Ray for Maya, Chaos Player
              www.chaos.com

              Comment


              • #8
                Ah, forgive my foolishness, it didn't read your last post carefully. This will not work in batch mode, since like I explained when I posted it - it reads the UI labels where we expand the path and filename - those do not exist in command-line batch mode.
                Alex Yolov
                Product Manager
                V-Ray for Maya, Chaos Player
                www.chaos.com

                Comment


                • #9
                  Could we maybe add a feature request to get a function for this that always work? I currently do as bigbossfr but sometimes get incorrect results.

                  -- Erik

                  Comment


                  • #10
                    OK. I understand.
                    The feature which can get a output path without depending on UI is hoped.

                    OakCorp Japan - Yuji Yamauchi
                    oakcorp.net
                    v-ray.jp

                    Comment


                    • #11
                      What do you need to use it for?
                      Alex Yolov
                      Product Manager
                      V-Ray for Maya, Chaos Player
                      www.chaos.com

                      Comment


                      • #12
                        Renderfarm things where I need to know output before it exists.

                        -- Erik

                        Comment


                        • #13
                          Yes, but how exactly - what is going to happen with the returned value "path/filename.ext" once it is returned to you? Printed into some log, where if you think is incorrect you will stop the rendering and readjust the output settings? We need that info to think of possible solutions.
                          Alex Yolov
                          Product Manager
                          V-Ray for Maya, Chaos Player
                          www.chaos.com

                          Comment


                          • #14
                            Preview path for tractor.

                            Input for post render jobs.

                            I guess in current cases the grabbing UI elements way should work but it would be nice with a function that I know won't stop working between versions.

                            It would also be nice that if it worked similar to vrayTransformFilename but if no Camera or RenderLayer is passed it returns paths to all combinations.

                            -- Erik

                            Comment


                            • #15
                              You can try this post-translate python for batch mode. Once the scene is passed from maya to vray, it will ask vray the dir+filename. The downside is that it will only be run once, so you won't get updates for each frame, for example.
                              Code:
                              from vray.utils import *
                              p=findByType("SettingsOutput")
                              d=p[0].get("img_dir")
                              f=p[0].get("img_file")
                              print d+f
                              Alex Yolov
                              Product Manager
                              V-Ray for Maya, Chaos Player
                              www.chaos.com

                              Comment

                              Working...
                              X