From 6c7f9e5493bc5a025f157b70d5cdde2b9376421c Mon Sep 17 00:00:00 2001 From: raccoon Date: Mon, 20 Jan 2025 04:06:20 +0500 Subject: [PATCH] Revert "Future-proof implementation" This reverts commit 5a270289f0126e84e5292dc52f5b56a4a5667e7b. --- .../avatar-example/mesh/blend~/fbx_export.py | 41 ++++++------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/Assets/avatar-example/mesh/blend~/fbx_export.py b/Assets/avatar-example/mesh/blend~/fbx_export.py index ffef397..d6fcd5a 100644 --- a/Assets/avatar-example/mesh/blend~/fbx_export.py +++ b/Assets/avatar-example/mesh/blend~/fbx_export.py @@ -2,13 +2,10 @@ import os from datetime import datetime import bpy -FUTURE = bpy.app.version >= (2, 80, 0) -from bpy.props import EnumProperty, StringProperty, BoolProperty, PointerProperty, IntProperty +from bpy.props import StringProperty, BoolProperty, PointerProperty, IntProperty from bpy.types import UIList, Operator, Panel, PropertyGroup, Context -if FUTURE: - from bpy.types import Collection as Group -else: - from bpy.types import Group + +from io_scene_fbx import ExportFBX 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): col = self.layout.column(align=True) 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) @@ -42,8 +39,7 @@ def fbx_export(context: Context) -> None: 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 groups if g.fbx_exportable]: + for group in [g for g in bpy.data.groups if g.fbx_exportable]: filepath = os.path.join(rootpath, name_as_path(group.name)) basepath = os.path.dirname(filepath) @@ -97,20 +93,7 @@ class FBXExportProps(PropertyGroup): description="Export FBX on Blender file save", default=False ) - object_types = EnumProperty( - 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'}, - ) + object_types = ExportFBX.object_types group_index = IntProperty(default=0) @@ -150,17 +133,17 @@ class SCENE_PT_fbx_autoexport(Panel): col = layout.column() 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") col.separator() split = col.split() sub = split.column() - sub.label(text="Filter groups:") - sub.template_list("FBX_UL_ExportItems", "", bpy.data, "collections" if FUTURE else "groups", scene.fbx_export, "group_index", rows=5) + sub.label("Filter groups:") + sub.template_list("FBX_UL_ExportItems", "", bpy.data, "groups", scene.fbx_export, "group_index", rows=5) sub = split.column() - sub.label(text="Filter object types:") + sub.label("Filter object types:") sub.prop(scene.fbx_export, "object_types") col.separator() @@ -193,7 +176,7 @@ def register() -> None: for cls in classes: bpy.utils.register_class(cls) bpy.types.Scene.fbx_export = PointerProperty(type=FBXExportProps) - Group.fbx_exportable = BoolProperty( + bpy.types.Group.fbx_exportable = BoolProperty( name="Export Group", description="Mark group as FBX exportable", default=False @@ -203,7 +186,7 @@ def register() -> None: def unregister() -> None: bpy.app.handlers.save_pre.remove(on_save) - del Group.fbx_exportable + del bpy.types.Group.fbx_exportable del bpy.types.Scene.fbx_export for cls in reversed(classes): bpy.utils.unregister_class(cls)