Is there a script to convert a series of verts to a curve?

Hi

Does anyone know of a script to convert a series of verts imported from a dxf or vrml file into a curve?

many thanks

http://cybercreator2.free.fr/Pythons/Mesh2Curve.blend

It only works with “Linear Meshes” though, the verts must be connected by edges in linear progression.

%<

I keep geting not a linear mesh error when I try to use this. can some one explain a linear mesh to me. what I am doing is creating a plane deleting 3 verts, duplicating the one left, moveing the duplicate filling them with an edge, then subdividing.this doesn’t seem to make a “linear mesh” any way this is what I am trying to do
http://www.christerb.com/tutorials/maya_modelbraid/index.html
I could not good results with curves but I can model the braid described with verts in blender. now I want to make curves so I can try hair guides.
maby its the fact that I am subdivding instead of adding one vert after another. Off to try.

Aww… then you want this one:

https://blenderartists.org/forum/viewtopic.php?t=37615

Probably only works with 2.37 and there is a .blend you can download near the bottom of that page.

%<

fligh% do you have a hard drive full of links
just set them free
thank you I wil take a look at this
sean

do you have a hard drive full of links

No, I have a memory that bugs the hell out of my wife!

%<

This script does not work with blender 2.38 and upper .

Or you could go here:

https://blenderartists.org/forum/viewtopic.php?t=54607&postdays=0&postorder=asc&start=0

where a helpful guy called phlip solves the problem i think.

bye

I have updated the script. It was an error of compatibilty with lastest version of Blender (as detected by phlip).

So you can find the new version of the script here : http://cybercreator2.free.fr/Pythons/Mesh2Curve.py or the .blend : http://cybercreator2.free.fr/Pythons/Mesh2Curve.blend

(Old versions are still avaible here in directory Old/)

I have cleaned the script and errors reports are better. I’ve also added headers for inclusion in script folder of Blender (even if I think it is the kind of script used once).

3R:

I haven’t worked out how to use the script. Blender freezes if I try selecting verts or edges to convert. Where am I going wrong?

thanks

Hi,

Edges to be converted have to be in a separated object (you can use Pkey to convert only a part of a mesh).
Then, in Object Mode (it should also work in edit Mode), just select object to convert and launch the script.

To see on what type of mesh script run, you can see the .blend file.

However, I think you use the script how it has to be used (even if it’s tried to apply script on a bad mesh, it shouldn’t freeze Blender and just send a Pop-up error message). So if you can send me a .blend where it don’t work, I’ll try to solve the problem. If you can also try to apply script on my .blend exemple, it would be nice.

Thanks

3R:

Hi

Your script works great for me with your .blend. So i tried it on some imported 2D dxf geometry and it didn’t convert to a curve.

This is the output.

-----BEGINNING of Mesh2Curve Script’s processing-----
Conversion for : Mesh.011/ line number : 1
Created curve object : Mesh.011 curve 0
Conversion for : Mesh.011/ line number : 2
Created curve object : Mesh.011 curve 1
Conversion for : Mesh.011/ line number : 3
Created curve object : Mesh.011 curve 2
Conversion for : Mesh.011/ line number : 4
Created curve object : Mesh.011 curve 3
Conversion for : Mesh.011/ line number : 5
Created curve object : Mesh.011 curve 4
Conversion for : Mesh.011/ line number : 6
Created curve object : Mesh.011 curve 5
Conversion for : Mesh.011/ line number : 7

So i tried it on an add->new mesh->circle and it worked great, except I couldn’t get it to fill when i closed the curve, also each vert has a handle? like a path? unlike when i trace over the DXF geometry with a bezier curve (poly) and close it.

many thanks

Why do not use svg files instead of dxf ones ?
http://jmsoler.free.fr/didacticiel/blender/tutor/cpl_import_svg_en.htm

jms:

Why do not use svg files instead of dxf ones ?

Well, because i’m trying to use blender as a architectural viz tool working from 2D CAD building plans and elevations that i produce each and every day.

example: https://blenderartists.org/forum/viewtopic.php?t=54466

