Skip to content

Commit

Permalink
Merge pull request #110 from mika-f/releases/v3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mika-f authored Aug 10, 2024
2 parents 50fd72f + c3a1d1d commit b967f31
Show file tree
Hide file tree
Showing 20 changed files with 457 additions and 343 deletions.
24 changes: 24 additions & 0 deletions src/addon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,40 @@
# pyright: reportUnboundVariable=false
# pyright: reportUnknownArgumentType=false

bl_info = {
"name": "Drag and Drop Support",
"author": "Natsuneko",
"description": "Blender add-on for import some files from drag-and-drop",
"blender": (3, 1, 0),
"version": (3, 2, 0),
"location": "Drag and Drop Support",
"doc_url": "https://docs.natsuneko.com/en-us/drag-and-drop-support/",
"tracker_url": "https://github.com/mika-f/blender-drag-and-drop/issues",
"category": "Import-Export",
}


if "bpy" in locals():
import importlib

importlib.reload(formats)
importlib.reload(interop)
importlib.reload(operator)
importlib.reload(preferences)
else:
from . import formats
from . import interop
from . import operator
from . import preferences

import bpy # nopep8


classes: list[type] = []

if not interop.has_official_api():
classes.append(preferences.DragAndDropPreferences)

classes.extend(operator.get_operators())
classes.extend(formats.CLASSES)

Expand All @@ -31,6 +51,8 @@ def register():
for c in classes:
bpy.utils.register_class(c)

interop.try_load()


def unregister():
global classes
Expand All @@ -42,6 +64,8 @@ def unregister():
except:
pass

interop.try_unload()


if __name__ == "__main__":
register()
73 changes: 0 additions & 73 deletions src/addon/blender_manifest.toml

This file was deleted.

31 changes: 17 additions & 14 deletions src/addon/formats/_3mf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
ImportsWithCustomSettingsBase,
VIEW3D_MT_Space_Import_BASE,
)
from ..interop import has_official_api


class Import3MFWithDefaults(ImportWithDefaultsBase):
Expand Down Expand Up @@ -61,22 +62,24 @@ def format():
return "3mf"


class VIEW3D_FH_Import_3MF(bpy.types.FileHandler):
bl_idname = "VIEW3D_FH_Import_3MF"
bl_label = "Import 3D Manufacturing Format File"
bl_import_operator = "object.drop_event_listener"
bl_file_extensions = ".3mf"

@classmethod
def poll_drop(cls, context: bpy.types.Context | None) -> bool:
if context is None:
return False
return context and context.area and context.area.type == "VIEW_3D"


OPERATORS: list[type] = [
Import3MFWithDefaults,
Import3MFWithCustomSettings,
VIEW3D_MT_Space_Import_3MF,
VIEW3D_FH_Import_3MF,
]

if has_official_api():

class VIEW3D_FH_Import_3MF(bpy.types.FileHandler):
bl_idname = "VIEW3D_FH_Import_3MF"
bl_label = "Import 3D Manufacturing Format File"
bl_import_operator = "object.drop_event_listener"
bl_file_extensions = ".3mf"

@classmethod
def poll_drop(cls, context: bpy.types.Context | None) -> bool:
if context is None:
return False
return context and context.area and context.area.type == "VIEW_3D"

OPERATORS.append(VIEW3D_FH_Import_3MF)
31 changes: 17 additions & 14 deletions src/addon/formats/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
ImportsWithCustomSettingsBase,
VIEW3D_MT_Space_Import_BASE,
)
from ..interop import has_official_api


class ImportABCWithDefaults(ImportWithDefaultsBase):
Expand Down Expand Up @@ -87,22 +88,24 @@ def format():
return "abc"


class VIEW3D_FH_Import_ABC(bpy.types.FileHandler):
bl_idname = "VIEW3D_FH_Import_ABC"
bl_label = "Import ABC File"
bl_import_operator = "object.drop_event_listener"
bl_file_extensions = ".abc"

@classmethod
def poll_drop(cls, context: bpy.types.Context | None) -> bool:
if context is None:
return False
return context and context.area and context.area.type == "VIEW_3D"


OPERATORS: list[type] = [
ImportABCWithDefaults,
ImportABCWithCustomSettings,
VIEW3D_MT_Space_Import_ABC,
VIEW3D_FH_Import_ABC,
]

if has_official_api():

class VIEW3D_FH_Import_ABC(bpy.types.FileHandler):
bl_idname = "VIEW3D_FH_Import_ABC"
bl_label = "Import ABC File"
bl_import_operator = "object.drop_event_listener"
bl_file_extensions = ".abc"

@classmethod
def poll_drop(cls, context: bpy.types.Context | None) -> bool:
if context is None:
return False
return context and context.area and context.area.type == "VIEW_3D"

