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

__init__.py « oscurart_tools - git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1688c6a30579e0ecc056d1b6e7b5ce40ffdebb19 (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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
# ##### 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 LICENSE BLOCK #####

# <pep8 compliant>

bl_info = {
    "name": "Oscurart Tools",
    "author": "Oscurart, CodemanX",
    "version": (3, 5, 0),
    "blender": (2, 77, 0),
    "location": "View3D > Tools > Oscurart Tools",
    "description": "Tools for objects, render, shapes, and files.",
    "warning": "",
    "wiki_url":
        "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/3D_interaction/Oscurart_Tools",
    "tracker_url": "https://developer.blender.org/maniphest/task/edit/form/2/",
    "category": "Object",
    }

import bpy

from . import oscurart_files
from . import oscurart_meshes
from . import oscurart_objects
from . import oscurart_shapes
from . import oscurart_render
from . import oscurart_overrides
from . import oscurart_animation

import bpy
from bpy.types import (
            AddonPreferences,
            Panel,
            PropertyGroup,
            )

from bpy.props import (
            StringProperty,
            BoolProperty,
            IntProperty,
            )

class View3DOscPanel(PropertyGroup):
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'

    # CREA PANELES EN TOOLS
    osc_object_tools = BoolProperty(default=False)
    osc_mesh_tools = BoolProperty(default=False)
    osc_shapes_tools = BoolProperty(default=False)
    osc_render_tools = BoolProperty(default=False)
    osc_files_tools = BoolProperty(default=False)
    osc_overrides_tools = BoolProperty(default=False)
    osc_animation_tools = BoolProperty(default=False)

    # PARA ESCENAS NUEVAS
    overrides = bpy.props.StringProperty(default="[]")


class OscOverridesProp(PropertyGroup):
    matoverride = bpy.props.StringProperty()
    grooverride = bpy.props.StringProperty()


# PANELES
class OscPanelControl(Panel):
    bl_idname = "Oscurart Panel Control"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    bl_category = "Oscurart Tools"
    bl_label = "Panels Switcher"
    bl_options = {'DEFAULT_CLOSED'}

    def draw(self, context):
        layout = self.layout
        scene = context.scene
        oscurart = scene.oscurart

        col = layout.column(align=1)
        col.prop(oscurart, "osc_object_tools", text="Object", icon="OBJECT_DATAMODE")
        col.prop(oscurart, "osc_mesh_tools", text="Mesh", icon="EDITMODE_HLT")
        col.prop(oscurart, "osc_shapes_tools", text="Shapes", icon="SHAPEKEY_DATA")
        col.prop(oscurart, "osc_animation_tools", text="Animation", icon="POSE_DATA")
        col.prop(oscurart, "osc_render_tools", text="Render", icon="SCENE")
        col.prop(oscurart, "osc_files_tools", text="Files", icon="IMASEL")
        col.prop(oscurart, "osc_overrides_tools", text="Overrides", icon="GREASEPENCIL")


class OscPanelObject(Panel):
    bl_idname = "Oscurart Object Tools"
    bl_label = "Object Tools"
    bl_category = "Oscurart Tools"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    bl_options = {'DEFAULT_CLOSED'}

    @classmethod
    def poll(cls, context):
        return context.scene.oscurart.osc_object_tools

    def draw(self, context):
        layout = self.layout
        col = layout.column(align=1)

        colrow = col.row(align=1)
        colrow.operator("object.relink_objects_between_scenes", icon="LINKED")
        colrow = col.row(align=1)
        colrow.operator("object.copy_objects_groups_layers", icon="LINKED")
        colrow.operator("object.set_layers_to_other_scenes", icon="LINKED")
        colrow = col.row(align=1)
        colrow.operator("object.objects_to_groups", icon="GROUP")
        colrow = col.row(align=1)
        colrow.prop(bpy.context.scene, "SearchAndSelectOt", text="")
        colrow.operator("object.search_and_select_osc", icon="ZOOM_SELECTED")
        colrow = col.row(align=1)
        colrow.prop(bpy.context.scene, "RenameObjectOt", text="")
        colrow.operator("object.rename_objects_osc", icon="SHORTDISPLAY")
        col.operator(
            "object.distribute_osc",
            icon="OBJECT_DATAMODE",
            text="Distribute")
        col.operator(
            "object.duplicate_object_symmetry_osc",
            icon="OUTLINER_OB_EMPTY",
            text="Duplicate Sym")
        colrow = col.row(align=1)
        colrow.operator(
            "object.modifiers_remove_osc",
            icon="MODIFIER",
            text="Remove Modifiers")
        colrow.operator(
            "object.modifiers_apply_osc",
            icon="MODIFIER",
            text="Apply Modifiers")
        colrow = col.row(align=1)
        colrow.operator(
            "group.group_in_out_camera",
            icon="RENDER_REGION",
            text="Make Groups in out Camera")


class OscPanelMesh(Panel):
    bl_idname = "Oscurart Mesh Tools"
    bl_label = "Mesh Tools"
    bl_category = "Oscurart Tools"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    bl_options = {'DEFAULT_CLOSED'}

    @classmethod
    def poll(cls, context):
        return context.scene.oscurart.osc_mesh_tools

    def draw(self, context):
        layout = self.layout
        col = layout.column(align=1)

        col.operator("mesh.object_to_mesh_osc", icon="MESH_MONKEY")
        col.operator("mesh.select_side_osc", icon="VERTEXSEL")
        colrow = col.row(align=1)
        colrow.operator("mesh.resym_save_map", icon="UV_SYNC_SELECT")
        colrow = col.row(align=1)
        colrow.operator(
            "mesh.resym_mesh",
            icon="UV_SYNC_SELECT",
            text="Resym Mesh")
        colrow.operator("mesh.resym_vertex_weights_osc", icon="UV_SYNC_SELECT")
        colrow = col.row(align=1)
        colrow.operator("mesh.reconst_osc", icon="UV_SYNC_SELECT")
        colrow = col.row(align=1)
        colrow.operator("mesh.overlap_uv_faces", icon="UV_FACESEL")
        colrow = col.row(align=1)
        colrow.operator("view3d.modal_operator", icon="STICKY_UVS_DISABLE")
        colrow = col.row(align=1)
        colrow.operator("file.export_groups_osc", icon='GROUP_VCOL')
        colrow.operator("file.import_groups_osc", icon='GROUP_VCOL')
        colrow = col.row(align=1)
        colrow.operator("mesh.export_vertex_colors", icon='COLOR')
        colrow.operator("mesh.import_vertex_colors", icon='COLOR')


class OscPanelShapes(Panel):
    bl_idname = "Oscurart Shapes Tools"
    bl_label = "Shapes Tools"
    bl_category = "Oscurart Tools"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    bl_options = {'DEFAULT_CLOSED'}

    @classmethod
    def poll(cls, context):
        return context.scene.oscurart.osc_shapes_tools

    def draw(self, context):
        layout = self.layout
        col = layout.column(align=1)

        col.operator("object.shape_key_to_objects_osc", icon="OBJECT_DATAMODE")
        col.operator("mesh.create_lmr_groups_osc", icon="GROUP_VERTEX")
        col.operator("mesh.split_lr_shapes_osc", icon="SHAPEKEY_DATA")
        colrow = col.row(align=1)
        colrow.operator("mesh.create_symmetrical_layout_osc", icon="SETTINGS")
        colrow.operator("mesh.create_asymmetrical_layout_osc", icon="SETTINGS")


class OscPanelRender(Panel):
    bl_idname = "Oscurart Render Tools"
    bl_label = "Render Tools"
    bl_category = "Oscurart Tools"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    bl_options = {'DEFAULT_CLOSED'}

    @classmethod
    def poll(cls, context):
        return context.scene.oscurart.osc_render_tools

    def draw(self, context):
        layout = self.layout
        col = layout.column(align=1)

        colrow = col.row(align=1)
        colrow.operator(
            "render.copy_render_settings_osc",
            icon="LIBRARY_DATA_DIRECT",
            text="Copy Render Settings").mode = "render"
        colrow.operator(
            "render.copy_render_settings_osc",
            icon="LIBRARY_DATA_DIRECT",
            text="Copy Cycles Settings").mode = "cycles"
        col.operator(
            "file.create_batch_maker_osc",
            icon="LINENUMBERS_ON",
            text="Make Render Batch")
        col.operator(
            "file.create_batch_python",
            icon="LINENUMBERS_ON",
            text="Make Python Batch")
        colrow = col.row(align=1)
        colrow.operator(
            "render.render_all_scenes_osc",
            icon="RENDER_STILL",
            text="All Scenes").frametype = False
        colrow.operator(
            "render.render_all_scenes_osc",
            text="> Frame").frametype = True
        colrow = col.row(align=1)
        colrow.operator(
            "render.render_current_scene_osc",
            icon="RENDER_STILL",
            text="Active Scene").frametype = False
        colrow.operator(
            "render.render_current_scene_osc",
            text="> Frame").frametype = True

        colrow = col.row(align=1)
        colrow.operator("render.render_crop_osc", icon="RENDER_REGION")
        colrow.prop(bpy.context.scene, "rcPARTS", text="Parts")

        boxcol = layout.box().column(align=1)
        colrow = boxcol.row(align=1)
        colrow.operator(
            "render.render_selected_scenes_osc",
            icon="RENDER_STILL",
            text="Selected Scenes").frametype = False
        colrow.operator(
            "render.render_selected_scenes_osc",
            text="> Fame").frametype = True

        for sc in bpy.data.scenes[:]:
            boxcol.prop(sc, "use_render_scene", text=sc.name)


class OscPanelFiles(Panel):
    bl_idname = "Oscurart Files Tools"
    bl_label = "Files Tools"
    bl_category = "Oscurart Tools"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    bl_options = {'DEFAULT_CLOSED'}

    @classmethod
    def poll(cls, context):
        return context.scene.oscurart.osc_files_tools

    def draw(self, context):
        layout = self.layout
        col = layout.column(align=1)
        col.operator("file.save_incremental_osc", icon="NEW")
        col.operator("image.reload_images_osc", icon="IMAGE_COL")
        col.operator("file.sync_missing_groups", icon="LINK_AREA")
        col = layout.column(align=1)
        colrow = col.row(align=1)
        colrow.prop(bpy.context.scene, "oscSearchText", text="")
        colrow.prop(bpy.context.scene, "oscReplaceText", text="")
        col.operator("file.replace_file_path_osc", icon="SHORTDISPLAY")


class OscPanelOverrides(Panel):
    bl_idname = "Oscurart Overrides"
    bl_label = "Overrides Tools"
    bl_category = "Oscurart Tools"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    bl_options = {'DEFAULT_CLOSED'}

    @classmethod
    def poll(cls, context):
        return context.scene.oscurart.osc_overrides_tools

    def draw(self, context):
        layout = self.layout
        box = layout.box()
        col = box.column(align=1)

        # col.operator("render.overrides_set_list", text="Create Override
        # List", icon="GREASEPENCIL")
        col.label(text="Active Scene: " + bpy.context.scene.name)
        col.label(text="Example: [[Group,Material]]")
        col.prop(bpy.context.scene.oscurart, "overrides", text="")
        col.operator(
            "render.check_overrides",
            text="Check List",
            icon="ZOOM_ALL")
        col.operator("render.overrides_on", text="On / Off", icon="QUIT")
        col.label(
            text=str("OVERRIDES: ON" if bpy.use_overrides else "OVERRIDES: OFF"))

        box = layout.box()
        boxcol = box.column(align=1)
        boxcol.label(text="Danger Zone")
        boxcolrow = boxcol.row(align=1)
        boxcolrow.operator(
            "render.apply_overrides",
            text="Apply Overrides",
            icon="ERROR")
        boxcolrow.operator(
            "render.restore_overrides",
            text="Restore Overrides",
            icon="ERROR")


class OscPanelAnimation(Panel):
    bl_idname = "Oscurart Animation Tools"
    bl_label = "Animation Tools"
    bl_category = "Oscurart Tools"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    bl_options = {'DEFAULT_CLOSED'}

    @classmethod
    def poll(cls, context):
        return context.scene.oscurart.osc_animation_tools

    def draw(self, context):
        layout = self.layout
        col = layout.column(align=1)
        row = col.row()

        col.operator("anim.quick_parent_osc", icon="OUTLINER_DATA_POSE")
        row = col.row(align=1)
        row.prop(bpy.context.scene, "quick_animation_in", text="")
        row.prop(bpy.context.scene, "quick_animation_out", text="")


# Addons Preferences Update Panel

def update_panel(self, context):
    try:
        bpy.utils.unregister_class(OscPanelControl)
        bpy.utils.unregister_class(OscPanelObject)
        bpy.utils.unregister_class(OscPanelMesh)
        bpy.utils.unregister_class(OscPanelShapes)
        bpy.utils.unregister_class(OscPanelRender)
        bpy.utils.unregister_class(OscPanelFiles)
        bpy.utils.unregister_class(OscPanelOverrides)
        bpy.utils.unregister_class(OscPanelAnimation)
    except:
        pass

    addon_prefs = context.user_preferences.addons[__name__].preferences

    OscPanelControl.bl_category = addon_prefs.category
    bpy.utils.register_class(OscPanelControl)
    OscPanelObject.bl_category = addon_prefs.category
    bpy.utils.register_class(OscPanelObject)
    OscPanelMesh.bl_category = addon_prefs.category
    bpy.utils.register_class(OscPanelMesh)
    OscPanelShapes.bl_category = addon_prefs.category
    bpy.utils.register_class(OscPanelShapes)
    OscPanelRender.bl_category = addon_prefs.category
    bpy.utils.register_class(OscPanelRender)
    OscPanelFiles.bl_category = addon_prefs.category
    bpy.utils.register_class(OscPanelFiles)
    OscPanelOverrides.bl_category = addon_prefs.category
    bpy.utils.register_class(OscPanelOverrides)
    OscPanelAnimation.bl_category = addon_prefs.category
    bpy.utils.register_class(OscPanelAnimation)


class OscurartToolsAddonPreferences(bpy.types.AddonPreferences):
    # this must match the addon name, use '__package__'
    # when defining this in a submodule of a python package.
    bl_idname = __name__

    category = bpy.props.StringProperty(
            name="Category",
            description="Choose a name for the category of the panel",
            default="Oscurart Tools",
            update=update_panel,
            )

    def draw(self, context):

        layout = self.layout
        row = layout.row()
        col = row.column()
        col.label(text="Category:")
        col.prop(self, "category", text="")

# ========================= FIN DE SCRIPTS =========================


def register():
    bpy.utils.register_module(__name__)

    bpy.types.Scene.oscurart = bpy.props.PointerProperty(type=View3DOscPanel)

    bpy.types.Scene.ovlist = bpy.props.CollectionProperty(type=OscOverridesProp)

    bpy.types.Scene.quick_animation_in = bpy.props.IntProperty(default=1)
    bpy.types.Scene.quick_animation_out = bpy.props.IntProperty(default=250)

    # SETEO VARIABLE DE ENTORNO
    bpy.types.Scene.SearchAndSelectOt = bpy.props.StringProperty(
                                               default="Object name initials")


def unregister():
    del bpy.types.Scene.oscurart
    del bpy.types.Scene.quick_animation_in
    del bpy.types.Scene.quick_animation_out
    del bpy.types.Scene.SearchAndSelectOt

    bpy.utils.unregister_module(__name__)


if __name__ == "__main__":
    register()