Quantcast

Export two layers to DXF

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Export two layers to DXF

kitwallace
This post was updated on .
I work on polyhedra and their construction and rendering.  A rather complex part is the production of a net from a solid.  i'd like to laser-cut these nets, but this needs two layers - one for the outline to cut through, the other for the interior lines to score.  I see there has been some discussion on the issue list re layer export but until it is implemented, what work-arounds have folk used?  I guess I could export two separate DXFs  and merge them somehow?


Rhombic Dodecahedron

TIA  
Chris

http://kitwallace.co.uk/3d/solid-index.xq
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Export two layers to DXF

fred_dot_u
If you aren't averse to using other programs, a couple options pop into my alleged mind.

If you're starting from an STL file, consider that the free program Slic3r provides for export to a DLP 3D printer, in the form of sliced segments determined by the user-defined layer thickness. Sending your STL to the program, setting zero infill and layer thickness to your requirements should result in a set of graphic images, although I've forgotten the format of those images. Even if they are JPG, BMP, PNG, one can easily convert them to your laser format.

Another option is to use Inkscape to import the flattened image and modify the lines as needed. I selected Inkscape because it's free, but any vector editing program should provide for your requirements. If you haven't checked out Pepakura, you may find it contains even better answers. Although not free, it's astonishingly low priced considering the features.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Export two layers to DXF

Ronaldo
In reply to this post by kitwallace
2017-04-10 10:41 GMT-03:00 kitwallace <[hidden email]>:

http://kitwallace.co.uk/3d/solid-index.xq


Wow! What a huge and rich work. I tip my hat to you.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Export two layers to DXF

kitwallace
This post was updated on .
Ronaldo - thanks - it's a bit of a monster and still growing. It's great that OpenSCAD can do this stuff - multiple hat-tips to the team  (but oh for an associative array)

Fred -thanks for the suggestions. It seems both those approaches go via  images and that will loose accuracy and require manual work.  I feel that merging the 2 DXF files should work - I'm looking for, say, a python script which does this.

Chris
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Export two layers to DXF

droftarts
Hi Kit

I took one of your polyhedra net files and played around with it. As there's no way of drawing lines, let alone exporting them, from OpenSCAD, I resigned to drawing them by hand. I added a projection cut to get the net in 2D, then exported a dxf and svg.

If you're exporting a dxf, you're probably going to have to reconnect the lines at some point anyway, as OpenSCAD exports dxfs as individual line segments. Opening the dxf in a drawing package (eg Inkscape) should give you the outline (or cut line). You can reconnect the points easily in Inkscape, or if you export from OpenSCAD as an SVG, they stay connected.

To draw the internal 'fold' lines in Inkscape, create a new layer, and select the line tool (pen tool). Set the cursor to snap to 'cusp nodes' ( View > Show/Hide > Snap Controls Bar), and the cursor should snap to the nearest point, and allow you to draw the lines accurately to the points. Inkscape's drawing tools are somewhat of an acquired taste (especially after years using Illustrator!), so if you need extra guidance on the above, let me know, though there is extensive online help. You can, of course, do something similar in other vector drawing packages.

Once all the lines are drawn, export the file as a dxf (uncheck 'use ROBO-master...' but check 'use LWPOLYLINE...'). If you have problems importing the dxf into the laser cutter software, you may need to resave it with a better dxf creation tool than Inkscape; I use QCAD. This opens Inkscape dxfs (and OpenSCAD's and Illustrator's), and allows you to resave them in a version other software will understand. I tend to use R15 dxf version, which seems to have the broadest support for my uses.

Haven't tried laser cutting the resulting file yet, but will... soon...

Ian A-S (Bristol Hackspace)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Export two layers to DXF

kitwallace
Hi Ian

Many thanks for that advice.  I can generate two dxf files one for the outer


the other for the inner lines


so I was thinking that I could combine these as layers in one DXF I might not need much manual intervention.  I've generated the two DXF files to experiment with and would be glad of your help.

Chris  
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Export two layers to DXF

