refactor(Blender): changed all imports to be relative, to be up to spec with Blender 4.2 extensions

This commit is contained in:
kaosat.dev 2024-08-09 12:22:49 +02:00
parent 362d6b214b
commit 33f2809682
23 changed files with 35 additions and 40 deletions

View File

@ -273,6 +273,7 @@ Blender side:
- [ ] auto reload registry if absent/possible - [ ] auto reload registry if absent/possible
- cannot be done from UI possibly polling with increasing timeout - cannot be done from UI possibly polling with increasing timeout
- bpy.ops.blenvy.components_registry_reload() - bpy.ops.blenvy.components_registry_reload()
- double check bpy.context.components_registry
- [x] filter out MaterialInfos from list of "fixable components" - [x] filter out MaterialInfos from list of "fixable components"

View File

@ -2,7 +2,7 @@ import os
import json import json
import pathlib import pathlib
import bpy import bpy
from blenvy.settings import generate_complete_settings_dict from ...settings import generate_complete_settings_dict
from io_scene_gltf2 import ExportGLTF2_Base from io_scene_gltf2 import ExportGLTF2_Base

View File

@ -1,6 +1,5 @@
from blenvy.blueprints.blueprint_helpers import find_blueprints_not_on_disk from ....blueprints.blueprint_helpers import find_blueprints_not_on_disk
def is_blueprint_always_export(blueprint): def is_blueprint_always_export(blueprint):
return blueprint.collection['always_export'] if 'always_export' in blueprint.collection else False return blueprint.collection['always_export'] if 'always_export' in blueprint.collection else False

View File

@ -3,8 +3,7 @@ import os
import bpy import bpy
import traceback import traceback
from blenvy.blueprints.blueprints_scan import blueprints_scan from ....blueprints.blueprint_helpers import inject_export_path_into_internal_blueprints
from blenvy.blueprints.blueprint_helpers import inject_export_path_into_internal_blueprints
from ..blueprints.get_blueprints_to_export import get_blueprints_to_export from ..blueprints.get_blueprints_to_export import get_blueprints_to_export
from ..levels.get_levels_to_export import get_levels_to_export from ..levels.get_levels_to_export import get_levels_to_export

View File

@ -1,7 +1,7 @@
import json import json
import bpy import bpy
from blenvy.core.object_makers import (make_empty) from ....core.object_makers import make_empty
from blenvy.add_ons.bevy_components.utils import is_component_valid_and_enabled from ...bevy_components.utils import is_component_valid_and_enabled
from ..constants import custom_properties_to_filter_out from ..constants import custom_properties_to_filter_out
from ..utils import remove_unwanted_custom_properties from ..utils import remove_unwanted_custom_properties

View File

@ -2,7 +2,7 @@ import json
import os import os
import bpy import bpy
from blenvy.settings import load_settings from ....settings import load_settings
def get_standard_exporter_settings(): def get_standard_exporter_settings():
standard_gltf_exporter_settings = load_settings(".blenvy_gltf_settings") standard_gltf_exporter_settings = load_settings(".blenvy_gltf_settings")

View File

@ -1,6 +1,6 @@
import bpy import bpy
from blenvy.core.helpers_collections import (set_active_collection) from ....core.helpers_collections import set_active_collection
from blenvy.core.object_makers import (make_empty) from ....core.object_makers import make_empty
from .duplicate_object import duplicate_object from .duplicate_object import duplicate_object
from .export_gltf import export_gltf from .export_gltf import export_gltf
from ..constants import custom_properties_to_filter_out from ..constants import custom_properties_to_filter_out

View File

@ -3,7 +3,7 @@ import bpy
from .project_diff import get_changes_per_scene from .project_diff import get_changes_per_scene
from .auto_export import auto_export from .auto_export import auto_export
from .settings_diff import get_setting_changes from .settings_diff import get_setting_changes
from blenvy.settings import load_settings, upsert_settings from ....settings import upsert_settings
# prepare export by gather the changes to the scenes & settings # prepare export by gather the changes to the scenes & settings
def prepare_and_export(): def prepare_and_export():

View File

@ -2,7 +2,7 @@ import json
import traceback import traceback
import bpy import bpy
from .serialize_project import serialize_project from .serialize_project import serialize_project
from blenvy.settings import load_settings, upsert_settings from ....settings import load_settings
def bubble_up_changes(object, changes_per_scene): def bubble_up_changes(object, changes_per_scene):
if object is not None and object.parent: if object is not None and object.parent:

View File

