Thanks to example .3ds file and bug report from stridernzl.
1) The API function for adding textures to meshes was not working correctly, resulting in a Null texture slot being created (i.e. a texture slot was created, but the given texture could never be assigned to this).
Fixed by making the function always require a texture as input (as with other places that use pointers as arguments).
2) In "Textured" draw mode, the imported meshes were shown white (i.e. without any textures).
It appears that that the old old setting (mesh.faceUV) is no longer valid/wrapped in RNA, so worked around this by setting the 'tex' setting for UV-faces on. From the UI, this seems to do the same thing as entering editmode and assigning an image to the faces from the image editor.
---
I've also removed a few lines of commented 2.4x code that is no longer valid. Hopefully there wasn't anything too valuable that I accidentally removed in this process ;)
blender supports type changing for textures in a way that python doesnt.
add a new general function.
Example usage:
tex = bpy.data.textures.new("Foo")
tex.type = 'IMAGE'
tex = tex.recast_type()
Macro to give the number of users accounting for fake user.
ID_REAL_USERS(id)
Use this so you can remove a datablock if it has a fake users as well as apply transformations to it in the 3D view.
Move api function bpy.data.add_texture() --> bpy.data.textures.new()/remove()
change how data is added. eg.
bpy.data.add_mesh(name) --> bpy.data.meshes.new(name)
bpy.data.remove_lamp(lamp) --> bpy.data.lamps.remove(lamp)
image and texture stil use add_* funcs
however this meant the invoke function could not modify properties for exec to use (unless it called exec directly after)
since the popup for eg would re-instance the python class each time.
now use the operator properties directly through rna without an automatic copy.
now an operator attribute is accessed like this...
self.path --> self.properties.path