How to use UVlayer?

Hi,
i like to support the new UVlayers to make it possible exporting different uv coords per texture channel.

But how to do the? I didn’t understand it.

Exporting vertex colors works out of the box and the active color layer will be exported automaticly. But not the UVlayer.

i basicly use this code to export the the texture coords and index:

rawData = Blender.NMesh.GetRawFromObject(thisObj.getName())
rawData.faces
face.uv

Thanks!

NMesh cant access UV layers, only Mesh

You have to set the active layer, then access teh UV’s or vcols as useual.
see the FBX exporter in blender for an example


for uvlayer in me.getUVLayers():
    me.activeUVLayer = uvlayer
    print uvlayer
    for f in me.faces:
        print '	', f.index, f.uv

Will NMesh have access to UV layers in future?

nope, NMesh is awful,

long answer is, if anyone wants to maintain NMesh, they can. but we (ken and myself) are focusing on Mesh now and only touching NMesh when we have to.

we will also have BMesh soon bopefully so maintain 3x mesh API’s is a bit much.

NMesh will export the mesh as is including the modifiers right? That’s the only differenz or?
That’s why i’m using it. Or is there a way getting the same data from Mesh?

Thanx!

both Mesh and NMesh can access mesh data with and without modifiers applied.

Hi Cambo,

ok changed anything from NMesh to mesh (just chnaging zwo lines). But i can’t find a way to get the information which texture channel using whicj uvlayer :frowning:

Are the uvlayers always ordered like the texture channels?

Thanks so far!

http://members.optusnet.com.au/cjbarton/BPY_API/Material.Material-class.html#uvlayer

Mhm, interesting, it seems the official documentation got holes. I downloaded it from blender.org and the uvlayer didn’t appear at this chapter. Thanks so far.

I think I added this after 2.43

Oh man problems, problems, problems :frowning:
Did you know how to combine Mesh.getFromObject and activeUVLayer?

I ike to get the uv coords and index of the derrived mesh and not of the original (this is needed exporting subsurfed meshes with multiple uv layers).

THANX!

there is no problem with getting UV ;layers from deformed subsurf mesh

  • This works with the new and decieded on API

import bpy
sce= bpy.data.scenes
ob = sce.active.objects.active
me = bpy.data.meshes.new()
me.getFromObject(ob)
print me.getUVLayerNames()

Oh Man! Yes!

Thanx thousend times!!!

Let me know if you some times need my help.

Best regards.
Bart.