"flat" dxf export script + how would I separate loose parts?

Okies Yorik my man!

Spoke with Les Newell over at SheetCAM (He is the developer of SheetCAM) and he confirmed my suspision that the Export we are gettign from the script is apparently writting the same line more than once. The error message in SheetCAM [The drawing contains overlapping Outlines] means simple, that SheetCAM detected that the same exact line exists more than once in the DXF. Les has actually built in protection for this scenario (Mostly to prevent 3D drawings from causing problems) but that fix actually resolves the issue with Overlapping Outlines when it is imported into SheetCAM. (Exactly as the error message indicates it does.) Although for me the Script is usable as is for my purposes, methinks the issue will cause other problems with their implementations. If you like, I can get you a DXF file that is exported from Blender using your script, and another that I have repaired so you can compare the two. Perhaps that would assist you in your efforts. Your doing great Yorik!
:slight_smile:

Yes, actually DXF files are always a big headache, always full of problems, bad-formatted entities, etc. Of course one could write a kind of wizard that cleans a lot of things before exporting, but my idea was to make just a simple thing that exports what is selected, and doesn’t check further, as long as the geometry can be exported to valid dxf files. For example, if you don’t remove doubles, you could have polylines with 2 vertices at the same position, which is a valid polyline anyway, but some applications would complain about that or refuse to import…

Maybe the best solution would be to have another script that cleans linework… That way it can be used to clean imported files too… But cleaning 2D CAD files is a hell of a work, and I’m not sure it can be totally done “automatically”…

I hear ya mate. But I have been using a simple 10 vertices circle in my testing. No chance of having doubles to begin with. using the first script you developed, I can import the DXF file back into Blender, but it the circle is incomplete and there are multiple doubled vertices in it. (doubled vertices may just be an issue with the import function cause I always have to remove dooubles when I import a dxf) The second script you wrote actually makes a nightmarish DXF file when you open it in notepad. The standard format is all jumbled together, but, CAD programs can still read it. [EDIT: Accutrans can parse the file, But AutoCAD and Volo View cannot.] Blender wants nothign to do with it and it fails to load with a parsing error. I am still snooping through the actual DXF files that are being generated. Compared to a DXF file that I have used a real CAD program to generate, there are distinct differences even though the two files are polyline based. Of course, my knowledge of DXF format is woefully short. I’m reading and snooping and if I find anything interesting that I think might help, I will surely let you know!! Thanks for all your efforts mate!

That’s strange, for me it works kind of fine now…

Looking at the output of the new script, the resulting DXF isn’t getting a line feed or carriage return after each line is all. Accutrans is able to parse through it, but Blender, AutoCAD, and Volo View can’t open it. I have been all over the place looking at all kinds of what-nots trying to help you here (since my programming skills are just above that of a common squirrel).

Possible solution is to forget Polylines and LPolylines and just go old school and do just ‘Lines.’ I was looking for documentation on the SDFX library you used in the first draft but couldn’t find anything. I know it supports regular lines. i was trying to figure out how to convert your script but only managed to mangle a few copies of it. hehe

Up to you Yorik if you want to pursue it further. I made a spreadsheet of the different outputs in ASCII so I could tell exactly where the differences where. I can post it if your curious.

Heya Yorik

Was looking at SheetCAM forums and found that the latest (under developement) version of SheetCAM has support for SVG files. So I downloaded it and made a SVG with you Profile scripts and hit one minor snag…

http://www.wikkidwidgets.com/images/TSU.jpg

hehe, I confirmed with a SVG viewer, the SVG’s are exported upside down. :smiley:

hi Yorik, handy tool, thank you.

Unfortunately autocad will have problems with it, because LWPOLYLINE is an acad-r14 object and dxf code must have corresponding r14 header.
It must be at least AC1014. R14 header specification seams to be a little complicate…

I would suggest go back to LINEs or POLYLINEs:

  • R12-dxf-code doesn’t need header section at all
  • “all” CAD-systems will read this.

Yorik,
i’ve made a little modification: lets your script to export DXF-r12 (LWPOLYLINEs -> POLYLINEs)
version 0.1.4

WiKKiDWidgets, let me know if it works better for you

the createIslands() and getOrderedVert() need rework, they generate plenty of double-verts even from simple edge structures, even after remove doubles. Editing such a “multi layered” polyline in autocad is a nightmare.

Hi migius, thanks for helping me with that! You are the DXF expert here :slight_smile: I’m still quite young with it…
Yes, some parts of the script are a bit messy, but until now it imported fine in qcad… I’ll work a bit more on it. For the carriage return problem it’s probably some windows/linux difference… forgot to add \r I think.
I’ll check a bit further. Thanks for the script update!

The line feed doesn’t matter - both Unix and windows format should work!
The only problem was the wrong header AC1009 (not supporting LWPOLYLINE entities.)

I have had some problems to understand your intention with createIslands() and getOrderedVert(). Could you please explain what islands are good for?

the new DXF-Exporter script is here

well, suppose you have several separated polylines in a mesh… Then you must separate them into different group of connected edges (islands). Then, you must order the vertices because in a polyline vertices must be ordered. But in Blender they are not always ordered, so that’s why I made this… I am far from sure that it is the best way or anything, but that’s where my humble brain brought me :)…

Thats right. It is an interesting topological problem. Searching for optimal algorithm will make fun. Or going the short way with google, hehe

Nope, exported using your version and I can’t open it with SheetCAM or Accutrans, Blender give a parsing error trying to re-import it, but it does import it back in. Only issue it that it adds a face. (I’m using a 10 vert circle for testing.) I tried Volo View and AutoCAD. They will open it with no errors, but nothing is there. I zoomed in and out and panned all over. Nada.

Hiya Yorik, did you see my post on the first page showing the output from your SVG script? Not sure if you want to work on it further, but its kinda neat anyway. hehe
Hey thanks for all your work on this. when I get my new CNC procedural documentation written, you will be given mega credit for your efforts!

thanks!

yes, i’m trying to figure out how to flip that… it’s because svg coordinates are with the origin on top. Ah, i updated the script, i think it makes correct polylines now… But maybe still needs some adjustments.

Ya want me to download and test it?
Si not a problem for me to do that for ya!

Yes, sure! It is the same download link as the first version:
http://yorik.orgfree.com/scripts/export_profile.py
I’m curious to see how it works now…

Okies, I’ll nab it now and give it a go. :slight_smile: