Announcement

Collapse
No announcement yet.

How to read Frame stamp with python ?

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

  • How to read Frame stamp with python ?

    Hi, is there a way how to read Frame stamp like %primitives with python or mel ?

    thx
    Rasto

  • #2
    Not for the moment. I will add it as a feature request though - either that, or writing the stamp variables as OpenEXR meta attributes. Do you have any preference as to which method would be better?

    Best regards,
    Vlado
    I only act like I know everything, Rogers.

    Comment


    • #3
      The best of the best would be to output a .xml with some infomations, statistiques....
      www.deex.info

      Comment


      • #4
        Hi Vlado, thx for your reply,

        1. for advanced users is better way to have access all available variables in Maya this way:

        Pre Render Frame MEL: python("import writemeta\nreload(writemeta)")

        writemeta.py
        Code:
        import maya.cmds as cmds
        distance = cmds.getAttr('object.translateX')
        cmds.setAttr("vraySettings.imgOpt_exr_attributes", "objectDistance="+str(distance)+", type="string")
        (here user need to read V-Ray variables like %vrayversion,%filename,%frame,%primitives,%rendert ime,%computername, etc...) for example:
        Code:
        distance = [COLOR="#008000"][B]vrayVar.vrayversion[/B][/COLOR]
        2. and second, easier way is have option write dynamic variables to Extra Attributes: comment=hello;test=%vrayversion or comment=hello;vrayVar.vrayversion

        Out of Topic: Vlado, can you help me with this ? When i try to read %polycount of scene where is only vrmesh, it's not displaying real polycount of mesh. http://forums.chaosgroup.com/showthr...-in-rendertime

        Comment


        • #5
          Originally posted by bigbossfr View Post
          The best of the best would be to output a .xml with some infomations, statistiques....
          i mean better way is read it internaly, because reading external files = more problems.

          maybe some internal array of per frame stats. (not all frames, only actual frame log)

          array = [raycasts=16619275, camera_rays=16619275, shadow_rays=0, gi_rays=0, reflection_rays=0]

          Comment


          • #6
            I am writting something, give me some minutes
            www.deex.info

            Comment


            • #7
              Ok, i writed this quickly for you.
              Here a function in python which read the vray log and get some informations :

              Code:
              import os
              def getAllStatisticFromLog():
                  allEnv = os.environ.keys()
                  if 'VRAY_FOR_MAYA_LOG_FILE_NAME' in allEnv and 'VRAY_FOR_MAYA_LOG_FILE_PATH' in allEnv:
                      logPath = os.path.join(os.environ['VRAY_FOR_MAYA_LOG_FILE_PATH'], os.environ['VRAY_FOR_MAYA_LOG_FILE_NAME'])
                  else:
                      logPath = os.path.join(os.environ['TMP'], "vray4maya_log.txt")
                  
                  numbTreeFaces = None
                  numbRaycasts = None
                  numbCameraRays = None
                  numbShdRays = None
                  numbGIRays = None
                  numbReflRays = None
                  numbRefracRays = None
                  numbUnsRays = None
                  numbInterPrim = None
                  numbSDTriangle = None
                  numbMBTriangle = None
                  numbStaticPrim = None
                  numbMovPrim = None
                  numbInfPrim = None
                  totalFrameTime = None
                  
                  if os.path.isfile(logPath):
                      with open(logPath,'r') as f:
                          output = f.readlines()
                          whereToStart = [i for i, x in enumerate(output) if "Creating and initializing renderer." in x]
                          output = output[whereToStart[-1]:]
                          for line in output:
                              if "Number of tree faces:" in line:
                                  numbTreeFaces = int(line.split()[-1])
                              elif "Number of raycasts:" in line:
                                  numbRaycasts = int(line.split()[-1])
                              elif "Camera rays:" in line:
                                  numbCameraRays = int(line.split()[-1])
                              elif "Shadow rays:" in line:
                                  numbShdRays = int(line.split()[-1])
                              elif "GI rays:" in line:
                                  numbGIRays = int(line.split()[-1])
                              elif "Reflection rays:" in line:
                                  numbReflRays = int(line.split()[-1])
                              elif "Refraction rays:" in line:
                                  numbRefracRays = int(line.split()[-1])
                              elif "Unshaded rays:" in line:
                                  numbUnsRays = int(line.split()[-1])
                              elif "Number of intersectable primitives:" in line:
                                  numbInterPrim = int(line.split()[-1])
                              elif "SD triangles:" in line:
                                  numbSDTriangle = int(line.split()[-1])
                              elif "MB triangles:" in line:
                                  numbMBTriangle = int(line.split()[-1])
                              elif "Static primitives:" in line:
                                  numbStaticPrim = int(line.split()[-1])
                              elif "Moving primitives:" in line:
                                  numbMovPrim = int(line.split()[-1])
                              elif "Infinite primitives:" in line:
                                  numbInfPrim = int(line.split()[-1])
                              elif "Total frame time" in line:
                                  totalFrameTime = float(line.split()[-2][1:])
                  return numbTreeFaces, numbRaycasts, numbCameraRays, numbShdRays, numbGIRays, numbReflRays, numbRefracRays, numbUnsRays, numbInterPrim, numbSDTriangle, numbMBTriangle, numbStaticPrim, numbMovPrim, numbInfPrim, totalFrameTime
              You can use this code into postFrame mel, and create another function to add all data into exr metadata.
              www.deex.info

              Comment


              • #8
                Originally posted by bigbossfr View Post
                Ok, i writed this quickly for you.
                Here a function in python which read the vray log and get some informations :

                Code:
                import os
                def getAllStatisticFromLog():
                    allEnv = os.environ.keys()
                    if 'VRAY_FOR_MAYA_LOG_FILE_NAME' in allEnv and 'VRAY_FOR_MAYA_LOG_FILE_PATH' in allEnv:
                        logPath = os.path.join(os.environ['VRAY_FOR_MAYA_LOG_FILE_PATH'], os.environ['VRAY_FOR_MAYA_LOG_FILE_NAME'])
                    else:
                        logPath = os.path.join(os.environ['TMP'], "vray4maya_log.txt")
                    
                    numbTreeFaces = None
                    numbRaycasts = None
                    numbCameraRays = None
                    numbShdRays = None
                    numbGIRays = None
                    numbReflRays = None
                    numbRefracRays = None
                    numbUnsRays = None
                    numbInterPrim = None
                    numbSDTriangle = None
                    numbMBTriangle = None
                    numbStaticPrim = None
                    numbMovPrim = None
                    numbInfPrim = None
                    totalFrameTime = None
                    
                    if os.path.isfile(logPath):
                        with open(logPath,'r') as f:
                            output = f.readlines()
                            whereToStart = [i for i, x in enumerate(output) if "Creating and initializing renderer." in x]
                            output = output[whereToStart[-1]:]
                            for line in output:
                                if "Number of tree faces:" in line:
                                    numbTreeFaces = int(line.split()[-1])
                                elif "Number of raycasts:" in line:
                                    numbRaycasts = int(line.split()[-1])
                                elif "Camera rays:" in line:
                                    numbCameraRays = int(line.split()[-1])
                                elif "Shadow rays:" in line:
                                    numbShdRays = int(line.split()[-1])
                                elif "GI rays:" in line:
                                    numbGIRays = int(line.split()[-1])
                                elif "Reflection rays:" in line:
                                    numbReflRays = int(line.split()[-1])
                                elif "Refraction rays:" in line:
                                    numbRefracRays = int(line.split()[-1])
                                elif "Unshaded rays:" in line:
                                    numbUnsRays = int(line.split()[-1])
                                elif "Number of intersectable primitives:" in line:
                                    numbInterPrim = int(line.split()[-1])
                                elif "SD triangles:" in line:
                                    numbSDTriangle = int(line.split()[-1])
                                elif "MB triangles:" in line:
                                    numbMBTriangle = int(line.split()[-1])
                                elif "Static primitives:" in line:
                                    numbStaticPrim = int(line.split()[-1])
                                elif "Moving primitives:" in line:
                                    numbMovPrim = int(line.split()[-1])
                                elif "Infinite primitives:" in line:
                                    numbInfPrim = int(line.split()[-1])
                                elif "Total frame time" in line:
                                    totalFrameTime = float(line.split()[-2][1:])
                    return numbTreeFaces, numbRaycasts, numbCameraRays, numbShdRays, numbGIRays, numbReflRays, numbRefracRays, numbUnsRays, numbInterPrim, numbSDTriangle, numbMBTriangle, numbStaticPrim, numbMovPrim, numbInfPrim, totalFrameTime
                You can use this code into postFrame mel, and create another function to add all data into exr metadata.
                but, how you want to write this data to images ?

                Comment


                • #9
                  Just use Python Exr lib : http://excamera.com/articles/26/doc/openexr.html
                  www.deex.info

                  Comment


                  • #10
                    You can use this code into postFrame mel, and create another function to add all data into exr metadata.
                    if you writing postFrame mel, meta data will be offseted 1 frame.

                    Originally posted by bigbossfr View Post
                    V-Ray is for artists, not for programmers.
                    I mean this is wrong way to do all externaly, if vray can handle it for you internaly and simply.

                    Comment

                    Working...
                    X