Fix mesh_snap_utilities_line running without key-maps available
[blender-addons.git] / system_blend_info.py
blob7f574cf710a6ee85a0005446803cd67fd90f6989
1 # scene_blend_info.py Copyright (C) 2010, Mariano Hidalgo
3 # Show Information About the Blend.
4 # ***** BEGIN GPL LICENSE BLOCK *****
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License
9 # as published by the Free Software Foundation; either version 2
10 # of the License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software Foundation,
19 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 # ***** END GPL LICENCE BLOCK *****
23 bl_info = {
24 "name": "Scene Information",
25 "author": "uselessdreamer",
26 "version": (0, 3, 1),
27 "blender": (2, 80, 0),
28 "location": "Properties > Scene > Blend Info Panel",
29 "description": "Show information about the .blend",
30 "warning": "",
31 "doc_url": "{BLENDER_MANUAL_URL}/addons/system/blend_info.html",
32 "category": "System",
35 import bpy
38 def quantity_string(quantity, text_single, text_plural, text_none=None):
39 sep = " "
41 if not text_none:
42 text_none = text_plural
44 if quantity == 0:
45 string = str(quantity) + sep + text_none
47 if quantity == 1:
48 string = str(quantity) + sep + text_single
50 if quantity >= 2:
51 string = str(quantity) + sep + text_plural
53 if quantity < 0:
54 return None
56 return string
59 class OBJECT_PT_blendinfo(bpy.types.Panel):
60 bl_label = "Blend Info"
61 bl_space_type = "PROPERTIES"
62 bl_region_type = "WINDOW"
63 bl_context = "scene"
64 bl_options = {'DEFAULT_CLOSED'}
66 def draw(self, context):
67 ob_cols = []
68 db_cols = []
70 objects = bpy.data.objects
72 layout = self.layout
74 # OBJECTS
76 l_row = layout.row()
77 num = len(bpy.data.objects)
78 l_row.label(text=quantity_string(num, "Object", "Objects")
79 + " in the scene:",
80 icon='OBJECT_DATA')
82 l_row = layout.row()
83 ob_cols.append(l_row.column())
84 ob_cols.append(l_row.column())
86 row = ob_cols[0].row()
87 meshes = [o for o in objects.values() if o.type == 'MESH']
88 num = len(meshes)
89 row.label(text=quantity_string(num, "Mesh", "Meshes"),
90 icon='MESH_DATA')
92 row = ob_cols[1].row()
93 curves = [o for o in objects.values() if o.type == 'CURVE']
94 num = len(curves)
95 row.label(text=quantity_string(num, "Curve", "Curves"),
96 icon='CURVE_DATA')
98 row = ob_cols[0].row()
99 cameras = [o for o in objects.values() if o.type == 'CAMERA']
100 num = len(cameras)
101 row.label(text=quantity_string(num, "Camera", "Cameras"),
102 icon='CAMERA_DATA')
104 row = ob_cols[1].row()
105 lamps = [o for o in objects.values() if o.type == 'LIGHT']
106 num = len(lamps)
107 row.label(text=quantity_string(num, "Lamp", "Lamps"),
108 icon='LIGHT_DATA')
110 row = ob_cols[0].row()
111 armatures = [o for o in objects.values() if o.type == 'ARMATURE']
112 num = len(armatures)
113 row.label(text=quantity_string(num, "Armature", "Armatures"),
114 icon='ARMATURE_DATA')
116 row = ob_cols[1].row()
117 lattices = [o for o in objects.values() if o.type == 'LATTICE']
118 num = len(lattices)
119 row.label(text=quantity_string(num, "Lattice", "Lattices"),
120 icon='LATTICE_DATA')
122 row = ob_cols[0].row()
123 empties = [o for o in objects.values() if o.type == 'EMPTY']
124 num = len(empties)
125 row.label(text=quantity_string(num, "Empty", "Empties"),
126 icon='EMPTY_DATA')
128 row = ob_cols[1].row()
129 empties = [o for o in objects.values() if o.type == 'SPEAKER']
130 num = len(empties)
131 row.label(text=quantity_string(num, "Speaker", "Speakers"),
132 icon='OUTLINER_OB_SPEAKER')
134 layout.separator()
136 # DATABLOCKS
138 l_row = layout.row()
139 num = len(bpy.data.objects)
140 l_row.label(text="Datablocks in the scene:")
142 l_row = layout.row()
143 db_cols.append(l_row.column())
144 db_cols.append(l_row.column())
146 row = db_cols[0].row()
147 num = len(bpy.data.meshes)
148 row.label(text=quantity_string(num, "Mesh", "Meshes"),
149 icon='MESH_DATA')
151 row = db_cols[1].row()
152 num = len(bpy.data.curves)
153 row.label(text=quantity_string(num, "Curve", "Curves"),
154 icon='CURVE_DATA')
156 row = db_cols[0].row()
157 num = len(bpy.data.cameras)
158 row.label(text=quantity_string(num, "Camera", "Cameras"),
159 icon='CAMERA_DATA')
161 row = db_cols[1].row()
162 num = len(bpy.data.lights)
163 row.label(text=quantity_string(num, "Lamp", "Lamps"),
164 icon='LIGHT_DATA')
166 row = db_cols[0].row()
167 num = len(bpy.data.armatures)
168 row.label(text=quantity_string(num, "Armature", "Armatures"),
169 icon='ARMATURE_DATA')
171 row = db_cols[1].row()
172 num = len(bpy.data.lattices)
173 row.label(text=quantity_string(num, "Lattice", "Lattices"),
174 icon='LATTICE_DATA')
176 row = db_cols[0].row()
177 num = len(bpy.data.materials)
178 row.label(text=quantity_string(num, "Material", "Materials"),
179 icon='MATERIAL_DATA')
181 row = db_cols[1].row()
182 num = len(bpy.data.worlds)
183 row.label(text=quantity_string(num, "World", "Worlds"),
184 icon='WORLD_DATA')
186 row = db_cols[0].row()
187 num = len(bpy.data.textures)
188 row.label(text=quantity_string(num, "Texture", "Textures"),
189 icon='TEXTURE_DATA')
191 row = db_cols[1].row()
192 num = len(bpy.data.images)
193 row.label(text=quantity_string(num, "Image", "Images"),
194 icon='IMAGE_DATA')
196 row = db_cols[0].row()
197 num = len(bpy.data.texts)
198 row.label(text=quantity_string(num, "Text", "Texts"),
199 icon='TEXT')
201 # Register
202 classes = [
203 OBJECT_PT_blendinfo
206 def register():
207 from bpy.utils import register_class
208 for cls in classes:
209 register_class(cls)
211 def unregister():
212 from bpy.utils import unregister_class
213 for cls in reversed(classes):
214 unregister_class(cls)
217 if __name__ == "__main__":
218 register()