As the title suggests, I’m having trouble testing the scripts I’m developing from the Text Editor window. I’m developing an exporter script as an Add-On which of course drops an entry into the File > Export menu. Everything works fine when I simply enable the addon from the preferences window, but as soon as I run the script from the Text Editor and open the File > Export menu, I get the following error in the console:
AttributeError: 'NoneType' object has no attribute 'path'
The offending line of code is
default_path = os.path.splitext(bpy.data.filepath) + ".x"
which suggests that the os module has not been loaded despite the “import os” statement at the top of the script.
I’ve tried this on two computers with the same result. The first computer was running 32-bit Windows 7 with Blender 2.53 r31485, and the second was running 64-bit Windows Vista with Blender 2.53 r31482. I am out of town and away from my main dev computer which runs 32-bit Windows XP. I have never encountered this problem before, but I suspect it has to do with very recent changes in the way python types are registered (now implicitly, as opposed to explicitly with register() in the past).
Here, as everyone has a copy of the script I am developing (I wrote the DirectX Exporter Add-On script), you can all follow along.
First, make sure you are running Blender r31485 or higher (this is the highest at this writing).
Second, open Blender and change the default 3D View window into a Text Editor.
Third, load io_export_directx_x.py from the 2.53/scripts/addons folder into the Text Editor and press Run Script (or Alt+P).
Fourth, open the File menu at the top of the screen and just hover over the Export menu.
Doing the above steps gives me this.
I can’t imagine that I’m the only one that has this problem, but if this is how it’s gonna be from here on out, how am I supposed to test my scripts? The only solution I’ve been able to do is to edit the script, save it, restart Blender, and then enable the addon from the preferences window. There has to be a better way. How do all of you test your scripts?
Any help would be greatly appreciated.