# Why is Pie empty when no object in layer

Everything works perfect as long as the layer has an object, otherwise the Pie menu will be empty. Is that because I have a camera command in the pie and no object is present that could be used for the camera?

I get the following error:

mesh = context.active_object.data AttributeError: 'NoneType' object has no attribute 'data'

So if yes then I am curious if this is a doable Pie menu when an object has to be present for the Pie menu to work. At least the normal view commands like fullscreen or so should work and be displayed:

class View(Menu):
bl_idname = "pie.view"
bl_label = "View"

def draw(self, context):
layout = self.layout

mesh = context.active_object.data

#4 - LEFT
pie.operator("view3d.view_all", text="View All", icon="VIEWZOOM")
#6 - RIGHT
pie.operator("view3d.view_selected", text="View Selected", icon="BORDERMOVE")
#2 - BOTTOM
pie.operator("screen.screen_full_area", text="Full Screen",icon='FULLSCREEN_ENTER')
#8 - TOP
#7 - TOP - LEFT
pie.operator("view3D.object_as_camera", text="Set As Active Camera", icon="OUTLINER_DATA_CAMERA")
#9 - TOP - RIGHT
#1 - BOTTOM - LEFT
#3 - BOTTOM - RIGHT


Pie View KeyConfig

km = wm.keyconfigs.addon.keymaps.new(name = '3D View Generic', space_type = 'VIEW_3D')
kmi = km.keymap_items.new('wm.call_menu_pie', 'SPACE', 'PRESS', shift=True)
kmi.properties.name = "pie.view"


mesh = context.active_object.data

if context.active_object :