Security checks also for other operators (rendering) ...
authorClemens Barth <barth@root-1.de>
Sun, 28 Oct 2012 21:11:31 +0000 (21:11 +0000)
committerClemens Barth <barth@root-1.de>
Sun, 28 Oct 2012 21:11:31 +0000 (21:11 +0000)
io_mesh_xyz/__init__.py

index 816c918db743ec516b284850ae7467e66214872e..b4bda1ac7f74e096b52a7bbb22caa6eb7cafedb5 100644 (file)
@@ -280,6 +280,27 @@ class CLASS_atom_xyz_create_command(Operator):
     bl_label = "Create command"
     bl_description = "Create a shell command for rendering the scene"
 
+    # If no object is in the scene, do nothing (return False).
+    @classmethod
+    def poll(self, context):
+
+        if bpy.context.object == None:
+            return False
+        if len(import_xyz.STRUCTURE) == 0:
+            return False
+        if len(import_xyz.ALL_FRAMES) < 2:
+            return False
+
+        EMPTY = True
+        for element in import_xyz.STRUCTURE:
+            if element.name != '':
+                EMPTY = False
+
+        if EMPTY == True:
+            return False
+
+        return True
+
     def execute(self, context):
         global ATOM_XYZ_ERROR
         global ATOM_XYZ_NOTE
@@ -357,6 +378,27 @@ class CLASS_atom_xyz_render(Operator):
     bl_label = "Render"
     bl_description = "Render the scene"
 
+    # If no object is in the scene, do nothing (return False).
+    @classmethod
+    def poll(self, context):
+
+        if bpy.context.object == None:
+            return False
+        if len(import_xyz.STRUCTURE) == 0:
+            return False
+        if len(import_xyz.ALL_FRAMES) < 2:
+            return False
+
+        EMPTY = True
+        for element in import_xyz.STRUCTURE:
+            if element.name != '':
+                EMPTY = False
+
+        if EMPTY == True:
+            return False
+
+        return True
+
     def execute(self, context):
         global ATOM_XYZ_ERROR
         scn = bpy.context.scene