However when i get a building with arched window detail for example it gets very messy trying to put quad faces around such apertures, so I thought that curves would do it. But as manipulating curves around shapes is painfull (as there is no dynamic snapping in blender like cad) i can’t just snap a curve vert onto a mesh vert imported from a CAD drawing as dxf or vrml. you end up chasing the crosshairs round with ctrl s this and ctrl s that, so I look for another way to do it, i ask the question has anyone a script to take a hanful of verts in the shape of say an arched window, from a dxf import and convert them into a curve in that shape.

thanks for your interest.

So i tried it on an add->new mesh->circle and it worked great, except I couldn’t get it to fill when i closed the curve, also each vert has a handle? like a path? unlike when i trace over the DXF geometry with a bezier curve (poly) and close it.

If you want to fill curve, it must be a 2D curve. My script must be able to convert 3D curve so the default result is a path. If you want to have a 2D curve, just go in Edit Bouton Panel when the curve is selected and turn off the 3D button (just near to Back and Front). It will automaticly fill it.

For the problem of handles of each vert there is a solution : Select the curve and edit it and select all handles. Then in the Edit Bouton Panel push the Poly bouton.

I know that this solution create new points in your curve (beggining and end of handles). If you want I can try to solve the problem.

What is very strange is that it can’t convert your dxf. I don’t know how dxf converter script works, but the output shows that my script try to convert something and create 5 or 6 curves. So try to select mesh before use the Mesh2Curve script and remove doubles. (…It’s just an idea)

If it still don’t work, try to send me a exemple file. It may be a configuration that I have not imagined.

Thanks and sorry if my english isn’t perfect :wink:

3R:

Fantastic, I’ve got the script to work on DXF / vrml imports from CAD. Many thanks. :smiley:

I hadn’t considered removing doubles to get rid of line on line from the DXF imports. After I removed doubles your script worked.

Just two minor things. The script was telling me sometimes that the mesh couldn’t be converted because it contained a face?

And i selected some edges which threw up a ‘mesh have a point used for more than two edges’ error message, then the script freezes and I can’t exit, the message just keeps coming back up and the command line says:

Conversion for : Mesh/ line number : 1

repeatedly.

But apart from that converting edges/verts to curves is solved.

thanks

3R:

What would be required to amend the script to make 2D Poly Bezier curves rather than 3D nurbs, which I then have to convert to 2D Polys?

thanks

yellow:

Ok, so it was just a problem with the importer script (I think that when it import it create edge by edge and made a lot of verticles).
So for other problems I think that it’s also linked to importation : my script can’t run if there is a face or a verticle linked to more than 2 edges : in this case it can’t determine where is the beggining and the end of the curve.

If you want to make 2D Poly curves, I just have made a script for you :
http://cybercreator2.free.fr/Pythons/Specifik/Mesh2Curve_Yellow.blend

To improve the script I think I’ll modifiy it this week to make avaible some options 2D/3D and Poly/Nurb/Bezier, maybe with Popups menu or with a graphic user interface. What methode is preferable?

3R:

Many thanks for creating the script to convert to 2D Poly. I tried the .blend and it works great except for the rotation of the poly compared to the mesh it’s converted. A minor thing.

When I try the script on my test blend the converted poly appears flat as if it’s been rotated 90degs. I tried it in top and front view with the same result. The poly doesn’t take the shape of the mesh it’s converted like when you change the nurb to a 2D poly. Am I doing something wrong?

To improve the script I think I’ll modifiy it this week to make avaible some options 2D/3D and Poly/Nurb/Bezier, maybe with Popups menu or with a graphic user interface. What methode is preferable?

That would be fantastic, i think a popup menu for speed and minimum space.

many thanks

In fact your problem of rotation and of flat conversion comes from the same fact : to convert to 2D curves I have to make a projection of your mesh in 2D. I choose the Z-local Axis to do the projection.
If you want my script convert your mesh just rotate it in order to have local Z-axis perpendicular to the plane of your mesh.

This operation to align Z-axis with your mesh can also be done with a python script. I’ll try to do it this week.

++
3R