I experience the following error when no object is present on the layer:
Traceback (most recent call last):
File "C:\Users\info\Desktop\untitled.blend\studioTools_Shelf_Beta v2.py", line 352, in draw
AttributeError: 'NoneType' object has no attribute 'data'
location: <unknown location>:-1
This is part of the object shading class I wrote.
class ObjectShading(bpy.types.Panel):
bl_label = "Viewport Shading"
bl_idname = "ObjectShading"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
bl_category = "Shading Toolbox"
def draw(self, context):
layout = self.layout
mesh = obj.data
row = layout.row()
row.prop(mesh, "use_auto_smooth", text="Break Edges")
Do I have to build in a switch that in case no object is present on the layer this class is ignored meaning the object shading tab is not evaluated? Similar to the switch here: Ray visibility panel
Here is what I learned and this approach works - I am just curious if this is the way one should do it or if in this case a better idea should be used.
class ObjectShading(bpy.types.Panel):
bl_label = "Viewport Shading"
bl_idname = "ObjectShading"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
bl_category = "Modeling Toolbox"
def draw(self, context):
layout = self.layout
mesh = obj.data