Part 1:
I've got the source code for an add-on for importing a .skn file that won't display in the add-ons menu in the preferences window. I have the folder with the 4 files needed in it in the scripts/addons/ directory but it wont display in the UI. I am able to import it through the python console but it has problems, still doesnt show up in the addons directory
I figured out part 1, was missing the bl_addon_info in the ____init____.py file it was in ____bpy_init____.py"
Part 2:
This has brought a new problem into the light though, I can't activate the addon through the UI, and when trying to activate it through the python console i get a new error:
Traceback (most recent call last):
File "C:\PROGRA~1\BLENDE~1\Blender\2.54\scripts\ui\space_userpref.py", line 1086, in execute
mod = __import__(module_name)
File "C:\PROGRA~1\BLENDE~1\Blender\2.54\scripts\addons\io_scene_skn\__init__.py", line 37, in <module>
from .__bpy_init__ import *
OverflowError: modification time overflows a 4 byte field
Updating Blender to 2.70 and merging the ____init____.py and the _____bpy_init____.py together mostly solved part 2 and 3 and I am already using this code to register it:
def register():
bpy.utils.register_module(__name__)
bpy.types.INFO_MT_file_import.append(menu_func_import)
bpy.types.INFO_MT_file_export.append(menu_func_export)
def unregister():
try:
bpy.utils.unregister_module(__name__)
except:
pass
try:
bpy.types.INFO_MT_file_import.remove(menu_func_import)
except:
pass
try:
bpy.types.INFO_MT_file_export.remove(menu_func_export)
except:
pass
if __name__ == '__main__':
register()
Still doesn't register it correctly but I can run it from the python console, Updating to 2.70 has introduced another problem that I will post a separate question about since it is most likely not connected to this one in any way.
Part 3: (hopefully solving part 2 solves part 3)
When i try to run a function "io_scene_skn.import_char() I get an error:
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
AttributeError: 'module' object has no attribute 'import_char'
I've tried defining the attributes for import__char both in line, (doesn't work) syntax error, and individually before calling the io_scene_skn.import_char() command.
And here is the code: (import_char is near the bottom of the code)
class IMPORT_OT_skn(bpy.types.Operator, ImportHelper):
bl_label="Import SKN"
bl_idname="import.skn"
SKN_FILE = props.StringProperty(name='Mesh', description='Model .skn file')
SKL_FILE = props.StringProperty(name='Skeleton', description='Model .skl file')
DDS_FILE = props.StringProperty(name='Texture', description='Model .dds file')
MODEL_DIR = props.StringProperty()
CLEAR_SCENE = props.BoolProperty(name='ClearScene', description='Clear current scene before importing?', default=True)
APPLY_WEIGHTS = props.BoolProperty(name='LoadWeights', description='Load default bone weights from .skn file', default=True)
def draw(self, context):
layout = self.layout
fileProps = context.space_data.params
self.MODEL_DIR = fileProps.directory
selectedFileExt = path.splitext(fileProps.filename)[-1].lower()
if selectedFileExt == '.skn':
self.SKN_FILE = fileProps.filename
elif selectedFileExt == '.skl':
self.SKL_FILE = fileProps.filename
elif selectedFileExt == '.dds':
self.DDS_FILE = fileProps.filename
box = layout.box()
box.prop(self.properties, 'SKN_FILE')
box.prop(self.properties, 'SKL_FILE')
box.prop(self.properties, 'DDS_FILE')
box.prop(self.properties, 'CLEAR_SCENE', text='Clear scene before importing')
box.prop(self.properties, 'APPLY_WEIGHTS', text='Load mesh weights')
def execute(self, context):
import_char(MODEL_DIR=self.MODEL_DIR,
SKN_FILE=self.SKN_FILE,
SKL_FILE=self.SKL_FILE,
DDS_FILE=self.DDS_FILE,
CLEAR_SCENE=self.CLEAR_SCENE,
APPLY_WEIGHTS=self.APPLY_WEIGHTS)
return {'FINISHED'}
Can anyone help here?
__bpy_init__.py
into__init__.py
so they are one file. Have a look at the template called addon_add_object.py it has register and unregister functions to enable the addon operators. $\endgroup$ – sambler Jun 25 '14 at 5:35