Edges to Curve Script for Blender 2.5

Can someone help please
I cannot use Blender 2.5 just because one key component is missing.
The very Edges to Curve Script.
Dear Campbell Barton,
could you please rewrite this script for Blender 2.5.(tried it it does not work)
If you are too busy working on the Durian Project can someone help please.
All my Model are based on thie script (even my sculpting start with this script)

The script is as follow:

#!BPY
“”" Registration info for Blender menus:
Name: ‘Edges to Curve’
Blender: 241
Group: ‘Mesh’
Tip: ‘Edges not used by a face are converted into polyline(s)’
“”"
author = (“Campbell Barton”)
url = (“blender”, “blenderartists.org”)
version = “1.0 2006/02/08”

bpydoc = “”"
Edges to Curves

This script converts open and closed edge loops into curve polylines

Supported:<br>
Polylines where each vert has no more then 2 edges attached to it.
“”"

***** BEGIN GPL LICENSE BLOCK *****

Script copyright © Campbell J Barton

This program is free software; you can redistribute it and/or

modify it under the terms of the GNU General Public License

as published by the Free Software Foundation; either version 2

of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

You should have received a copy of the GNU General Public License

along with this program; if not, write to the Free Software Foundation,

Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

***** END GPL LICENCE BLOCK *****

--------------------------------------------------------------------------

from Blender import *

def polysFromMesh(me):
# a polyline is 2
#polylines are a list
polyLines = []

# Get edges not used by a face
edgeDict= dict([ (ed.key, ed) for ed in me.edges ])
for f in me.faces:
    for key in f.edge_keys:
        try:
            del edgeDict[key]
        except:
            pass

edges= edgeDict.values()


while edges:
    currentEdge= edges.pop()
    startVert= currentEdge.v2
    endVert= currentEdge.v1
    polyLine= [startVert, endVert]
    ok= 1
    while ok:
        ok= 0
        #for i, ed in enumerate(edges):
        i=len(edges)
        while i:
            i-=1
            ed= edges[i]
            if ed.v1 == endVert:
                polyLine.append(ed.v2)
                endVert= polyLine[-1]
                ok=1
                del edges[i]
                #break
            elif ed.v2 == endVert:
                polyLine.append(ed.v1)
                endVert= polyLine[-1]
                ok=1
                del edges[i]
                #break
            elif ed.v1 == startVert:
                polyLine.insert(0, ed.v2)
                startVert= polyLine[0]
                ok=1
                del edges[i]
                #break    
            elif ed.v2 == startVert:
                polyLine.insert(0, ed.v1)
                startVert= polyLine[0]
                ok=1
                del edges[i]
                #break
    polyLines.append((polyLine, polyLine[0]==polyLine[-1]))
    # print len(edges), len(polyLines)
return polyLines

def mesh2polys():
scn= Scene.GetCurrent()
scn.objects.selected = []

meshOb= scn.objects.active
if meshOb==None or meshOb.type != 'Mesh':
    Draw.PupMenu( 'ERROR: No Active Mesh Selected, Aborting' )
    return
Window.WaitCursor(1)
Window.EditMode(0)
me = meshOb.getData(mesh=1)
polygons= polysFromMesh(me)
w = 1.0
cu= Curve.New()
cu.name = me.name
cu.setFlag(1)

ob = scn.objects.active = scn.objects.new(cu)
ob.setMatrix(meshOb.matrixWorld)

i=0
for poly, closed in polygons:
    if closed:
        vIdx= 1
    else:
        vIdx= 0
    
    v= poly[vIdx]
    cu.appendNurb((v.co.x, v.co.y, v.co.z, w))
    vIdx += 1
    cu[i].type= 0 # Poly Line
    
    # Close the polyline if its closed.
    if closed:
        cu[i].setFlagU(1)
    
    # Add all the points in the polyline.
    while vIdx&lt;len(poly):
        v= poly[vIdx]
        cu.appendPoint(i, (v.co.x, v.co.y, v.co.z, w))
        vIdx+=1
    i+=1
Window.WaitCursor(0)

not used as yet.

“”"
def writepolys():
me = Scene.GetCurrent().getActiveObject().getData(mesh=1)
polygons= polysFromMesh(me)
file=open(’/polygons.txt’, ‘w’)
for ply in polygons:
file.write('polygon ')
if ply[1]:
file.write('closed ')
else:
file.write(‘open ‘)
file.write(’%i
’ % len(ply[0]))
for pt in ply[0]:
file.write(’%.6f %.6f %.6f
’ % tuple(pt.co) )
file.close()
“”"

if name == ‘main’:
mesh2polys()

can you upload the code so we cn read it and copy it back
or upload somwhere so we can download it !

would help to help you i guess

happy 2.5

The detais for the script is there:
http://wiki.blender.org/index.php/Extensions:2.4/Py/Scripts/Mesh/edges_to_curves

It seems like the script should alreaby be included in 2.5!?
But it is not.

you can find the script in the 2.49 version of blender
Script -> Mesh -> Edges to curve

Can you help?

it’s possible this ahs not been done yet
but should be soon hopefully

meanwhile if you need to se it then ue 2.49

you could also go to IRC python and ask the question there
may be it’s already being work on by someone!

happy 2.5

Ok I guess I wait to see if it come out for the next release of Blender 2.5.
Otherwise there is not escape for me.
I am going to get my hand durty in scripting to get the Job done.

Thank you for your help and guidance.

Happy 2.49 for now

I don’t know if this will help, but have you tried using Alt-C to convert the mesh to a curve?

you can also look at the simplify curve script done this week

it has most of the commands to read a curve and then make a new one

ok it needs to be converted to a mesh instead but that should not be that difficult

or wait till the script for edge to curve is converted !

hope it helps

there are so many scripts to be converted i don’t think devs have time right now to work on this cause too much work to debug 2.5 and add the new features and don’t think it’s gone change for a while at least next 2 or 3 months or more

don’t forget 2.5 is still in alpha stage and requires may be more work then expected
and without taking into consideration the scripts

so patience it will be done in time

happy 2.5