This add-on allows you to export content created with Blender to Unreal Engine, including:
Release Logs: https://github.com/xavier150/Blender-For-UnrealEngine-Addons/wiki/Release-Logs
This extension requests the following permissions:
Import/export FBX from/to disk
Copy generated script paths
This extension manipulates sys.path
in bfu_import_module/asset_import_script.py
.
Adding directories to the sys.path
is against the policy for extensions.blender.org
because future imports may load different modules afterwards.
Suggest to use importlib
to load the module and run it's main()
function, Blender's bpy.utils.execfile(..)
does something similar.
See: https://developer.blender.org/docs/handbook/addons/guidelines/
Hello Campbell, Thanks for the review and suggestions!
I updated, now asset_import_script and sequencer_import_script will import and call run_unreal_import_script.py using arguments.
run_unreal_import_script.py will import the module and process the import in Unreal Engine without manipulate sys.path.
I have a problem now, I have set the page in draft, but I don't know where I can put the new addon file.
Checking again:
sys.argv
is set and not restored, this may break functionality elsewhere that checks sys.argv
.linux-arm
for example. platforms = ...
should be removed from the blender_manifest.toml
unless you're bundling DLL's or similar.assimp team
, Blender Foundation
, Bastien Montagne
... (not a full list).
paths_exclude_pattern
in the blender_manifest.toml
so the build commnad excludes fbxio/io_scene_fbx_2_83/
, fbxio/io_scene_fbx_2_93/
, fbxio/io_scene_fbx_3_1/
, fbxio/io_scene_fbx_3_2/
etc.Thanks!
About the fbxio is because I use a generated modified versions of the native fbxio.
Both versions use only the necessary content.
Sorry I did not understand with the copyright, I thought the problem was the "all right reserved".
I will add "Blender Foundation" and the copyright from the io_scene_fbx. This is correct ?
copyright = [ "2024 Xavier Loux", "2013 Blender Foundation", "2006-2012 assimp team" "2013 Campbell Barton" "2014 Bastien Montagne" ]
Hello Campbell,
Thanks for your help! I have another question: am I allowed to manipulate sys.modules?
I'm facing a new problem: the file run_unreal_import_script.py is run by Unreal Engine to import the exported assets. In this file, I now use importlib.util to import the module bfu_import_module, but it doesn't import the sub-modules inside bfu_import_module.
So when I use "from . import" in bfu_import_module.init.py, I get the error "No module named 'bfu_import_module'".
I was able to fix this by using sys.modules[module_name] = module just before spec.loader.exec_module(module).
Here the part of my code
`def import_unreal_module(): # Get the script directory script_dir = os.path.dirname(os.path.abspath(file)) module_name = "bfu_import_module" module_file = os.path.join(script_dir, module_name, "init.py")
# Load the module dynamically
spec = importlib.util.spec_from_file_location(module_name, module_file)
module = importlib.util.module_from_spec(spec)
sys.modules[module_name] = module
spec.loader.exec_module(module)
return module
def clear_unreal_module(): module_name = "bfu_import_module" del sys.modules[module_name]
def run_from_asset_import_script(import_data_filepath): module = import_unreal_module() try: module.run_asset_import(json_load_file(import_data_filepath)) except Exception as e: print(f"An error has occurred: {e}") clear_unreal_module()`
Regarding manipulating of sys.modules
- I'd really rather not because it breaks name-spacing.
But this is only the case for for Blender's instance of Python.
It looks as if run_unreal_import_script.py
doesn't run in Blender's Python instance. In that case rules to prevent extensions interfering with each other don't apply.
However importing some modules...
Running some code-quality checks:
This add-on seems to use names in literal quotes without being escaped. Names may themselves contain quotes or other characters that need to be escaped.
For example:
data_path = 'objects["{:s}"]'.format(object.name)
is incorrect because object.name
may contain a "
character.
To resolve:
repr(...)
or the !r
conversion flag for f-strings or str.format
.bpy.utils.escape_identifier(..)
.Ref: bone names and driver name assignments to data_path.
Sign in to comment.
Ready for review