Close

DXF Export Code

A project log for Space Colonisation

No, not space exploration. Its a method of filling an area with a pattern. A remix of Charlie Williams' "Laser etched book edges".

agpcooperagp.cooper 06/07/2018 at 10:580 Comments

DXF Export Code

Writing DXF code is a real pain. The reference manual is complex. Also old code usually does not work with later versions of Autocad.

Not too hard to write line or segment code (there is an example in the back of the reference manual) but polyline code was a real headache. Made worse that my CAD package reads in polylines as lines/segments and not as polylines, as it uses LWPolyline internally. Took me ages to accept that the code was likely correct.

I have written 3D code but reverting back to 2D is easy enough.

But really I should have written a gCode export and skipped DXF export.

There is some C code for DXF import (just a skeleton) in the back of the reference manual so that should not be too bad.

I can use segments for the Colonisation algorithm cut-out and out-line boundaries but that requires quite a bit of code to reconstruct the orginal polyline. It not that easy to reconnect the segments, I know as I have had to sovle this problem before.

Determining if a grid point is inside or outside a polyline is not too hard, however.

gCode Export

I think I should rework the Colonisation code to export gCode directly. Internally, the Colonisation algorithm will need some work (I think) else I will likely need to reoptimise the segment order (think of the Travelling Salesman problem).

DXF Line/Segment Code added to Colonisation Algorithm

I could not add the DXF Polyline code without a major rework of the Colonisation algorithm. So I will have to convert to Polylines later. The results are quite good:

Still an issue with some missed grid locations but much improved from my first iteration.

DXF is a Headache

DXF is a headache. Delta-Cad is happy with Circle and Line but not Polyline (it loads as segments). Cut2D is happy with Polyline but not Circle or Line. When I look inside the other dxf files they are using  AcDb* etc. What is that?

Okay, I found a paper with a simple dxf file with AcDb* entities. Entities have handles but what are the rules? Anyway, Delta-Cad will load the file, even with LWPolyline it still thinks they are segments (even when I set the closed polyline flag). Cut2D will not touch them.

I think I am going backwards!

I actually think I would be better off using some other format or even directly to gCode.

AlanX

Discussions