Setting FOV in Maxscript

895 Views Asked by At

I am fairly new to Mascript and Autodesk - I have a simple script, that places a camera and I want to change the FOV, horizontally and vertically.

I am using the example provided from Max-Script Documentation, and my script looks like the following:

rgb_cam = freecamera name: "foo"  position:[0,0,0]
rgb_cam.fov Float default: 45.0

The second command gives me the error:

-- Type error: Call needs function or class, got: 45.0
-- MAXScript callstack:
--  thread data: threadID:8848
--  ------------------------------------------------------
--  [stack level: 0]
--  In top-level

So I guess, that the way the function is called is wrong, however the documentation said so. Lastly, this will only change the horizontal fov, not the vertical one - how can I change it via MaxScript?

I am using Autodesk 3ds Max 2018 - Student Version

2

There are 2 best solutions below

1
On

You just have to assign the value to the fov parameter, you do this like this:

rgb_cam = freecamera name: "foo"  position:[0,0,0]
rgb_cam.fov = 33.0

What the documentation is telling you is that the fov defaults to 45 and is a float value, that line is not a valid piece of code.

10
On

I was able to find the solution by myself. The documentation is not how to execute the files, but merely showing how the default parameters are. Furthermore, one has to change the flag determining the actual chosen field of view settings, like this:

rgb_cam = freecamera name: "rgb"  position:[0.0,0.0,25.0] rotation: (eulertoquat (eulerAngles 0 0 0))
--Horizontal FOV 
rgb_cam.fovType = 1
rgb_cam.fov = 84.1
--Vertical FOV
rgb_cam.fovType = 2
rgb_cam.fov = 48.1