I have an existing data-transfer script for recreating meshes inside Blender using Python.... a script creates these scripts.
It applies UV coordinates to the vertices from a pre-built texFaces array using the following code:
texFaces = [
[[0, 0], [0.04166666667, 0.08333333333], [0, 0.08333333333]],
[[0.04166666667, 0], [0.08333333333, 0.08333333333], [0.04166666667, 0.08333333333]],
[[0.08333333333, 0], [0.125, 0.08333333333], [0.08333333333, 0.08333333333]], ... ]
uvtex = mshobj.uv_textures.new()
for n,tf in enumerate(texFaces):
...datum = uvtex.data[n]
...datum.uv1 = tf[0]
...datum.uv2 = tf[1]
...datum.uv3 = tf[2]
uv1...uv3 don't exist in MeshTexturePoly. I understand that the data structures have been changed. What is the equivalent code in the new regime? This is per-facet UV, created from per-vertex UV. The coordinate and facet data is similarly built from program-generated arrays:
mshobj = bpy.data.meshes.new('Object01')
mshobj.from_pydata(coords, [], faces)
mshobj.update(calc_edges=True)
mshobj.calc_normals()
Thanks.
since 2.63 (bmesh), there can't be uv1-uv4 anymore, as each face can have unlimited number of vertices (ngons). Therefore, the API and the internal data structures changed. Have a look at the official import scripts and the API docs:
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.63/BMesh
http://www.blender.org/documentation/blender_python_api_2_65_release/info_gotcha.html#ngons-and-tessellation-faces
There are also couple threads about this, here and on blenderartists.org
_________________
I'm sitting, waiting, wishing, building Blender in superstition...
As stated here:
http://www.blender.org/documentation/blender_python_api_2_65_release/info_gotcha.html#ngons-and-tessellation-faces
you can still use the old data structures, but they got new names. When a mesh datablock is empty, you can write to tessfaces (former faces), UV access should also work via tessface_uv_texture (was uv_texture).
But refrain from using from_pydata(), as you won't be able to add UVs 'cause it calls an implicit mesh validation/update and the tessface_* structures will become read-only.
You can, however, use foreach_set() - which is also used by from_pydata().
Official addons are the addons which come with Blender and which have been developed by the Blender team. There are also a lot stock addons, which aren't official, but community-made - nonetheless stable (if they come with blender, they had had a code review to get to trunk).
Checkout the importer code in
Blender\x.xx\scripts\addons\ (x.xx --> blender version, e.g. 2.65)
-> io_scene_3ds\ (using loops)
and
-> io_scene_obj\ (using tessface_*)
_________________
I'm sitting, waiting, wishing, building Blender in superstition...