
Question:
Using Blender 2.49's Python API I'm creating a mesh. I have a list of vertices and a list of face indices.
e.g.
mesh = bpy.data.meshes.new('mesh') mesh.verts.extend(mVerts) mesh.faces.extend(mFaces)
I've noticed MVert's uvco property and MFace's uv property, and added some random values, but I can't see any change when I render.
Regarding uvco, the documentation mentions:
Note: These are not seen in the UV editor and they are not a part of UV a UVLayer.
I tried this with the new mesh selected:
import Blender from Blender import * import random scn = Scene.GetCurrent() ob = scn.objects.active o = ob.getData() for v in o.verts: v.uvco = (random.random(),random.random(),random.random()) print v.uvco for f in o.faces: r = (random.random(),random.random()) for i in range(0,4): f.uv.append(r) print f.uv
I can see the values change in Terminal, but I don't see any change when I render. If I reselect the object, the previous face uvs are gone.
Can anyone explain how are UVs set using the Blender 2.49 Python API ?
Thanks
Solution:1
Try simply replacing this line:
o = ob.getData()
with
o = ob.getData(mesh=True)
Due to the historic development of Blender Python API, an ordinary call to blender_object.getData gives you a copy of an object's mesh data, that while can be modified, is not "live" on the displayed object. (Actually it is even an "NMesh" - a class that differs from the living "Mesh" class).
With the optional parameter "mesh=True" passed to the getData method you get back the living mesh of the object, and changes therein have effect (that can be seen upon an update forced with after a Blender.Redraw()).
I never tried UV things, however, so there might be more things to it, but I believe this is your issue.
Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
EmoticonEmoticon