FBX Import: Speed up parsing by reading entire subtrees into BytesIO
[blender-addons.git] / system_blend_info.py
blobb0fa8536edc2a421943d5b66fc65f19aecc84805
1 # SPDX-FileCopyrightText: 2010 Mariano Hidalgo
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 bl_info = {
6 "name": "Scene Information",
7 "author": "uselessdreamer",
8 "version": (0, 3, 1),
9 "blender": (2, 80, 0),
10 "location": "Properties > Scene > Blend Info Panel",
11 "description": "Show information about the .blend",
12 "warning": "",
13 "doc_url": "{BLENDER_MANUAL_URL}/addons/system/blend_info.html",
14 "category": "System",
17 import bpy
20 def quantity_string(quantity, text_single, text_plural, text_none=None):
21 sep = " "
23 if not text_none:
24 text_none = text_plural
26 if quantity == 0:
27 string = str(quantity) + sep + text_none
29 if quantity == 1:
30 string = str(quantity) + sep + text_single
32 if quantity >= 2:
33 string = str(quantity) + sep + text_plural
35 if quantity < 0:
36 return None
38 return string
41 class OBJECT_PT_blendinfo(bpy.types.Panel):
42 bl_label = "Blend Info"
43 bl_space_type = "PROPERTIES"
44 bl_region_type = "WINDOW"
45 bl_context = "scene"
46 bl_options = {'DEFAULT_CLOSED'}
48 def draw(self, context):
49 ob_cols = []
50 db_cols = []
52 objects = bpy.data.objects
54 layout = self.layout
56 # OBJECTS
58 l_row = layout.row()
59 num = len(bpy.data.objects)
60 l_row.label(text=quantity_string(num, "Object", "Objects")
61 + " in the scene:",
62 icon='OBJECT_DATA')
64 l_row = layout.row()
65 ob_cols.append(l_row.column())
66 ob_cols.append(l_row.column())
68 row = ob_cols[0].row()
69 meshes = [o for o in objects.values() if o.type == 'MESH']
70 num = len(meshes)
71 row.label(text=quantity_string(num, "Mesh", "Meshes"),
72 icon='MESH_DATA')
74 row = ob_cols[1].row()
75 curves = [o for o in objects.values() if o.type == 'CURVE']
76 num = len(curves)
77 row.label(text=quantity_string(num, "Curve", "Curves"),
78 icon='CURVE_DATA')
80 row = ob_cols[0].row()
81 cameras = [o for o in objects.values() if o.type == 'CAMERA']
82 num = len(cameras)
83 row.label(text=quantity_string(num, "Camera", "Cameras"),
84 icon='CAMERA_DATA')
86 row = ob_cols[1].row()
87 lamps = [o for o in objects.values() if o.type == 'LIGHT']
88 num = len(lamps)
89 row.label(text=quantity_string(num, "Lamp", "Lamps"),
90 icon='LIGHT_DATA')
92 row = ob_cols[0].row()
93 armatures = [o for o in objects.values() if o.type == 'ARMATURE']
94 num = len(armatures)
95 row.label(text=quantity_string(num, "Armature", "Armatures"),
96 icon='ARMATURE_DATA')
98 row = ob_cols[1].row()
99 lattices = [o for o in objects.values() if o.type == 'LATTICE']
100 num = len(lattices)
101 row.label(text=quantity_string(num, "Lattice", "Lattices"),
102 icon='LATTICE_DATA')
104 row = ob_cols[0].row()
105 empties = [o for o in objects.values() if o.type == 'EMPTY']
106 num = len(empties)
107 row.label(text=quantity_string(num, "Empty", "Empties"),
108 icon='EMPTY_DATA')
110 row = ob_cols[1].row()
111 empties = [o for o in objects.values() if o.type == 'SPEAKER']
112 num = len(empties)
113 row.label(text=quantity_string(num, "Speaker", "Speakers"),
114 icon='OUTLINER_OB_SPEAKER')
116 layout.separator()
118 # DATABLOCKS
120 l_row = layout.row()
121 num = len(bpy.data.objects)
122 l_row.label(text="Datablocks in the scene:")
124 l_row = layout.row()
125 db_cols.append(l_row.column())
126 db_cols.append(l_row.column())
128 row = db_cols[0].row()
129 num = len(bpy.data.meshes)
130 row.label(text=quantity_string(num, "Mesh", "Meshes"),
131 icon='MESH_DATA')
133 row = db_cols[1].row()
134 num = len(bpy.data.curves)
135 row.label(text=quantity_string(num, "Curve", "Curves"),
136 icon='CURVE_DATA')
138 row = db_cols[0].row()
139 num = len(bpy.data.cameras)
140 row.label(text=quantity_string(num, "Camera", "Cameras"),
141 icon='CAMERA_DATA')
143 row = db_cols[1].row()
144 num = len(bpy.data.lights)
145 row.label(text=quantity_string(num, "Lamp", "Lamps"),
146 icon='LIGHT_DATA')
148 row = db_cols[0].row()
149 num = len(bpy.data.armatures)
150 row.label(text=quantity_string(num, "Armature", "Armatures"),
151 icon='ARMATURE_DATA')
153 row = db_cols[1].row()
154 num = len(bpy.data.lattices)
155 row.label(text=quantity_string(num, "Lattice", "Lattices"),
156 icon='LATTICE_DATA')
158 row = db_cols[0].row()
159 num = len(bpy.data.materials)
160 row.label(text=quantity_string(num, "Material", "Materials"),
161 icon='MATERIAL_DATA')
163 row = db_cols[1].row()
164 num = len(bpy.data.worlds)
165 row.label(text=quantity_string(num, "World", "Worlds"),
166 icon='WORLD_DATA')
168 row = db_cols[0].row()
169 num = len(bpy.data.textures)
170 row.label(text=quantity_string(num, "Texture", "Textures"),
171 icon='TEXTURE_DATA')
173 row = db_cols[1].row()
174 num = len(bpy.data.images)
175 row.label(text=quantity_string(num, "Image", "Images"),
176 icon='IMAGE_DATA')
178 row = db_cols[0].row()
179 num = len(bpy.data.texts)
180 row.label(text=quantity_string(num, "Text", "Texts"),
181 icon='TEXT')
183 # Register
184 classes = [
185 OBJECT_PT_blendinfo
188 def register():
189 from bpy.utils import register_class
190 for cls in classes:
191 register_class(cls)
193 def unregister():
194 from bpy.utils import unregister_class
195 for cls in reversed(classes):
196 unregister_class(cls)
199 if __name__ == "__main__":
200 register()