[Bf-python] Add UV coordinates by python: is possible?

Manuel Bastioni manuelbastioni at tin.it
Mon Feb 2 03:42:52 CET 2004


I'm trying to write this code to read the UV from external file
and assign to object . I't's very short, I paste it here:

try:
        obj = Blender.Object.Get("Base")
        obj_mesh = obj.getData()
        obj_mesh.hasVertexUV(1)
    except:
        print "Base obj not in scene"
        return

    file = open(path+"base.uv")
   
    for f in obj_mesh.faces:
        uvData = file.readline()
        uvCoo = uvData.split(';')
        nverts = len(f.v)
        for i in range(nverts):
            uvVertCoo = uvCoo[i].split(',')
            f.uv.append(uvVertCoo)
       
    file.close()
    obj_mesh.update()

The uv is stored in text line as
x,y;x,y;x,y;x,y

If I use the line
f.uv.append(uvVertCoo)

Blender print  the error:

SystemError: new style getargs format but argument is not a tuple

If I modify the line above as
f.uv.append(tuple(uvVertCoo))

the error is:

TypeError: bad argument type for built-in operation

Is possible to add the UV in this way? If not, can be a good idea to 
implement it....

Thanks,

                Manuel





More information about the Bf-python mailing list