I really like working in sublime but there’s no link right now so i elaborated an universal “Script Live-Link”
it can work with any note editor what so ever, the goal is to facilitate development of scripts and addon within blender for peoples who use different text editors.
here is the project:
You can choose up to 3 scripts paths at the time in the text editor T panel.
Once the python script path is choosed, an execute script operator will be at your disposal. (click on the operator for an direct manual execution).
You can create a livelink:
If “EXECUTE” is in the first line of your script, every time you save the script, it will automatically run inside of blender. it can also work with if __name__ == "__main__": register() which is nice for working on addons.
If “#EXECUTE_CUSTOM” is in the first line of your script, every time you save the script, it will automatically create(/overwrite) a new file with the line between #EXECUTE_START and #EXECUTE_STOP then run it in blender. see examples here
if you choose the #EXECUTE_CUSTOM method, don’t forget your boundaries. as the script will be empty otherwise.
If #STOP is in the first line of your script, the live-link will stop.
Always keep an text editor open in the blender main layout otherwise the link will not work. i suggest you tu use a set up like this below
There’s also an addon reloader operator, handy to update the code of your addon directly into blender if if __name__ == "__main__": register() method won’t work for you. You just need to set the path of the addon you are working on. i only support “one .py file” addon type. let me know if you’d like a full folder to zip & install automation
Set up a text editor in your main layout (Keep it always open when using the addon)
use CTRL+T to open the T panel, and go in my addon tab
choose your script path in one of your 3 path slots, then click on "Start LiveLink.
if #EXECUTE or #EXECUTE_CUSTOM is in the first line of the script, everytime you save the him it will automatically it will be automatically executed within blender.
Help! my live-link doesnt work!
if the script link is not working for you. please read above. but here a quick check-up:
at the first place, is your script working witouth the addon ? try it out in a text editor.
is the link on ? if it’s a brand new blender session and you forgot to close it last time, you will need to stop and re-start the link. is #EXECUTE in your first line ?
Did you use #EXECUTE_CUSTOM witouth any boundaries ?
did you leave an text editor always open as i suggested above ?
do you [Ctrl+S] shortcut from your text editor actually save ondisk ?
you can try to check if the live-link is properly working with the debug mode (checkbox below) it will print all important event, timers and handlers activities.
i cracked the #execute problem with the help of kiao. im using it for my scripts right now. it’s god damn powerful. i hope the blender institute will let me make this addon official. it make a kinda universal link with any other script editor. (there’s just the step of finding script path which is annoying).
#EXECUTE is now working perfectly, with 3 scripts live-linked simultaneously.
It can not work with addon if __name__ == "__main__": register() which is really nice for working on an addon.
if your addon is too complex to be used with if __name__ == "__main__": register() you may directly register it inside of blender with the addon realod operator.
personally i’m not working with .zip format with multiples scripts for one addon. so right now this operator will only work for one file .py addon format. Please let me know if .zip support important for you. i think i can automate a whole folder to .zip + auto addon reg.
i dropped the .blend text editor live link. as it is totally useless. i get that it’s cool but i find not utility in this. It’s worth nothing now that #EXECUTE is here. If you don’t agree with that let me know.
you have now the possibility of executing only some part of your script. for example:
#EXECUTE[5] will only execute line 5
#EXECUTE[5:55] will only execute lines 5 to 55
#EXECUTE[5:10][15:16][36] will only execute lines 5 to 10 + 15 to 16 +36
This is really useful. i tested it myself, as there’s no need to use a whole new file to do some testing.
it will also generate a ScriptName_script_cut.py file. let me know if i should automatically delete him after execution.
I could do an alternate way of doing this like #EXECUTE BELOW and #STOP directly inside of the script ? what do you think ? is this better ? i think i’ll do that right now. ?
i had some def attribute problem in the script so there’s some horrible def repetition. it was kind of tricky to get one def working for the three custom slots at the same time. so i had to made one def per slot which is stupid. but well it is working. #don’t judge me please
#EXECUTE_CUSTOM
def my_super_complex_def():
if blabla == True:
if 'hello' not in manywow:
#EXECUTE_START
print('very')
print('wow')
print('such')
print('handy')
#EXECUTE_STOP
1)install the addon .py
2)set up a text editor (always open) and go in the T or N panel. find out my addon category.
3)just set your script path. you can set 3 scripts simultaneously.
4) use #EXECUTE in the first line of your script and every time you save the script will be automatically run inside of blender.
if I work on panel, there is no update (no new property is draw)
I got this error when I try to disable the addon
Exception in module unregister(): ‘/home/elreenys/.config/blender/2.80/scripts/addons/Script-LiveLink_V19.py’
Traceback (most recent call last):
File “/mnt/55197c6b-14c8-49a8-a69e-286fbfc7ebdb/Blender build/blender-2.80-linux-glibc217-x86_64/2.80/scripts/modules/addon_utils.py”, line 437, in disable
mod.unregister()
File “/home/elreenys/.config/blender/2.80/scripts/addons/Script-LiveLink_V19.py”, line 430, in unregister
bpy.app.timers.unregister(poll_text1)
ValueError: Error: function is not registered
Error: Traceback (most recent call last):
File “/mnt/55197c6b-14c8-49a8-a69e-286fbfc7ebdb/Blender build/blender-2.80-linux-glibc217-x86_64/2.80/scripts/modules/addon_utils.py”, line 437, in disable
mod.unregister()
File “/home/elreenys/.config/blender/2.80/scripts/addons/Script-LiveLink_V19.py”, line 430, in unregister
bpy.app.timers.unregister(poll_text1)
ValueError: Error: function is not registered