Problem with mesh importing

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

soppera
Posts: 10
Joined: Fri Jan 24, 2003 9:21 am
Contact:

Problem with mesh importing

Postby soppera » Fri Jan 24, 2003 9:23 am

Hi,

Can anyone tell me why this code don't work with Blender 2.25 (neither with 2.23)?

import Blender
from Blender.NMesh import *

m = Blender.NMesh.GetRaw()
m.hasVertexColours(1)

f = Blender.NMesh.Face()
v1 = Blender.NMesh.Vert(1.0,0.0,0.0)
v2 = Blender.NMesh.Vert(1.0,1.0,0.0)
v3 = Blender.NMesh.Vert(0,0,0)
f.v=[v1,v2,v3]
f.col=[Col(255,0,0),Col(0,255,0),Col(0,0,255)]
#c1 = Blender.NMesh.Col(255,0,0)
#c2 = Blender.NMesh.Col(0,255,0)
#c3 = Blender.NMesh.Col(0,0,255)
#c4 = Blender.NMesh.Col()
#f.col=[c1,c2,c3]

m.verts.append(v1)
m.verts.append(v2)
m.verts.append(v3)
m.faces.append(f)

g = Blender.NMesh.Face()
v1 = Blender.NMesh.Vert(1.0,0.0,1.0)
v2 = Blender.NMesh.Vert(1.0,1.0,1.0)
v3 = Blender.NMesh.Vert(0,1,0)
g.v=[v1,v2,v3]
g.col=[Col(255,0,0),Col(0,255,0),Col(0,0,255)]
#c1 = Blender.NMesh.Col(255,0,0)
#c2 = Blender.NMesh.Col(0,255,0)
#c3 = Blender.NMesh.Col(0,0,255)
#c4 = Blender.NMesh.Col()
#f.col=[c1,c2,c3]

m.verts.append(v1)
m.verts.append(v2)
m.verts.append(v3)
m.faces.append(g)


ob = Blender.Object.New('Mesh')
ob.link(m)
sc = Blender.Scene.getCurrent();
sc.link(ob)
#Blender.NMesh.PutRaw(m)

Thanks in advance!

soppera
Posts: 10
Joined: Fri Jan 24, 2003 9:21 am
Contact:

Postby soppera » Fri Jan 24, 2003 3:15 pm

Oh, I should have said that the problem with this code is that the vertex colors aren't OK. With only one triangle: no problems; with two triangles, it does not work

Thanks in advance,


Return to “Python”

Who is online

Users browsing this forum: Bing [Bot] and 0 guests