forked from Yesssssman/blender-json-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
executable file
·64 lines (51 loc) · 1.76 KB
/
__init__.py
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
bl_info = {
"name": "Minecraft Model Json Exporter",
"author": "Yesssssman, box",
"blender": (2, 80, 0),
"category": "Import-Export",
"location": "File > Import-Export",
"description": "Epic Fight Mod JSON exporter ported to Blender 2.8+",
}
import bpy
from bpy.props import *
from bpy_extras.io_utils import ExportHelper
class ExportToJson(bpy.types.Operator, ExportHelper):
"""Export to Json that is specially designed for Epic Fight"""
bl_idname = "export_mc.json"
bl_label = "Export to Json for Minecraft"
filename_ext = ".json"
filter_glob = StringProperty(default="*.json", options={"HIDDEN"})
bl_options = {'PRESET'}
@classmethod
def poll(cls, context):
return context.active_object is not None
export_anim : BoolProperty(
name="Export Animation",
description="Export animation data",
default=True,
)
export_mesh : BoolProperty(
name="Export Mesh",
description="Export mesh data",
default=False,
)
export_armature : BoolProperty(
name="Export Armature",
description="Export armature data",
default=False,
)
def execute(self, context):
if not self.filepath:
raise Exception("Filepath not set")
from . import export_mc_json
return export_mc_json.save(context, **self.as_keywords())
def menu_func(self, context):
self.layout.operator(ExportToJson.bl_idname, text="Animated Minecraft Model (.json)")
def register():
bpy.utils.register_class(ExportToJson)
bpy.types.TOPBAR_MT_file_export.append(menu_func)
def unregister():
bpy.utils.unregister_class(ExportToJson)
bpy.types.TOPBAR_MT_file_export.remove(menu_func)
if __name__ == "__main__":
register()