forked from CGCookie/io_export_blend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
88 lines (71 loc) · 3.3 KB
/
__init__.py
File metadata and controls
88 lines (71 loc) · 3.3 KB
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
# ***** 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 *****
bl_info = {
"name": "Export .blend",
"author": "Jason van Gumster (Fweeb)",
"version": (1, 0),
"blender": (2, 83, 0),
"location": "File > Export > Blender (.blend)/Outliner > Context Menu > Export to .blend",
"description": "Exports all or some datablocks to a separate .blend file",
"warning": "",
"doc_url": "https://github.com/CGCookie/io_export_blend",
"tracker_url": "https://github.com/CGCookie/io_export_blend/issues",
"category": "Import-Export",
}
import bpy
# Local imports
from .exporters import ExportBlenderObjects, ExportBlenderCollection, ExportBlenderNodes
# UI
def menu_func_export(self, context):
if self.bl_label == "Export":
self.layout.operator(ExportBlenderObjects.bl_idname, text="Blender (.blend)")
elif self.bl_label == "Collection":
if len(context.selected_ids) == 1 and isinstance(context.selected_ids[0], bpy.types.Collection):
self.layout.operator_context = "INVOKE_DEFAULT"
self.layout.operator(ExportBlenderCollection.bl_idname, text="Export to .blend")
elif self.bl_label == "Object":
self.layout.operator_context = "INVOKE_DEFAULT"
self.layout.operator(ExportBlenderObjects.bl_idname, text="Export to .blend")
def menu_func_export_nodes(self, context):
self.layout.operator_context = "INVOKE_DEFAULT"
#XXX Disabling for Compositor nodes until bugfix for T88402
if context.active_node.id_data.type != 'COMPOSITING':
op = self.layout.operator(ExportBlenderNodes.bl_idname, text="Export to .blend")
#if context.active_node.id_data.type == 'COMPOSITING':
# op.is_compositor = True
def register():
bpy.utils.register_class(ExportBlenderObjects)
bpy.utils.register_class(ExportBlenderCollection)
bpy.utils.register_class(ExportBlenderNodes)
bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
bpy.types.OUTLINER_MT_object.append(menu_func_export)
bpy.types.OUTLINER_MT_collection.append(menu_func_export)
bpy.types.NODE_MT_node.append(menu_func_export_nodes)
def unregister():
bpy.utils.unregister_class(ExportBlenderObjects)
bpy.utils.unregister_class(ExportBlenderCollection)
bpy.utils.unregister_class(ExportBlenderNodes)
bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
bpy.types.OUTLINER_MT_object.remove(menu_func_export)
bpy.types.OUTLINER_MT_collection.remove(menu_func_export)
bpy.types.NODE_MT_node.remove(menu_func_export_nodes)
if __name__ == "__main__":
register()
# test call
bpy.ops.export_scene.blend('INVOKE_DEFAULT')