georgevdd / blender-eclipse

Blender/Eclipse integration
GNU General Public License v3.0
6 stars 1 forks source link

Have to restart blender for debug to work #1

Open 8greg8 opened 6 years ago

8greg8 commented 6 years ago

Dear all.

This repo is great, but I have a problem using it. What I do is the following: First I open my Eclipse project with Blender scripts. Then I start Pydev debug server and after that I run Blender subprocess which starts Blender. By setting the breakpoints in eclipse I am able to stop the debugger in that line when I run the script from Blender.

The problem is, I can debug my script only once. If I change the script and want to debug it again, I have to close Blender and start it again as subprocess in Eclipse. This is very time consuming.

Does anyone have any suggestions how to debug on every script change in Blender without restarting Blender application?

georgevdd commented 6 years ago

Thank you for reporting this. I won't have a chance to look into it till 11 March at the soonest but I will do so after that.

8greg8 commented 6 years ago

I was digging for the solution in the past days and found out the following:

Debug is actually working, but when changing my scripts especially modules, debugger still assumes the old scripts are in use. Based on Blender tips and tricks I found out that Blender caches scripts. So to correct this one should use import my_module import imp imp.reload(my_module)

to reload module on every script run.

Further on I was also annoyed by always clicking "Reload from disk" in Blender when I changed the script. Solved this with the code

filename='<path to script>' exec(compile(open(filename).read(), filename, 'exec')) Now I can change my script run above code with only one click.

I also didn't get any output on the console in Eclipse. Still don't know why, but solved it with following on Windows machine. On Linux it should be similar:

First I added PYDEV_SRC_PATH to my environment variables and my PATH. I've done the same for Blender.exe to be able to run it from cmd. Then I opened local terminal in Eclipse and started blender with command in that terminal. Now I can always get printable output in Eclipse.

Hope this will help sbdy.

georgevdd commented 6 years ago

Thanks for this. I'll see whether I can incorporate it in a sensible way, when I get the chance.

georgevdd commented 6 years ago

I included your pointer to the tip about exec() in the main documentation. Thank you for that.