Hi, good night to everyone. I’m trying to make an import addon for the .wso format, a format from the TSR Workshop for editing meshes from the Sims 3.
I’ve seen a lot of reference and tutorials, but i cannot realize what it is wrong in the code at all. :spin:
I hope someone can help me, thanks a lot!!! Here is the code:
bl_info = {
'name': 'TSRW Importer (.wso)',
'location': 'File > Import > TSRW format (.wso)',
'description': 'Importer for the TSR Workshop format',
'category': 'Import-Export'
}
import struct
def read_byte(file_object, endian = '<'):
data = struct.unpack(endian + 'B', file_object.read(1))[0]
return data
def read_ushort(file_object, endian = '<'):
data = struct.unpack(endian + 'H', file_object.read(2))[0]
return data
def read_uint(file_object, endian = '<'):
data = struct.unpack(endian + 'I', file_object.read(4))[0]
return data
def read_int(file_object, endian = '<'):
data = struct.unpack(endian + 'i', file_object.read(4))[0]
return data
def read_float(file_object, endian = '<'):
data = struct.unpack(endian + 'f', file_object.read(4))[0]
return data
# Importer definition
import bpy
def import_wso_file(context, filepath):
file = open(filepath, 'rb')
wso_version = read_int(file)
print(wso_version)
# Class definition
from bpy_extras.io_utils import ImportHelper
from bpy.props import StringProperty
from bpy.types import Operator
class ImportWSO_Class(Operator, ImportHelper):
"""TSR Workshop format importer"""
bl_idname = "import_wso"
bl_label = "Import TSRW Format"
filename_ext = ".wso"
filter_glob = StringProperty(default="*.wso", options={"HIDDEN"})
def execute(self, context):
import_wso_file(context, self.filepath)
return {"FINISHED"}
def menu_func(self, context):
self.layout.operator(ImportWSO_Class.bl_idname, text="TSR Workshop (.wso)")
def register():
bpy.utils.register_class(ImportWSO_Class)
bpy.types.INFO_MT_file_import.append(menu_func)
def unregister():
bpy.utils.unregister_class(ImportWSO_Class)
bpy.types.INFO_MT_file_import.remove(menu_func)
if __name__ == "__main__":
register()
bpy.types.import_wso('INVOKE_DEFAULT')
Hi, good morning. I have another problem with my addon, and I found appropiate not to start another thread.
I have already functional code, i’ve put it all in a file called init.py.
The problem is that when I import the addon from the addon tab of the preferences window in Blender, it doesn’t appear in the list. The menu commands for importing and exporting doesn’t appear too. It only works when running the script in the text editor.
I’d like to make it an installable addon, i think there may be a problem in the code (I’ve remover all that i think it’s irrelevant, for easier reading):
No, there are no errors at all. Not in the info panel of Blender, nor in the console window (Dos-like terminal in Windows)
It says (in the info panel) “Modules installed from ‘… …_init_.py’ into ‘C:… …\Blender Foundation… \addons’ ()” highlighted in green.
The addon does not appear in the addons browser of the preferences window, for whatever category or support level I choose. It doesn’t exist at all.
¡¡¡Thanks a lot!!!, as soon as I’ve changed the filename it started to work like all other addons!!! It seems i misunderstood the purpose of naming something init.py
:yes:;):eyebrowlift::p:D