0
$\begingroup$

After a week I made a nice Addon for Blender. For testing I run it with

import bpy
import sys

scriptdir = "S:Blender\Dev\Scripts\Addons\meshEdit"
sys.path.append(scriptdir)

# Test  
filename = "S:\Scripts\Addons\meshEdit\meshEditorv7.py"
exec(compile(open(filename).read(), filename, 'exec'))

from Blender. All Package-Files are located in the Folder 'scriptdir'. After I finished i copy all Files to an other Folder (named 'S:\Setup Blender\AddOnes\meshEdit) and install it as Addon 'meshEdit' from Blenders Preferences/Addons.

Everything works fine.

For testing i remove the Addon 'meshEdit'

After this I realize that Blender has removed EVERY Python-File in the Develope-Folder

"S:Blender\Dev\Scripts\Addons\meshEdit",

including ALL 5 backup copies Folders inside.

I thinks the reason for this the Codeline 'sys.path.append(scriptdir)' So is there an other Way to testing an Addon and avoid this behaviour?

And is there a way to recover my work?

$\endgroup$
  • 2
    $\begingroup$ sys.path.append only alters variables in memory, it adds an item to an array. Nothing you have shown alters any files on disk. I expect you moved the wrong folder when you moved meshEdit to your addons folder, if it isn't still there and you have no backups I don't expect you will recover them now. $\endgroup$ – sambler Sep 29 '16 at 7:23
  • $\begingroup$ Do you need the exec after adding the path to sys you can import MeshEditorv7. Why not just place the file/files in your user addons folder, and reload them using F8. There was a q/a about this recently. $\endgroup$ – batFINGER Sep 29 '16 at 9:06
  • $\begingroup$ When working with paths in Python, be very careful with backslashes. Either use forward slashes, escape your backslashes ('aaa\\bbb') or use raw strings r'aaa\bbb' $\endgroup$ – dr. Sybren Sep 29 '16 at 18:09
  • $\begingroup$ I wrote 'MeshEditorv7' and its modules in Pycharm, the only thing that runs in Blender is the 'syspath' and 'exec' commands. I suspect the backslash thing that Sybren describe is the cause. I will try the script/addons folder solution that sambler had suggested, and copy the original files. As a kind of "Claymore-Folder". Python owes its name! $\endgroup$ – UncleTeo Oct 1 '16 at 12:26
1
$\begingroup$

As well as the addons folder installed with blender you can have addons within blender's preferences folder. How to find the user config folder on each system is explained here.

Within the config folder for the current blender version, you can create a scripts/addons folder (which is where blender places scripts when you use the install from file button). Inside this addons folder, create and edit your addon. Your addon will show up in the addon list in preferences where you can enable/disable it after each change.

When you are happy with your edits, copy the addon to your backup folder. As the addon is edited in place you reduce the chance of erasing the wrong file and you can also remove/re-install blender without deleting your file.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.