Index: trunk/doc/developer/packaging/Changelog =================================================================== --- trunk/doc/developer/packaging/Changelog (revision 28464) +++ trunk/doc/developer/packaging/Changelog (revision 28465) @@ -9,6 +9,7 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TODO: - export_gcode doesn't depend on libgd + - export_gcode depends on plugin millpath A. changes that probably don't need action Index: trunk/scconfig/plugins.h =================================================================== --- trunk/scconfig/plugins.h (revision 28464) +++ trunk/scconfig/plugins.h (revision 28465) @@ -94,6 +94,7 @@ plugin_def("export_excellon", "Excellon drill exporter", sbuildin, 1, 0) plugin_def("export_fidocadj", "FidoCadJ .fcd pcb_exporter", sbuildin, 1, 0) plugin_def("export_gcode", "gcode pcb_exporter", sbuildin, 1, 0) +plugin_def("export_gcode", "gcode pcb_exporter", sbuildin, 1, 0) plugin_def("export_gerber", "Gerber pcb_exporter", sbuildin, 1, 0) plugin_def("export_ipcd356", "IPC-D-356 Netlist pcb_exporter", sbuildin, 1, 0) plugin_def("export_lpr", "lpr pcb_exporter (printer)", sbuildin, 1, 0) @@ -141,6 +142,7 @@ plugin_dep("dialogs", "lib_hid_pcbui", 0) plugin_dep("draw_fab", "report", 0) plugin_dep("export_fidocadj", "lib_compat_help", 0) +plugin_dep("export_gcode", "millpath", 0) plugin_dep("export_gerber", "export_excellon", 0) plugin_dep("export_ipcd356", "lib_compat_help", 0) plugin_dep("export_lpr", "export_ps", 0) Index: trunk/src_plugins/export_gcode/export_gcode.pup =================================================================== --- trunk/src_plugins/export_gcode/export_gcode.pup (revision 28464) +++ trunk/src_plugins/export_gcode/export_gcode.pup (revision 28465) @@ -6,4 +6,5 @@ $fmt-feature-w export gcode (for milling) $package export default buildin +dep millpath autoload 1 Index: trunk/src_plugins/export_gcode/gcode.c =================================================================== --- trunk/src_plugins/export_gcode/gcode.c (revision 28464) +++ trunk/src_plugins/export_gcode/gcode.c (revision 28465) @@ -39,6 +39,8 @@ #include "hid_attrib.h" #include "hid_cam.h" +#include "../src_plugins/millpath/toolpath.h" + const char *pcb_export_gcode_cookie = "export_gcode plugin"; static pcb_hid_t gcode_hid; @@ -51,6 +53,8 @@ static gcode_t gctx; +static const char def_layer_script[] = "setup_negative; trace_contour; fix_overcuts"; +static const char def_mech_script[] = "setup_positive; trace_contour; fix_overcuts"; pcb_export_opt_t gcode_attribute_list[] = { {"outfile", "file name prefix for non-cam", @@ -62,11 +66,11 @@ #define HA_template 1 {"layer-script", "rendering script for layer graphics", - PCB_HATT_STRING, 0, 0, {0, 0, 0}, 0, 0}, + PCB_HATT_STRING, 0, 0, {0, def_layer_script, 0}, 0, 0}, #define HA_layer_script 2 {"mech-script", "rendering script for boundary/mech/drill", - PCB_HATT_STRING, 0, 0, {0, 0, 0}, 0, 0}, + PCB_HATT_STRING, 0, 0, {0, def_mech_script, 0}, 0, 0}, #define HA_mech_script 3 {"cam", "CAM instruction", @@ -86,10 +90,39 @@ return gcode_attribute_list; } +static gcode_print_lines(pcb_tlp_session_t *tctx, pcb_layergrp_t *grp) +{ + pcb_line_t *line; + gdl_iterator_t it; + pcb_coord_t lastx = PCB_MAX_COORD, lasty = PCB_MAX_COORD; + + if (tctx->res_path->Line.lst.length == 0) { + pcb_fprintf(gctx.f, "# empty layer group: %s\n", grp->name); + return; + } + + linelist_foreach(&tctx->res_path->Line, &it, line) { + if ((lastx != line->Point1.X) && (lasty != line->Point1.Y)) + pcb_fprintf(gctx.f, "G0 X%mm Y%mm\n", line->Point1.X, line->Point1.Y); + pcb_fprintf(gctx.f, "G1 X%mm Y%mm\n", line->Point2.X, line->Point2.Y); + lastx = line->Point2.X; + lasty = line->Point2.Y; + } +} + static void gcode_export_layer_group(pcb_layergrp_id_t group, const char *purpose, int purpi, pcb_layer_id_t layer, unsigned int flags, pcb_xform_t **xform) { int script_ha; + const char *script; + pcb_layergrp_t *grp = &gctx.pcb->LayerGroups.grp[group]; + static pcb_tlp_session_t tctx; + static pcb_coord_t tool_dias[] = { + PCB_MM_TO_COORD(0.2), + PCB_MM_TO_COORD(3) + }; + static pcb_tlp_tools_t tools = { sizeof(tool_dias)/sizeof(tool_dias[0]), tool_dias}; + if (flags & PCB_LYT_UI) return; @@ -122,12 +155,25 @@ if (gctx.f == NULL) return; - if (PCB_LAYER_IS_ROUTE(flags, purpi) || PCB_LAYER_IS_DRILL(flags, purpi)) + if (PCB_LAYER_IS_ROUTE(flags, purpi) || PCB_LAYER_IS_DRILL(flags, purpi)) { script_ha = HA_layer_script; - else + script = def_layer_script; + } + else { script_ha = HA_mech_script; + script = def_mech_script; + } + if (gcode_values[script_ha].str != NULL) + script = gcode_values[script_ha].str; + memset(&tctx, 0, sizeof(tctx)); + tctx.edge_clearance = PCB_MM_TO_COORD(0.05); + tctx.tools = &tools; + pcb_tlp_mill_script(gctx.pcb, &tctx, grp, script); + + gcode_print_lines(&tctx, grp); + if (!gctx.cam.active) fclose(gctx.f); }