@ -1,6 +1,4 @@
import bpy from ....settings import are_settings_identical, load_settings, changed_settings
from blenvy.settings import are_settings_identical, load_settings, changed_settings
# which common settings changes should trigger a re-export # which common settings changes should trigger a re-export
parameter_names_whitelist_common = [ parameter_names_whitelist_common = [

View File

@ -1,5 +1,5 @@
import bpy import bpy
from blenvy.blueprints.blueprint_helpers import check_if_blueprint_on_disk from ....blueprints.blueprint_helpers import check_if_blueprint_on_disk
# IF collection_instances_combine_mode is not 'split' check for each scene if any object in changes_per_scene has an instance in the scene # IF collection_instances_combine_mode is not 'split' check for each scene if any object in changes_per_scene has an instance in the scene
def changed_object_in_scene(scene_name, changes_per_scene, blueprints_data, collection_instances_combine_mode): def changed_object_in_scene(scene_name, changes_per_scene, blueprints_data, collection_instances_combine_mode):

View File

@ -1,8 +1,7 @@
import os import os
import bpy import bpy
from ....core.helpers_collections import traverse_tree
from blenvy.core.helpers_collections import (traverse_tree) from ....core.object_makers import make_cube
from blenvy.core.object_makers import make_cube
from ..common.generate_temporary_scene_and_export import generate_temporary_scene_and_export from ..common.generate_temporary_scene_and_export import generate_temporary_scene_and_export
from ..common.export_gltf import (generate_gltf_export_settings) from ..common.export_gltf import (generate_gltf_export_settings)

View File

@ -1,6 +1,6 @@
import bpy import bpy
from blenvy.materials.materials_helpers import find_materials_not_on_disk from ....materials.materials_helpers import find_materials_not_on_disk
def get_materials_to_export(changes_per_material, changed_export_parameters, blueprints_data, settings): def get_materials_to_export(changes_per_material, changed_export_parameters, blueprints_data, settings):
export_gltf_extension = getattr(settings, "export_gltf_extension", ".glb") export_gltf_extension = getattr(settings, "export_gltf_extension", ".glb")

View File

@ -1,7 +1,7 @@
import bpy import bpy
from bpy_types import (PropertyGroup) from bpy_types import (PropertyGroup)
from bpy.props import (EnumProperty, PointerProperty, StringProperty, BoolProperty, CollectionProperty, IntProperty) from bpy.props import (EnumProperty, PointerProperty, StringProperty, BoolProperty, CollectionProperty, IntProperty)
from blenvy.settings import load_settings, upsert_settings, generate_complete_settings_dict from ...settings import load_settings, upsert_settings, generate_complete_settings_dict
# list of settings we do NOT want to save # list of settings we do NOT want to save
settings_black_list = ['settings_save_enabled', 'dry_run'] settings_black_list = ['settings_save_enabled', 'dry_run']

View File

@ -1,8 +1,8 @@
import posixpath import posixpath
import bpy import bpy
from pathlib import Path from pathlib import Path
from blenvy.assets.assets_scan import get_blueprint_asset_tree, get_level_scene_assets_tree2 from ...assets.assets_scan import get_blueprint_asset_tree, get_level_scene_assets_tree2
from blenvy.add_ons.bevy_components.utils import is_component_valid_and_enabled from ..bevy_components.utils import is_component_valid_and_enabled
from .constants import custom_properties_to_filter_out from .constants import custom_properties_to_filter_out
from ...assets.assets_scan import get_level_scene_assets_tree2 from ...assets.assets_scan import get_level_scene_assets_tree2

View File

@ -1,7 +1,7 @@
import json import json
from bpy_types import Operator from bpy_types import Operator
from bpy.props import (StringProperty, EnumProperty, IntProperty) from bpy.props import (StringProperty, EnumProperty, IntProperty)
from blenvy.add_ons.bevy_components.utils import get_item_by_type from ..utils import get_item_by_type
class BLENVY_OT_component_list_actions(Operator): class BLENVY_OT_component_list_actions(Operator):
"""Move items up and down, add and remove""" """Move items up and down, add and remove"""

View File

@ -3,7 +3,7 @@ from bpy_types import Operator, UIList
from bpy.props import (StringProperty, EnumProperty, PointerProperty, FloatVectorProperty, IntProperty) from bpy.props import (StringProperty, EnumProperty, PointerProperty, FloatVectorProperty, IntProperty)
from ..propGroups.conversions_from_prop_group import property_group_value_to_custom_property_value from ..propGroups.conversions_from_prop_group import property_group_value_to_custom_property_value
from blenvy.add_ons.bevy_components.utils import get_item_by_type from ..utils import get_item_by_type
class BLENVY_OT_component_map_actions(Operator): class BLENVY_OT_component_map_actions(Operator):
"""Move items up and down, add and remove""" """Move items up and down, add and remove"""

View File

@ -3,8 +3,7 @@ import bpy
from bpy_types import (Operator) from bpy_types import (Operator)
from bpy.props import (StringProperty) from bpy.props import (StringProperty)
from bpy_extras.io_utils import ImportHelper from bpy_extras.io_utils import ImportHelper
from ....settings import upsert_settings
from blenvy.settings import upsert_settings
from ..components.metadata import ensure_metadata_for_all_items from ..components.metadata import ensure_metadata_for_all_items
from ..propGroups.prop_groups import generate_propertyGroups_for_components from ..propGroups.prop_groups import generate_propertyGroups_for_components

View File

@ -2,7 +2,8 @@ import os
import bpy import bpy
from bpy_types import (PropertyGroup) from bpy_types import (PropertyGroup)
from bpy.props import (EnumProperty, PointerProperty, StringProperty, BoolProperty, CollectionProperty, FloatProperty) from bpy.props import (EnumProperty, PointerProperty, StringProperty, BoolProperty, CollectionProperty, FloatProperty)
from blenvy.settings import load_settings, upsert_settings, generate_complete_settings_dict from ...settings import load_settings, upsert_settings, generate_complete_settings_dict
from .propGroups.prop_groups import generate_propertyGroups_for_components from .propGroups.prop_groups import generate_propertyGroups_for_components
from .components.metadata import ensure_metadata_for_all_items from .components.metadata import ensure_metadata_for_all_items
from .utils import add_component_to_ui_list from .utils import add_component_to_ui_list

View File

@ -1,10 +1,9 @@
import json
import bpy import bpy
from .constants import HIDDEN_COMPONENTS
from bpy.props import StringProperty, EnumProperty from bpy.props import StringProperty, EnumProperty
from bpy_types import Operator from bpy_types import Operator
from blenvy.core.helpers_collections import (set_active_collection) from ...core.helpers_collections import set_active_collection
from .constants import HIDDEN_COMPONENTS
import json
def select_area(context, area_name): def select_area(context, area_name):
for area in context.screen.areas: for area in context.screen.areas:

View File

@ -2,7 +2,7 @@ import os
import bpy import bpy
from bpy_types import (Operator) from bpy_types import (Operator)
from bpy.props import (StringProperty) from bpy.props import (StringProperty)
from blenvy.core.helpers_collections import set_active_collection from ..core.helpers_collections import set_active_collection
class BLENVY_OT_blueprint_select(Operator): class BLENVY_OT_blueprint_select(Operator):
"""Select blueprint """ """Select blueprint """

View File

@ -3,9 +3,8 @@ import bpy
from bpy_types import (PropertyGroup) from bpy_types import (PropertyGroup)
from bpy.props import (BoolProperty, EnumProperty, PointerProperty, StringProperty, CollectionProperty, IntProperty) from bpy.props import (BoolProperty, EnumProperty, PointerProperty, StringProperty, CollectionProperty, IntProperty)
from ..settings import upsert_settings, load_settings, generate_complete_settings_dict from ..settings import upsert_settings, load_settings, generate_complete_settings_dict
import blenvy.add_ons.auto_export.settings as auto_export_settings from ..add_ons.auto_export.settings import AutoExportSettings
import blenvy.add_ons.bevy_components.settings as component_settings from ..add_ons.bevy_components.settings import ComponentsSettings
# list of settings we do NOT want to save # list of settings we do NOT want to save
settings_black_list = ['settings_save_enabled', 'level_scene_selector', 'library_scene_selector'] settings_black_list = ['settings_save_enabled', 'level_scene_selector', 'library_scene_selector']
@ -127,8 +126,8 @@ class BlenvyManager(PropertyGroup):
) # type: ignore ) # type: ignore
# sub ones # sub ones
auto_export: PointerProperty(type=auto_export_settings.AutoExportSettings) # type: ignore auto_export: PointerProperty(type=AutoExportSettings) # type: ignore
components: PointerProperty(type=component_settings.ComponentsSettings) # type: ignore components: PointerProperty(type=ComponentsSettings) # type: ignore
level_scene_selector: PointerProperty(type=bpy.types.Scene, name="level scene", description="level scene picker", poll=is_scene_already_in_use, update=save_settings)# type: ignore level_scene_selector: PointerProperty(type=bpy.types.Scene, name="level scene", description="level scene picker", poll=is_scene_already_in_use, update=save_settings)# type: ignore
library_scene_selector: PointerProperty(type=bpy.types.Scene, name="library scene", description="library scene picker", poll=is_scene_already_in_use, update=save_settings)# type: ignore library_scene_selector: PointerProperty(type=bpy.types.Scene, name="library scene", description="library scene picker", poll=is_scene_already_in_use, update=save_settings)# type: ignore

View File

@ -1,7 +1,8 @@
import bpy import bpy
import blenvy.add_ons.bevy_components.ui as components_ui
import blenvy.add_ons.auto_export.ui as auto_export_ui
# from ...bevy_components.components import ui# as components_ui # from ...bevy_components.components import ui# as components_ui
from ...add_ons.bevy_components import ui as components_ui
from ...add_ons.auto_export import ui as auto_export_ui
###################################################### ######################################################
## ui logic & co ## ui logic & co