OPERATORS.append(VIEW3D_FH_Import_ABC)
31 changes: 17 additions & 14 deletions src/addon/formats/bvh.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
ImportsWithCustomSettingsBase,
VIEW3D_MT_Space_Import_BASE,
)
from ..interop import has_official_api


class ImportBVHWithDefaults(ImportWithDefaultsBase):
Expand Down Expand Up @@ -140,22 +141,24 @@ def format():
return "bvh"


class VIEW3D_FH_Import_BVH(bpy.types.FileHandler):
bl_idname = "VIEW3D_FH_Import_BVH"
bl_label = "Import Biovision Hierarchy File"
bl_import_operator = "object.drop_event_listener"
bl_file_extensions = ".bvh"

@classmethod
def poll_drop(cls, context: bpy.types.Context | None) -> bool:
if context is None:
return False
return context and context.area and context.area.type == "VIEW_3D"


OPERATORS: list[type] = [
ImportBVHWithDefaults,
ImportBVHWithCustomSettings,
VIEW3D_MT_Space_Import_BVH,
VIEW3D_FH_Import_BVH,
]

if has_official_api():

class VIEW3D_FH_Import_BVH(bpy.types.FileHandler):
bl_idname = "VIEW3D_FH_Import_BVH"
bl_label = "Import Biovision Hierarchy File"
bl_import_operator = "object.drop_event_listener"
bl_file_extensions = ".bvh"

@classmethod
def poll_drop(cls, context: bpy.types.Context | None) -> bool:
if context is None:
return False
return context and context.area and context.area.type == "VIEW_3D"

OPERATORS.append(VIEW3D_FH_Import_BVH)
32 changes: 18 additions & 14 deletions src/addon/formats/dae.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
ImportsWithCustomSettingsBase,
VIEW3D_MT_Space_Import_BASE,
)
from ..interop import has_official_api


class ImportDAEWithDefaults(ImportWithDefaultsBase):
Expand Down Expand Up @@ -90,22 +91,25 @@ def format():
return "dae"


class VIEW3D_FH_Import_DAE(bpy.types.FileHandler):
bl_idname = "VIEW3D_FH_Import_DAE"
bl_label = "Import Collada File"
bl_import_operator = "object.drop_event_listener"
bl_file_extensions = ".dae"

@classmethod
def poll_drop(cls, context: bpy.types.Context | None) -> bool:
if context is None:
return False
return context and context.area and context.area.type == "VIEW_3D"


OPERATORS: list[type] = [
ImportDAEWithDefaults,
ImportDAEWithCustomSettings,
VIEW3D_MT_Space_Import_DAE,
VIEW3D_FH_Import_DAE,
]


if has_official_api():

class VIEW3D_FH_Import_DAE(bpy.types.FileHandler):
bl_idname = "VIEW3D_FH_Import_DAE"
bl_label = "Import Collada File"
bl_import_operator = "object.drop_event_listener"
bl_file_extensions = ".dae"

@classmethod
def poll_drop(cls, context: bpy.types.Context | None) -> bool:
if context is None:
return False
return context and context.area and context.area.type == "VIEW_3D"

OPERATORS.append(VIEW3D_FH_Import_DAE)
31 changes: 17 additions & 14 deletions src/addon/formats/fbx.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
ImportsWithCustomSettingsBase,
VIEW3D_MT_Space_Import_BASE,
)
from ..interop import has_official_api


class ImportFBXWithDefaults(ImportWithDefaultsBase):
Expand Down Expand Up @@ -210,22 +211,24 @@ def format():
return "fbx"


class VIEW3D_FH_Import_FBX(bpy.types.FileHandler):
bl_idname = "VIEW3D_FH_Import_FBX"
bl_label = "Import FBX File"
bl_import_operator = "object.drop_event_listener"
bl_file_extensions = ".fbx"

@classmethod
def poll_drop(cls, context: bpy.types.Context | None) -> bool:
if context is None:
return False
return context and context.area and context.area.type == "VIEW_3D"


OPERATORS: list[type] = [
ImportFBXWithDefaults,
ImportFBXWithCustomSettings,
VIEW3D_MT_Space_Import_FBX,
VIEW3D_FH_Import_FBX,
]

if has_official_api():

class VIEW3D_FH_Import_FBX(bpy.types.FileHandler):
bl_idname = "VIEW3D_FH_Import_FBX"
bl_label = "Import FBX File"
bl_import_operator = "object.drop_event_listener"
bl_file_extensions = ".fbx"

@classmethod
def poll_drop(cls, context: bpy.types.Context | None) -> bool:
if context is None:
return False
return context and context.area and context.area.type == "VIEW_3D"

OPERATORS.append(VIEW3D_FH_Import_FBX)
Loading

0 comments on commit b967f31

Please sign in to comment.