I want to know the width and the height of my camera in blender-units.


Therefore I've written a small script:

import bpy

camera = bpy.context.selected_objects[0]


But all I get is 0. Is there any other way to get the dimensions?


As far as I know camera objects don't have geometry, and hence no real world Blender Units dimensions.

The viewport size of a camera object depends on a variety of factors.

The camera object size reflects the render resolution set in the render properties panel, changing proportions according to the image size. On top of that a scaling factor is applied, controlled by the Size property in the Object Data panel > Display > Size.

Besides that the Focal length will also affect the camera shape by adjusting the angle of the sides to reflect the current view field.

You may be able to calculate the resulting viewport size by recreating the math internally used by Blender to represent said camera object though, but I wouldn't expect that information would be readily accessible from the Python API.

  • 1
    $\begingroup$ You should be able to find it in the code that actually draws the camera in the 3D viewport. $\endgroup$ – dr. Sybren Dec 7 '17 at 11:57

Perhaps look at bpy.context.scene.render.resolution_x

You might find that you can get that info and it will stay the same since if you change the render resolution of a new camera, the old camera changes to match.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.