Scripting Live-Link 📜

Hello guys.

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

Suggested use. always keep an text edito open

  • 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

Script-LiveLink_V21.py (23.3 KB)

Old Version

Script-LiveLink_V8.py (16.0 KB)
Script-LiveLink_V17.py (21.3 KB)
Script-LiveLink_V19.py (19.7 KB)

Quick start guide
  1. install the Script-LiveLink.py
  2. Set up a text editor in your main layout (Keep it always open when using the addon)
  3. use CTRL+T to open the T panel, and go in my addon tab
  4. choose your script path in one of your 3 path slots, then click on "Start LiveLink.
  5. 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.
16 Likes

Hopefully jacque lucke will find a solution for the #EXECUTE problem.

2 Likes

Thanks for your hard work.

Hey thanks !
but you can thank me once we got the #EXECUTE feature working.

Ok i will.:wink:

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).

4 Likes

Okay. Finished.

UPTDATE

  • #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. ?

Script-LiveLink_V17.py (21.3 KB)

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

1 Like

UPDATE

I Replaced the custom execution system !

if #EXECUTE_CUSTOM is in the firsl line instead of simply #EXECUTE it will only execute lines between EXECUTE_START and EXECUTE_STOP

here’s some examples:




Example Script 1=

#EXECUTE
print(1)
print(2)
print(3)

Output:

1
2
3



Example Script 2=

#EXECUTE_CUSTOM
print(1)
#EXECUTE_START
print(2)
#EXECUTE_STOP
print(3)
print(4)
#EXECUTE_START
print(5)

Output:

2
5



#EXECUTE_START can also crop indentation for you

Example Script 3=

#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

Cutted script file will be this:

print('very')    
print('wow')    
print('such')    
print('handy')

Output:

very
wow
such
handy



Keep in mind that all the modules, def, and defined objects will not magically be working if not within the boundaries of the custom execution.

#EXECUTE_CUSTOM
import bpy
C = bpy.context
name = "Monkey"
print(4)
print(5)
#EXECUTE_START
C.object.name = name
#EXECUTE_STOP
print(3)
print(4)
print(5)

Output = Error




Script-LiveLink_V19.py (19.7 KB)

Thanks again! :slightly_smiling_face:

1 Like

@Elreenys let me know for potential feedbacks, do you use Sublime too ? or something else ?

Until now, I’m using VS code, but I was looking for a solution to use sublime.

1 Like

Cool ! let me know how you like it (both)
i will share my library of Snippets once they are in the 50’s

1 Like

It’s definitively my fav addon :heart:
Just one thing, you should add an how to install it in text form, the video is a bit fast.

Sorry.

i will, in the meanwhile it’s really simple:

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.

2 Likes

I succeed to use it but if others wants to try it, they’ll have instructions.
It’s CTR + T in the scripting tab to open the sidebar.

1 Like

What is the Addon Reloader is for in the menu?

It will’ automatically de-install/re-install and enable an addon you are working on.

1 Like

Thanks I will give it try.

1 Like

I have test a bit and :

  • 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

the error message is not important, it’s just that i’m trying to remove a timer something that doesn’t exist yet. I will correct that for update v20.

can i get the file that you cannot draw ? i’d like to see it for myself please, hard to tell witouth it.