toggle cyclic many nurbs curves

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.:(:(:frowning:


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()

If somebody knows, please teach me!:stuck_out_tongue:

Take a look at http://www.blender.org/documentation/242PythonDoc/Curve.CurNurb-class.html#setFlagU .

Thank you BeBraw.

I tried this:


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?:confused:

Note that setFlagU is a method of the CurNurb class. Not method of Curve class.

In other words the cyclic property is per curve nurb. Try iterating a curve and setting its cyclic flag on using setFlagU on its each curve nurb.

ok thank you for your answer

I writed it like that:


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()

:):):):slight_smile: