Search code examples
3dsmaxmaxscript

How do I change the FOV of the 3dsmax perspective window programmatically through Maxscript?


I need to access the FOV property of the Perspective viewport. This is not the same as the FOV property associated with target and free cameras.

To access the FOV property non-programmatically, right click on the viewport name (top left of each viewport), go to configure and under "perspective user view" you can change the FOV.


Solution

  • In 3ds Max 2008 and above, you can use

     viewport.setFOV 50.0
    

    To modify the field of view of the currently active viewport.

    Check out "Accessing Active Viewport Info, Type, and Transforms" in the MaxScript help

    So:

    Utility FieldOfView "Field of View"
    (
        slider fov "Field of View" pos:[17,43] width:128 height:44 range:[25,100,viewport.GetFOV()] type:#float
    
        on fov changed val do
        (
            viewport.setFOV val
        )
    )
    

    Will create the usual little Utility that will adjust the Field of View of the currently active viewport.

    mk:@MSITStore:C:\Program%20Files\Autodesk\3ds%20Max%202009\help\maxscript.chm::/Accessing_Active_Viewport_Info_Type_and_Transforms.htm