Newer
Older
# scene_blend_info.py Copyright (C) 2010, Mariano Hidalgo
#
# Show Information About the Blend.
# ***** BEGIN GPL LICENSE BLOCK *****
#
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ***** END GPL LICENCE BLOCK *****
"author": "uselessdreamer",
"location": "Properties > Scene > Blend Info Panel",
"description": "Show information about the .blend",
"warning": "",
"wiki_url": 'http://wiki.blender.org/index.php/Extensions:2.5/Py/' \
'Scripts/System/Blend Info',
"tracker_url": "https://projects.blender.org/tracker/index.php?" \
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"category": "System"}
import bpy
def quantity_string(quantity, text_single, text_plural, text_none=None):
sep = " "
if not text_none:
text_none = text_plural
if quantity == 0:
string = str(quantity) + sep + text_none
if quantity == 1:
string = str(quantity) + sep + text_single
if quantity >= 2:
string = str(quantity) + sep + text_plural
if quantity < 0:
return None
return string
class OBJECT_PT_blendinfo(bpy.types.Panel):
bl_label = "Blend Info"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "scene"
def draw(self, context):
ob_cols = []
db_cols = []
objects = bpy.data.objects
layout = self.layout
# OBJECTS
l_row = layout.row()
num = len(bpy.data.objects)
l_row.label(text=quantity_string(num, "Object", "Objects")
+ " in the scene:",
icon='OBJECT_DATA')
l_row = layout.row()
ob_cols.append(l_row.column())
ob_cols.append(l_row.column())
row = ob_cols[0].row()
meshes = [o for o in objects.values() if o.type == 'MESH']
num = len(meshes)
row.label(text=quantity_string(num, "Mesh", "Meshes"),
row = ob_cols[1].row()
curves = [o for o in objects.values() if o.type == 'CURVE']
num = len(curves)
row.label(text=quantity_string(num, "Curve", "Curves"),
row = ob_cols[0].row()
cameras = [o for o in objects.values() if o.type == 'CAMERA']
num = len(cameras)
row.label(text=quantity_string(num, "Camera", "Cameras"),
row = ob_cols[1].row()
lamps = [o for o in objects.values() if o.type == 'LAMP']
num = len(lamps)
row.label(text=quantity_string(num, "Lamp", "Lamps"),
row = ob_cols[0].row()
armatures = [o for o in objects.values() if o.type == 'ARMATURE']
num = len(armatures)
row.label(text=quantity_string(num, "Armature", "Armatures"),
row = ob_cols[1].row()
lattices = [o for o in objects.values() if o.type == 'LATTICE']
num = len(lattices)
row.label(text=quantity_string(num, "Lattice", "Lattices"),
row = ob_cols[0].row()
empties = [o for o in objects.values() if o.type == 'EMPTY']
num = len(empties)
row.label(text=quantity_string(num, "Empty", "Empties"),
row = ob_cols[1].row()
empties = [o for o in objects.values() if o.type == 'SPEAKER']
num = len(empties)
row.label(text=quantity_string(num, "Speaker", "Speakers"),
icon='OUTLINER_OB_SPEAKER')
# DATABLOCKS
l_row = layout.row()
num = len(bpy.data.objects)
l_row.label(text="Datablocks in the scene:")
l_row = layout.row()
db_cols.append(l_row.column())
db_cols.append(l_row.column())
row = db_cols[0].row()
num = len(bpy.data.meshes)
row.label(text=quantity_string(num, "Mesh", "Meshes"),
row = db_cols[1].row()
num = len(bpy.data.curves)
row.label(text=quantity_string(num, "Curve", "Curves"),
row = db_cols[0].row()
num = len(bpy.data.cameras)
row.label(text=quantity_string(num, "Camera", "Cameras"),
row = db_cols[1].row()
num = len(bpy.data.lamps)
row.label(text=quantity_string(num, "Lamp", "Lamps"),
row = db_cols[0].row()
num = len(bpy.data.armatures)
row.label(text=quantity_string(num, "Armature", "Armatures"),
row = db_cols[1].row()
num = len(bpy.data.lattices)
row.label(text=quantity_string(num, "Lattice", "Lattices"),
row = db_cols[0].row()
num = len(bpy.data.materials)
row.label(text=quantity_string(num, "Material", "Materials"),
row = db_cols[1].row()
num = len(bpy.data.worlds)
row.label(text=quantity_string(num, "World", "Worlds"),
row = db_cols[0].row()
num = len(bpy.data.textures)
row.label(text=quantity_string(num, "Texture", "Textures"),
row = db_cols[1].row()
num = len(bpy.data.images)
row.label(text=quantity_string(num, "Image", "Images"),
row = db_cols[0].row()
num = len(bpy.data.texts)
row.label(text=quantity_string(num, "Text", "Texts"),
def register():
Campbell Barton
committed
bpy.utils.register_module(__name__)
pass
def unregister():
Campbell Barton
committed
bpy.utils.unregister_module(__name__)
pass
if __name__ == "__main__":
register()