Neon22
Hi Chris - great progress.
I'd be inclined to load them into inkscape and select the paths and group them there. The advantage being that the result can be scaled and exported as SVG with useful dimensions.
Exporting from Inkscape as a PDF for printing, or send the SVG straight to someone like Ponoko - which takes svg files from inkscape and laser cuts them using their templates as a guide (colours define cut or score).
(all templates here: https://www.ponoko.com/starter-kits/inkscape)

Having said that a lot of laser cutters also take DXF - but its such a crusty format. Looks like you'll always be using straight lines though, so more chance of success...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Export two layers to DXF

kitwallace
Thanks for the suggestions folks.

I switched to exporting SVG since its easier to manipulate.  However, even the SVG paths are difficult to simplify to single lines for the laser cutter because the thin rectangles get  joined into  complex areas if they touch. After a struggle, I suddenly realised that I could construct the complete SVG in openscad as text, with lines as lines rather than  rectangles and outer and inner lines as two differently coloured paths.  This works fine even if I have to copy and paste echoed output to create the file.  

 

I'll write up the approach and post a link.

Chris
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Export two layers to DXF

Neon22
wow
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Export two layers to DXF

MichaelAtOz
Administrator
hmmm...resize a box-drawing-vertical char?
Admin - PM me if you need anything,
or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.


The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Export two layers to DXF

kitwallace
This post was updated on .
In reply to this post by kitwallace
In case it is of interest, I wrote up this work in my blog

http://kitwallace.tumblr.com/post/159631931839/laser-cut-nets-with-openscad

These OpenSCAD functions generate SVG from multiple 'paths'  as list of line segments.  No attempt is made to join up connected lines since laser cutter software seems to do this anyway and it doest matter when displaying SVG.  Paths are enclosed in a g element so that transformations can be added to the SVG later.

/*  path object:
    path[0] : lines
    path[1] : color
    path[2] : width

*/


function rstr(list,i=0) =  // string join a list of strings
   i < len(list)
      ? str(list[i],rstr(list,i+1))
      : "";

function line_to_svg(line) =
    str(" M ", line[0].x,",",line[0].y," L ",  line[1].x,",",line[1].y);

function path_to_svg(path, colour, width) =
    str("<path d='",rstr([for (line  = path[0]) line_to_svg(line)]) ," ' ",
           "style='fill:#ffffff;stroke:",path[1],";stroke-width:",path[2],"'"
           ," />");
   
function bounding_box(vertices) =
   [ [ min([for (v = vertices) v.x]),  
       min([for (v = vertices) v.y]),
       min([for (v = vertices) v.z])],
     [ max([for (v = vertices) v.x]),
       max([for (v = vertices) v.y]),
       max([for (v= vertices) v.z])]
    ];
 
function dash_line(line,dash_length) =
    let (v = line[1]- line[0])
    let(line_length=norm(v))
    let(n =  floor(line_length/dash_length))
    [for (i=[0:n-1])
      let(a = v *  i / n)
      let(b = v *(i + 0.5) /n)
      [line[0]+a,line[0]+b]
    ];
   
function dash_lines(lines, dash_length) =
     flatten( [for (l = lines)
           dash_line(l,dash_length)
      ]);

function paths_to_svg(paths, name) =
    let (v= flatten([for (path=paths) flatten(path[0])]))
    let (box=bounding_box(v))
    let (bx =  ceil(2*box[1].x-box[0].x))
    let (by =  ceil(2*box[1].y-box[0].y))
    str("<svg  xmlns='http://www.w3.org/2000/svg' version='1.1' ",
      " width='",bx,"mm'", " height='",by, "mm' ",
      " viewBox='", floor(box[0].x)," ",floor(box[0].y)," ", bx, " ",by,"'", ">",
    "<title>",name,"</title>","<g>",
    rstr(
     [for (path=paths)
         path_to_svg(path)
     ])
     ,"</g>","</svg>")
 ;  

Hopefully I'll get to do some actual cutting with this code soon. If anyone wants to try, my polyhedra generator http://kitwallace.co.uk/3d/solid-index.xq  now uses this code when generating a net.
Loading...