Announcement

Collapse
No announcement yet.

Execute vray physical cam with mel/python

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

  • Execute vray physical cam with mel/python

    I wanted to ask if there is a solution for adding the vray physical cam attributes to a camera.
    for now I can make it work if I execute the script in two parts:

    Part1
    cmds.camera()
    camlist = cmds.ls(sl=True)
    cmds.rename(camlist[0], 'vrayPhysicalCamera')
    mel.eval('vray addAttributesFromGroup |vrayPhysicalCamera|vrayPhysicalCameraShape vray_cameraPhysical 1;')

    part2
    mel.eval('setAttr "vrayPhysicalCameraShape.vrayCameraPhysicalOn" 1;')


    However, executing everything at once produces an error:
    // Error: line 1: setAttr: No object matches name: vrayPhysicalCameraShape.vrayCameraPhysicalOn //
    # Error: RuntimeError: file line 6: Error occurred during execution of MEL script
    line 1: setAttr: No object matches name: vrayPhysicalCameraShape.vrayCameraPhysicalOn #

    This happens regardless of using mel or python.
    Is there a native python or mel command for this action, without having to execute as a two part script?


    Thank you.

  • #2
    Originally posted by MjTheHunter View Post
    I wanted to ask if there is a solution for adding the vray physical cam attributes to a camera.
    for now I can make it work if I execute the script in two parts:

    Part1
    cmds.camera()
    camlist = cmds.ls(sl=True)
    cmds.rename(camlist[0], 'vrayPhysicalCamera')
    mel.eval('vray addAttributesFromGroup |vrayPhysicalCamera|vrayPhysicalCameraShape vray_cameraPhysical 1;')

    part2
    mel.eval('setAttr "vrayPhysicalCameraShape.vrayCameraPhysicalOn" 1;')


    However, executing everything at once produces an error:
    // Error: line 1: setAttr: No object matches name: vrayPhysicalCameraShape.vrayCameraPhysicalOn //
    # Error: RuntimeError: file line 6: Error occurred during execution of MEL script
    line 1: setAttr: No object matches name: vrayPhysicalCameraShape.vrayCameraPhysicalOn #

    This happens regardless of using mel or python.
    Is there a native python or mel command for this action, without having to execute as a two part script?


    Thank you.
    You have to do an evalDefered, not a eval.
    www.deex.info

    Comment


    • #3
      Can't make it work.
      the help files says that evalDeffered is not supported in python.
      I got the script to work by including this line:

      mel.eval('vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalOn;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalType;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalFilmWidth;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalFocalLength;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalSpecifyFOV;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalFOV;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalZoomFactor;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalDistortionType;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalDistortion;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalLensFile;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalDistortionMap;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalFNumber;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalLensShift;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalShutterSpeed;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalShutterAngle;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalShutterOffset;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalLatency;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalISO;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalSpecifyFocus;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalFocusDistance;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalExposure;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalWhiteBalance;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalVignetting;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalVignettingAmount;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalBladesEnable;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalBladesNum;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalBladesRotation;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalCenterBias;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalAnisotropy;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalUseDof;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalUseMoBlur;vrayAddAttr |vrayPhysicalCamera|vrayPhysicalCameraShape vrayCameraPhysicalSubdivs;')


      Ideally I would like to avoid that.

      Comment


      • #4
        Originally posted by MjTheHunter View Post
        Can't make it work.
        the help files says that evalDeffered is not supported in python.
        mel.evalDefered('vray addAttributesFromGroup |vrayPhysicalCamera|vrayPhysicalCameraShape vray_cameraPhysical 1;')

        ?
        www.deex.info

        Comment


        • #5
          This is what I get.
          # Error: AttributeError: file <maya console> line 1: 'module' object has no attribute 'evalDeferred' #

          Comment


          • #6
            Originally posted by MjTheHunter View Post
            This is what I get.
            # Error: AttributeError: file <maya console> line 1: 'module' object has no attribute 'evalDeferred' #
            mel.eval('evalDeferred("vray addAttributesFromGroup |vrayPhysicalCamera|vrayPhysicalCameraShape vray_cameraPhysical 1;")')

            Something like this (i can not test for you now).
            www.deex.info

            Comment


            • #7
              Spoke too soon.. Still no luck.

              cmds.camera()
              camlist = cmds.ls(sl=True)
              cmds.rename(camlist[0], 'vrayPhysicalCamera')
              mel.eval('evalDeferred("vray addAttributesFromGroup |vrayPhysicalCamera|vrayPhysicalCameraShape vray_cameraPhysical 1;")')
              mel.eval('setAttr "vrayPhysicalCameraShape.vrayCameraPhysicalOn" 1;')

              execute

              // Error: line 1: setAttr: No object matches name: vrayPhysicalCameraShape.vrayCameraPhysicalOn //
              # Error: RuntimeError: file <maya console> line 5: Error occurred during execution of MEL script
              line 1: setAttr: No object matches name: vrayPhysicalCameraShape.vrayCameraPhysicalOn #


              camera name is vrayPhysicalCamera
              camera shape is vrayPhysicalCameraShape
              Last edited by MjTheHunter; 14-05-2013, 07:49 AM.

              Comment


              • #8
                You have to make the second mel.eval command to be deferred.
                The first command has some gui effects, which are executed in background and you have to execute the second command when they have finished.
                To do so you have to execute
                Code:
                mel.eval('setAttr "vrayPhysicalCameraShape.vrayCameraPhysicalOn" 1;')
                In a deferred manner...
                V-Ray developer

                Comment


                • #9
                  That fixed the error, but it doesn't seems to set the physicalCam to On?

                  Comment


                  • #10
                    For me it works, even without evalDeferred calls, but I'm using Maya 2011 on linux.
                    What V-Ray, Maya and OS version are you using?
                    V-Ray developer

                    Comment


                    • #11
                      Maya 2013 edu, vray 2.3 edu and windows 7.

                      Comment

                      Working...
                      X