0
$\begingroup$

How do check the box labeled "Lock Camera to View" using Python?

There is a "lock_camera" property, but I don't know how to navigate to the object that has it to set it.

enter image description here

$\endgroup$

1 Answer 1

3
$\begingroup$

This code checks the "Lock Camera to View" box:

for area in bpy.context.screen.areas:
   if area.type == 'VIEW_3D':
      for space in area.spaces:
         if space.type == 'VIEW_3D':
            space.lock_camera = True
$\endgroup$
1
  • 1
    $\begingroup$ Can also use area.spaces.active to get the space assoc. with the area. $\endgroup$
    – batFINGER
    Apr 27, 2018 at 7:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .