Skip to content

Commit

Permalink
Merge pull request #37 from mika-f/feature/major-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
mika-f authored Dec 9, 2023
2 parents 316810f + d8f4e22 commit 39aefdc
Show file tree
Hide file tree
Showing 62 changed files with 2,170 additions and 637 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ body:
- 2.11.0
- 2.12.0
- 2.12.1
- 3.0.0-alpha.1
validations:
required: true
- type: dropdown
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ jobs:

- name: Build Injector for Release
run: |
msbuild -p:Configuration=Release -p:Platform=x64 -t:Rebuild src/blender-injection/blender-injection.vcxproj
msbuild -p:Configuration=Release -p:Platform=x64 -t:Rebuild src/dll/blender-injection.vcxproj
- name: Build Extension for Release
shell: powershell
run: |
New-Item .\bin -Type Directory
Copy-Item -Recurse .\src\blender-extension\ .\bin\drag-and-drop-support\
Copy-Item -Recurse .\src\addon\ .\bin\drag-and-drop-support\
- name: Collect Artifacts
shell: powershell
Expand All @@ -44,8 +44,8 @@ jobs:
$Dest = "$Archive\drag-and-drop-support"
New-Item $Dest -Type Directory
Copy-Item .\src\blender-injection\x64\Release\*.dll $Dest\
Copy-Item .\src\blender-extension\* $Dest\
Copy-Item .\src\dll\x64\Release\*.dll $Dest\
Copy-Item .\src\addon\* $Dest\
Copy-Item .\src\LICENSE.txt $Archive\
Compress-Archive "$Dest" "$Dest.zip"
Expand Down
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
"editor.formatOnSave": true,
"black-formatter.args": ["--line-length=120"],
"python.formatting.provider": "black"
}
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,32 @@

Blender add-on for importing some files from drag-and-drop.

## Supports
## Supported Formats

