diff --git a/blender/surf.py b/blender/surf.py index 09bb346..f7a1d21 100644 --- a/blender/surf.py +++ b/blender/surf.py @@ -20,7 +20,7 @@ class SMBDumpMesh(bpy.types.Operator, ExportHelper): @classmethod def poll(cls, context): - if context.active_object.type == 'MESH': + if context.active_object and context.active_object.type == 'MESH': return context.active_object else: return None @@ -92,7 +92,7 @@ class SMBLoadMesh(bpy.types.Operator, ExportHelper): @classmethod def poll(cls, context): - return context.active_object is not None + return True def execute(self, context): data = json.load(open(self.filepath, 'r')) @@ -103,8 +103,9 @@ class SMBLoadMesh(bpy.types.Operator, ExportHelper): for v_co in data['vertices']: bm.verts.new(v_co) - for f_idx in data['faces']: - bm.faces.new([bm.verts[i] for i in f_idx]) + if 'faces' in data: + for f_idx in data['faces']: + bm.faces.new([bm.verts[i] for i in f_idx]) bm.to_mesh(mesh) mesh.update() @@ -129,7 +130,7 @@ class SMBPanel(bpy.types.Panel): @classmethod def poll(cls, context): - return (context.object is not None) + return True def register():