I just wrote a simple script that take the vertex of mesh’ faces to draw nurbs curves.
The problem is that I don’t know how to close (toggle cyclic) those curves.:(:(
import Blender
from Blender import Mesh, Object, Scene, NMesh, Curve, CurNurb
ob = Blender.Object.GetSelected()[0]
me = NMesh.GetRawFromObject(ob.getName())
n = 1
for NMFace in me.faces:
coord = []
b = NMFace.v
for points in b:
loc = points.co
x = loc[0]
y = loc[1]
z = loc[2]
w = 2.0
newloc = [x,y,z,w]
coord.append(newloc)
cu = Curve.New()
cu.appendNurb(coord[0])
cu_nurb = cu[0]
coord.remove(coord[0])
for newloc in coord:
cu_nurb.append(newloc)
cu.isCyclic() == True
ob= Object.New('Curve')
ob.link(cu)
scn= Scene.GetCurrent()
scn.link(ob)
ob.layers= [7]
print "processing face", n
n += 1
print "Done"
Blender.Redraw()
import Blender
from Blender import Mesh, Object, Scene, NMesh, Curve, CurNurb
ob = Blender.Object.GetSelected()[0]
me = NMesh.GetRawFromObject(ob.getName())
n = 1
for NMFace in me.faces:
coord = []
b = NMFace.v
for points in b:
loc = points.co
x = loc[0]
y = loc[1]
z = loc[2]
w = 2.0
newloc = [x,y,z,w]
coord.append(newloc)
cu = Curve.New()
cu.appendNurb(coord[0])
cu_nurb = cu[0]
coord.remove(coord[0])
for newloc in coord:
cu_nurb.append(newloc)
cu.setFlagU(1)
ob= Object.New('Curve')
ob.link(cu)
scn= Scene.GetCurrent()
scn.link(ob)
ob.layers= [7]
print "processing face", n
n += 1
print "Done"
Blender.Redraw()
But there is still an Attribute Error on setFlagU
:(I don’t understand where is the error?
import Blender
from Blender import Mesh, Object, Scene, NMesh, Curve, CurNurb
ob = Blender.Object.GetSelected()[0]
me = NMesh.GetRawFromObject(ob.getName())
n = 1
for NMFace in me.faces:
coord = []
b = NMFace.v
for points in b:
loc = points.co
x = loc[0]
y = loc[1]
z = loc[2]
w = 2.0
newloc = [x,y,z,w]
coord.append(newloc)
cu = Curve.New()
cu.appendNurb(coord[0])
cu_nurb = cu[0]
coord.remove(coord[0])
for newloc in coord:
cu_nurb.append(newloc)
cu_nurb.setFlagU(1)
ob= Object.New('Curve')
ob.link(cu)
scn= Scene.GetCurrent()
scn.link(ob)
ob.layers= [7]
print "processing face", n
n += 1
print "Done"
Blender.Redraw()