Revert "Future-proof implementation"

This reverts commit 5a270289f0.
This commit is contained in:
raccoon
2025-01-20 04:06:20 +05:00
parent 5a270289f0
commit 6c7f9e5493

View File

@@ -2,13 +2,10 @@ import os
from datetime import datetime from datetime import datetime
import bpy import bpy
FUTURE = bpy.app.version >= (2, 80, 0) from bpy.props import StringProperty, BoolProperty, PointerProperty, IntProperty
from bpy.props import EnumProperty, StringProperty, BoolProperty, PointerProperty, IntProperty
from bpy.types import UIList, Operator, Panel, PropertyGroup, Context from bpy.types import UIList, Operator, Panel, PropertyGroup, Context
if FUTURE:
from bpy.types import Collection as Group from io_scene_fbx import ExportFBX
else:
from bpy.types import Group
def message_box(message: str, title: str = "Message", icon: str = 'INFO') -> None: def message_box(message: str, title: str = "Message", icon: str = 'INFO') -> None:
@@ -21,7 +18,7 @@ def message_box(message: str, title: str = "Message", icon: str = 'INFO') -> Non
def draw(self, context): def draw(self, context):
col = self.layout.column(align=True) col = self.layout.column(align=True)
for line in message.strip().split("\n"): for line in message.strip().split("\n"):
col.label(text=line) col.label(line)
bpy.context.window_manager.popup_menu(draw, title=title, icon=icon) bpy.context.window_manager.popup_menu(draw, title=title, icon=icon)
@@ -42,8 +39,7 @@ def fbx_export(context: Context) -> None:
rootpath = os.path.normpath(bpy.path.abspath(context.scene.fbx_export.export_dir)) rootpath = os.path.normpath(bpy.path.abspath(context.scene.fbx_export.export_dir))
groups = bpy.data.collections if FUTURE else bpy.data.groups for group in [g for g in bpy.data.groups if g.fbx_exportable]:
for group in [g for g in groups if g.fbx_exportable]:
filepath = os.path.join(rootpath, name_as_path(group.name)) filepath = os.path.join(rootpath, name_as_path(group.name))
basepath = os.path.dirname(filepath) basepath = os.path.dirname(filepath)
@@ -97,20 +93,7 @@ class FBXExportProps(PropertyGroup):
description="Export FBX on Blender file save", description="Export FBX on Blender file save",
default=False default=False
) )
object_types = EnumProperty( object_types = ExportFBX.object_types
name="Object Types",
options={'ENUM_FLAG'},
items=(
('EMPTY', "Empty", ""),
('CAMERA', "Camera", ""),
('LAMP', "Lamp", ""),
('ARMATURE', "Armature", "WARNING: not supported in dupli/group instances"),
('MESH', "Mesh", ""),
('OTHER', "Other", "Other geometry types, like curve, metaball, etc. (converted to meshes)"),
),
description="Which kind of object to export",
default={'EMPTY', 'CAMERA', 'LAMP', 'ARMATURE', 'MESH', 'OTHER'},
)
group_index = IntProperty(default=0) group_index = IntProperty(default=0)
@@ -150,17 +133,17 @@ class SCENE_PT_fbx_autoexport(Panel):
col = layout.column() col = layout.column()
sub = col.column(align=True) sub = col.column(align=True)
sub.prop(scene.fbx_export, "on_save", icon='FILE_REFRESH') sub.prop(scene.fbx_export, "on_save", icon='LOAD_FACTORY')
sub.operator(FBX_OT_ManualExport.bl_idname, icon="PASTEDOWN") sub.operator(FBX_OT_ManualExport.bl_idname, icon="PASTEDOWN")
col.separator() col.separator()
split = col.split() split = col.split()
sub = split.column() sub = split.column()
sub.label(text="Filter groups:") sub.label("Filter groups:")
sub.template_list("FBX_UL_ExportItems", "", bpy.data, "collections" if FUTURE else "groups", scene.fbx_export, "group_index", rows=5) sub.template_list("FBX_UL_ExportItems", "", bpy.data, "groups", scene.fbx_export, "group_index", rows=5)
sub = split.column() sub = split.column()
sub.label(text="Filter object types:") sub.label("Filter object types:")
sub.prop(scene.fbx_export, "object_types") sub.prop(scene.fbx_export, "object_types")
col.separator() col.separator()
@@ -193,7 +176,7 @@ def register() -> None:
for cls in classes: for cls in classes:
bpy.utils.register_class(cls) bpy.utils.register_class(cls)
bpy.types.Scene.fbx_export = PointerProperty(type=FBXExportProps) bpy.types.Scene.fbx_export = PointerProperty(type=FBXExportProps)
Group.fbx_exportable = BoolProperty( bpy.types.Group.fbx_exportable = BoolProperty(
name="Export Group", name="Export Group",
description="Mark group as FBX exportable", description="Mark group as FBX exportable",
default=False default=False
@@ -203,7 +186,7 @@ def register() -> None:
def unregister() -> None: def unregister() -> None:
bpy.app.handlers.save_pre.remove(on_save) bpy.app.handlers.save_pre.remove(on_save)
del Group.fbx_exportable del bpy.types.Group.fbx_exportable
del bpy.types.Scene.fbx_export del bpy.types.Scene.fbx_export
for cls in reversed(classes): for cls in reversed(classes):
bpy.utils.unregister_class(cls) bpy.utils.unregister_class(cls)