Last active
June 9, 2023 06:40
-
-
Save L0Lock/838a9d83066f0420ff930b137201f848 to your computer and use it in GitHub Desktop.
Sublime Text build environment for Blender Addons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cmd": "build_addon.py", | |
"working_dir": "$project_path", | |
"windows" : { | |
"shell": true | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import shutil | |
import os | |
from distutils import dir_util, file_util | |
# Target folder where to copy the addon's content. | |
# I use a custom directory to avoid having to reinstall addons at each new Blender version | |
# If you want to do the same, don't forget to add that path to Blender > Edit menu > Preferences > File Paths tab > Scripts | |
targetFolder="C:\\AppInstall\\Blender\\MyScripts\\addons\\" | |
# Input files and folders. See examples from lines 16 to 19 | |
# Folders will be copied with their full content. | |
# Put them between '' marks, coma between elements, one per line. | |
# You can write in absolute and relative paths, I chose relative for simplicity. | |
inputFiles=['import_synkscetch_notes.py', | |
'example folder', | |
'example/sub/folder', | |
'example file' | |
] | |
for src in inputFiles: | |
print(f'Copying "{src}" to "{targetFolder}"') | |
if os.path.isdir(src): | |
dir_util.copy_tree(src, targetFolder, preserve_mode=1, preserve_times=1, preserve_symlinks=0, update=1, verbose=1, dry_run=0) | |
elif os.path.isfile(src): | |
file_util.copy_file(src, targetFolder, preserve_mode=1, preserve_times=1, update=1, link=None, verbose=1, dry_run=0) | |
else: | |
print(f'"{src}" not found, skipping...') | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I personally work in my repository, but then need to copy my addon files to Blender's addons folder.
To make this quick, I set Sublime Project Folder according in my repository.
Then, thanks to this duo of build_addon.py file and custom Build System, I just have to hit ⎈ CtrlB to copy everything to Blender.
How to set up:
A - The build system
Put Blender Addon.sublime-build in Sublime Text's build system folders.
Or alternatively:
Sublime Text, go to Tools > Build System, choose Blender Addon.
B - The repository
If not done already, open you repository folder in Sublime Text (i recommend you to save it as a project).
In your addon repository base folder, put the build_addon.py file.
Open it with Sublime Text to set up which files can be copy-pasted and where.
The files and folder to copy are defined as in lines 16 to 19, follow the examples to make your own list of files/folder.
The target folder where to paste your addon is on line 5.
I use a custom directory to avoid having to reinstall addons at each new Blender version and have them all centralized in one place, easy to use.
If you want to do the same, don't forget to add that path to Blender > Edit menu > Preferences > File Paths tab > Scripts:
C - Usage
Anytime you work on an addon repository in Sublime Text, make sure you set the build system to Blender Addon.
Hit ⎈ CtrlB when you want to copy your stuff to Blender's addons folder.