which will fail (throw a KeyError
) if there is no object named camera, which could simply mean its been renamed, or is camera in a different language etc. It could be the camera linked to another scene, or no scene at all... in which case sliding it would appear to do nought.
Suggest in the case of camera, the active camera is assigned to the scene, scene.camera
. As long as this is set can use instead. This is the camera used when pressing Numpad 0 for camera view.
import bpy
class VIEW3D_PT_dof(bpy.types.Panel):
bl_idname = "VIEW3D_PT_dof"
bl_label = "Quick Focus"
bl_category = "DOF"
bl_space_type = "VIEW_3D"'VIEW_3D'
bl_region_type = "UI"'UI'
@classmethod
def poll(cls, context):
return context.scene.comaeracamera is not None
def draw_header(self, context):
layout = self.layout
layout.label(icon = "CAMERA_DATA"icon='CAMERA_DATA')
def draw(self, context):
layout = self.layout
cam = context.scene.camera
col = layout.column()
#col.label(text= "Focus", icon="CAMERA_DATA"icon='CAMERA_DATA')
col.operator("wm.splash")
col.operator("wm.splash")
col.prop(cam.data.dof, "aperture_fstop", slider=True)
classes = (
VIEW3D_PT_dof,
)
def register():
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)
if __name__ == "__main__":
register()