Skip to content

Commit

Permalink
Merge branch 'Dev' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
xavier150 committed Nov 20, 2024
2 parents acd0f22 + 989892c commit a9f1f48
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 20 deletions.
14 changes: 9 additions & 5 deletions blender-for-unrealengine/fbxio/generator/edit_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ def add_header_to_file(file_path):
"# --------------------------------------------- \n"
"\n"
)
with open(file_path, 'r+', encoding='utf-8') as f:
content = f.read()
f.seek(0, 0)
f.write(header + content)
##print(f"Added header to {file_path}")

try:
with open(file_path, 'r') as file:
original_content = file.read()
except FileNotFoundError:
original_content = "" # Si le fichier n'existe pas, le contenu sera vide

with open(file_path, 'w') as file:
file.write(header + original_content)

def lines_exist(file_path, search_string):
with open(file_path, 'r+', encoding='utf-8') as f:
Expand Down
39 changes: 24 additions & 15 deletions blender-for-unrealengine/fbxio/generator/generator.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import os
import platform
import shutil
import re
from . import edit_files
from . import edit_fbx_utils
from . import edit_export_fbx_bin

blender_install_folder = "C:\\Program Files\\Blender Foundation"
# Detect the current operating system
current_system = platform.system()
if current_system == "Windows":
blender_install_folder = r"U:\\BlenderBuilds"
elif current_system == "Linux":
blender_install_folder = r"/media/bleuraven/Game Engines/BlenderBuilds"


io_scene_fbx_prefix = "io_scene_fbx_"

export_fbx_files = [
Expand Down Expand Up @@ -64,7 +72,7 @@ def __init__(self, version, folder, files, new_io_fbx = None):
if new_io_fbx:
self.io_fbx = new_io_fbx
else:
self.io_fbx = "scripts\\addons\\io_scene_fbx"
self.io_fbx = r"scripts/addons/io_scene_fbx"

def get_str_version(self):
return str(self.version[0])+"_"+str(self.version[1])
Expand All @@ -73,7 +81,8 @@ def get_folder_str_version(self):
return str(self.version[0])+"."+str(self.version[1])

def get_addon_folder(self):
return os.path.join(blender_install_folder, self.folder, self.get_folder_str_version(), self.io_fbx)
addon_path = os.path.join(blender_install_folder, self.folder, self.io_fbx)
return os.path.abspath(addon_path)

def run_generate(self):
# Create the destination folder in the parent directory
Expand Down Expand Up @@ -172,40 +181,40 @@ def run_all_generate():
# generated var needs to be ordered from new to older.
generated = []

generate_4_3 = FBXExporterGenerate((4, 3, 0), "Blender 4.3", export_fbx_files_with_threading, "scripts\\addons_core\\io_scene_fbx")
generate_4_3 = FBXExporterGenerate((4, 3, 0), r"Blender_v4.3", export_fbx_files_with_threading, r"scripts/addons_core/io_scene_fbx/")
generated.append(generate_4_3.run_generate())

generate_4_2 = FBXExporterGenerate((4, 2, 0), "Blender 4.2", export_fbx_files_with_threading, "scripts\\addons_core\\io_scene_fbx")
generate_4_2 = FBXExporterGenerate((4, 2, 0), r"Blender_v4.2", export_fbx_files_with_threading, r"scripts/addons_core/io_scene_fbx/")
generated.append(generate_4_2.run_generate())

generate_4_1 = FBXExporterGenerate((4, 1, 0), "Blender 4.1", export_fbx_files_with_threading)
generate_4_1 = FBXExporterGenerate((4, 1, 0), r"Blender 4.1/4.1", export_fbx_files_with_threading)
generated.append(generate_4_1.run_generate())

generate_4_0 = FBXExporterGenerate((4, 0, 0), "Blender 4.0", export_fbx_files)
generate_4_0 = FBXExporterGenerate((4, 0, 0), r"Blender 4.0/4.0", export_fbx_files)
generated.append(generate_4_0.run_generate())

generate_3_6 = FBXExporterGenerate((3, 6, 0), "Blender 3.6", export_fbx_files)
generate_3_6 = FBXExporterGenerate((3, 6, 0), r"Blender 3.6/3.6", export_fbx_files)
generated.append(generate_3_6.run_generate())

generate_3_5 = FBXExporterGenerate((3, 5, 0), "Blender 3.5", export_fbx_files)
generate_3_5 = FBXExporterGenerate((3, 5, 0), r"Blender 3.5/3.5", export_fbx_files)
generated.append(generate_3_5.run_generate())

generate_3_4 = FBXExporterGenerate((3, 4, 0), "Blender 3.4", export_fbx_files)
generate_3_4 = FBXExporterGenerate((3, 4, 0), r"Blender 3.4/3.4", export_fbx_files)
generated.append(generate_3_4.run_generate())

generate_3_3 = FBXExporterGenerate((3, 3, 0), "Blender 3.3", export_fbx_files)
generate_3_3 = FBXExporterGenerate((3, 3, 0), r"Blender 3.3/3.3", export_fbx_files)
generated.append(generate_3_3.run_generate())

generate_3_2 = FBXExporterGenerate((3, 2, 0), "Blender 3.2", export_fbx_files)
generate_3_2 = FBXExporterGenerate((3, 2, 0), r"Blender 3.2/3.2", export_fbx_files)
generated.append(generate_3_2.run_generate())

generate_3_1 = FBXExporterGenerate((3, 1, 0), "Blender 3.1", export_fbx_files)
generate_3_1 = FBXExporterGenerate((3, 1, 0), r"Blender 3.1/3.1", export_fbx_files)
generated.append(generate_3_1.run_generate())

generate_2_93 = FBXExporterGenerate((2, 93, 0), "Blender 2.93", export_fbx_files)
generate_2_93 = FBXExporterGenerate((2, 93, 0), r"Blender 2.93/2.93", export_fbx_files)
generated.append(generate_2_93.run_generate())

generate_2_83 = FBXExporterGenerate((2, 83, 0), "Blender 2.83", export_fbx_files)
generate_2_83 = FBXExporterGenerate((2, 83, 0), r"Blender 2.83/2.83", export_fbx_files)
generated.append(generate_2_83.run_generate())

root_init_file = create_root_init_file(generated)
Expand Down

0 comments on commit a9f1f48

Please sign in to comment.