- `*.abc`
- `*.bvh`
- `*.dae`
- `*.fbx`
- `*.glb`
- `*.gltf`
- `*.obj`
- `*.ply`
- `*.stl`
- `*.svg`
- `*.usd`
- `*.usda`
- `*.usdc`
- `*.vrm` (Required [VRM Add-on for Blender](https://github.com/saturday06/VRM-Addon-for-Blender))
- `*.x3d`
- `*.wrl`

## Planned

- `*.mqo` (Required [Metasequoia File Importer/Exporter](https://github.com/nutti/blender-mqo))
- Add file format and add-on pair you want to supported!
- or PR for additional features is also welcome!

## Supported Blenders

v2.0.0 supports the following versions of Blender:

Expand All @@ -28,6 +53,8 @@ v2.0.0 supports the following versions of Blender:
- Blender 3.6.5 (x64 - Windows)
- Blender 4.0.0 (x64 - Windows)

## ScreenShot

## Installation

1. Download Installation Archive from [GitHub Releases](https://github.com/mika-f/blender-drag-and-drop/releases/latest)
Expand All @@ -39,7 +66,6 @@ v2.0.0 supports the following versions of Blender:
## How to use

1. Drag and Drop some file to 3D view, load it
1. if you want to configure import, please use `Drag and Drop Support` tab in 3D view.

## Known Issues

Expand Down
6 changes: 3 additions & 3 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ echo ***************************************************************************
echo Build blender-injection for %2 (%ARCH%)
echo ******************************************************************************************************

"%MSBUILD%" /p:Configuration=%2 /p:Platform=%1 /t:Rebuild src/blender-injection/blender-injection.vcxproj
"%MSBUILD%" /p:Configuration=%2 /p:Platform=%1 /t:Rebuild src/dll/blender-injection.vcxproj


echo ******************************************************************************************************
Expand All @@ -91,8 +91,8 @@ set DEST="bin\%1\DragAndDropSupport-v%VERSION%"
echo Y | rmdir /s "%DEST%"
mkdir "%DEST%"

echo F | xcopy /s "src\blender-injection\%1\"%2"\*.dll" "%DEST%\drag-and-drop-support\"
echo F | xcopy /s "src\blender-extension\*" "%DEST%\drag-and-drop-support\"
echo F | xcopy /s "src\dll\%1\"%2"\*.dll" "%DEST%\drag-and-drop-support\"
echo F | xcopy /s "src\addon\*" "%DEST%\drag-and-drop-support\"
echo F | xcopy "src\LICENSE.txt" "%DEST%\"

pwsh -Command compress-archive "%DEST%\drag-and-drop-support" "%DEST%\drag-and-drop-support.zip"
Expand Down
2 changes: 1 addition & 1 deletion src/Blender.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32414.318
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blender-injection", "blender-injection\blender-injection.vcxproj", "{FB47F8C7-76DB-49C6-B9FF-B22D9D0B89F5}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blender-injection-dll", "dll\blender-injection.vcxproj", "{FB47F8C7-76DB-49C6-B9FF-B22D9D0B89F5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
64 changes: 64 additions & 0 deletions src/addon/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# ------------------------------------------------------------------------------------------
# Copyright (c) Natsuneko. All rights reserved.
# Licensed under the MIT License. See LICENSE in the project root for license information.
# ------------------------------------------------------------------------------------------

# 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": (2, 13, 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] = [operator.DropEventListener, preferences.DragAndDropPreferences]

classes.extend(formats.CLASSES)


def register():
global classes

# register classes
for c in classes:
bpy.utils.register_class(c)

interop.try_load()


def unregister():
global classes

# unregister classes
for c in classes:
bpy.utils.unregister_class(c) # pyright: ignore[reportUnknownMemberType]

interop.try_unload()


if __name__ == "__main__":
register()
41 changes: 41 additions & 0 deletions src/addon/formats/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# ------------------------------------------------------------------------------------------
# Copyright (c) Natsuneko. All rights reserved.
# Licensed under the MIT License. See LICENSE in the project root for license information.
# ------------------------------------------------------------------------------------------

# pyright: reportUnusedImport=false

from . import abc
from . import bvh
from . import dae
from . import fbx
from . import glb
from . import obj
from . import obj_legacy
from . import ply
from . import stl
from . import stl_legacy
from . import svg
from . import usd
from . import vrm
from . import x3d

CLASSES: list[type] = []

# legacy importers
CLASSES.extend(obj_legacy.OPERATORS)
CLASSES.extend(stl_legacy.OPERATORS)

# modern importers
CLASSES.extend(abc.OPERATORS)
CLASSES.extend(bvh.OPERATORS)
CLASSES.extend(dae.OPERATORS)
CLASSES.extend(fbx.OPERATORS)
CLASSES.extend(glb.OPERATORS)
CLASSES.extend(obj.OPERATORS)
CLASSES.extend(ply.OPERATORS)
CLASSES.extend(stl.OPERATORS)
CLASSES.extend(svg.OPERATORS)
CLASSES.extend(usd.OPERATORS)
CLASSES.extend(vrm.OPERATORS)
CLASSES.extend(x3d.OPERATORS)
92 changes: 92 additions & 0 deletions src/addon/formats/abc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# ------------------------------------------------------------------------------------------
# Copyright (c) Natsuneko. All rights reserved.
# Licensed under the MIT License. See LICENSE in the project root for license information.
# ------------------------------------------------------------------------------------------

# pyright: reportGeneralTypeIssues=false
# pyright: reportUnknownArgumentType=false
# pyright: reportUnknownMemberType=false

from typing import Set
import bpy

from bpy.props import (
BoolProperty, # pyright: ignore[reportUnknownVariableType]
FloatProperty, # pyright: ignore[reportUnknownVariableType]
)
from bpy.types import Context

from .super import (
ImportWithDefaultsBase,
ImportsWithCustomSettingsBase,
VIEW3D_MT_Space_Import_BASE,
)


class ImportABCWithDefaults(ImportWithDefaultsBase):
bl_idname = "object.import_abc_with_defaults"
bl_label = "Import ABC File"

def execute(self, context: Context) -> Set[str] | Set[int]:
bpy.ops.wm.alembic_import(filepath=self.filepath())
return {"FINISHED"}


class ImportABCWithCustomSettings(ImportsWithCustomSettingsBase):
bl_idname = "object.import_abc_with_custom_settings"
bl_label = "Import ABC File"

# Properties based on Blender v4.0.0 (ordered by parameters on documents)
relative_path: BoolProperty(default=True, name="Relative Path")
scale: FloatProperty(default=1.0, min=0.0001, max=1000, name="Scale")
set_frame_range: BoolProperty(default=True, name="Set Frame Range")
validate_meshes: BoolProperty(default=False, name="Validate Meshes")
always_add_cache_reader: BoolProperty(default=False, name="Always Add Cache Reader")
is_sequence: BoolProperty(default=False, name="Is Sequence")

manual_transform_section: BoolProperty(default=True, name="Manual Transform")
options_section: BoolProperty(default=True, name="Option")

def draw(self, context: Context):
# Manual Transform Section
column, state = self.get_expand_column("manual_transform_section")

if state:
column.prop(self, "scale")

# Options Section
column, state = self.get_expand_column("options_section")

if state:
column.prop(self, "relative_path")
column.prop(self, "set_frame_range")
column.prop(self, "is_sequence")
column.prop(self, "validate_meshes")
column.prop(self, "always_add_cache_reader")

def execute(self, context: Context) -> Set[str] | Set[int]:
bpy.ops.wm.alembic_import(
filepath=self.filepath(),
relative_path=self.relative_path,
scale=self.scale,
set_frame_range=self.set_frame_range,
validate_meshes=self.validate_meshes,
always_add_cache_reader=self.always_add_cache_reader,
is_sequence=self.is_sequence,
)

return {"FINISHED"}


class VIEW3D_MT_Space_Import_ABC(VIEW3D_MT_Space_Import_BASE):
bl_label = "Import ABC File"

def format(self):
return "abc"


OPERATORS = [
ImportABCWithDefaults,
ImportABCWithCustomSettings,
VIEW3D_MT_Space_Import_ABC,
]
Loading

0 comments on commit 39aefdc

Please sign in to comment.