Welcome to mirror list, hosted at ThFree Co, Russian Federation.

system_blend_info.py - git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b8e79a6fd0fa7df724f4f30225682f7af5cb515b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright 2010 Mariano Hidalgo

# Show Information About the Blend.

bl_info = {
    "name": "Scene Information",
    "author": "uselessdreamer",
    "version": (0, 3, 1),
    "blender": (2, 80, 0),
    "location": "Properties > Scene > Blend Info Panel",
    "description": "Show information about the .blend",
    "warning": "",
    "doc_url": "{BLENDER_MANUAL_URL}/addons/system/blend_info.html",
    "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"
    bl_options = {'DEFAULT_CLOSED'}

    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"),
            icon='MESH_DATA')

        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"),
            icon='CURVE_DATA')

        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"),
            icon='CAMERA_DATA')

        row = ob_cols[1].row()
        lamps = [o for o in objects.values() if o.type == 'LIGHT']
        num = len(lamps)
        row.label(text=quantity_string(num, "Lamp", "Lamps"),
            icon='LIGHT_DATA')

        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"),
            icon='ARMATURE_DATA')

        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"),
            icon='LATTICE_DATA')

        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"),
            icon='EMPTY_DATA')

        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')

        layout.separator()

        # 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"),
            icon='MESH_DATA')

        row = db_cols[1].row()
        num = len(bpy.data.curves)
        row.label(text=quantity_string(num, "Curve", "Curves"),
            icon='CURVE_DATA')

        row = db_cols[0].row()
        num = len(bpy.data.cameras)
        row.label(text=quantity_string(num, "Camera", "Cameras"),
            icon='CAMERA_DATA')

        row = db_cols[1].row()
        num = len(bpy.data.lights)
        row.label(text=quantity_string(num, "Lamp", "Lamps"),
            icon='LIGHT_DATA')

        row = db_cols[0].row()
        num = len(bpy.data.armatures)
        row.label(text=quantity_string(num, "Armature", "Armatures"),
            icon='ARMATURE_DATA')

        row = db_cols[1].row()
        num = len(bpy.data.lattices)
        row.label(text=quantity_string(num, "Lattice", "Lattices"),
            icon='LATTICE_DATA')

        row = db_cols[0].row()
        num = len(bpy.data.materials)
        row.label(text=quantity_string(num, "Material", "Materials"),
            icon='MATERIAL_DATA')

        row = db_cols[1].row()
        num = len(bpy.data.worlds)
        row.label(text=quantity_string(num, "World", "Worlds"),
            icon='WORLD_DATA')

        row = db_cols[0].row()
        num = len(bpy.data.textures)
        row.label(text=quantity_string(num, "Texture", "Textures"),
            icon='TEXTURE_DATA')

        row = db_cols[1].row()
        num = len(bpy.data.images)
        row.label(text=quantity_string(num, "Image", "Images"),
            icon='IMAGE_DATA')

        row = db_cols[0].row()
        num = len(bpy.data.texts)
        row.label(text=quantity_string(num, "Text", "Texts"),
            icon='TEXT')

# Register
classes = [
    OBJECT_PT_blendinfo
]

def register():
    from bpy.utils import register_class
    for cls in classes:
        register_class(cls)

def unregister():
    from bpy.utils import unregister_class
    for cls in reversed(classes):
        unregister_class(cls)


if __name__ == "__main__":
    register()