Index: trunk/src_plugins/export_openscad/export_openscad.c =================================================================== --- trunk/src_plugins/export_openscad/export_openscad.c (revision 11200) +++ trunk/src_plugins/export_openscad/export_openscad.c (revision 11201) @@ -30,11 +30,13 @@ #include #include -#include "math_helper.h" +#include "compat_misc.h" #include "board.h" #include "data.h" #include "error.h" #include "layer.h" +#include "math_helper.h" +#include "misc_util.h" #include "plugins.h" #include "hid.h" @@ -149,6 +151,8 @@ pcb_hid_save_and_show_layer_ons(save_ons); + scad_draw_primitives(); + openscad_hid_export_to_file(f, options); scad_draw_drills(); @@ -186,6 +190,9 @@ if (flags & PCB_LYT_UDRILL) return 0; + if (flags & PCB_LYT_SILK) + return 1; + return 0; } @@ -270,7 +277,13 @@ static void openscad_draw_line(pcb_hid_gc_t gc, pcb_coord_t x1, pcb_coord_t y1, pcb_coord_t x2, pcb_coord_t y2) { - TRX(x1); TRY(y1); TRX(x2); TRY(y2); + double length, angle; + + length = pcb_distance(x1, y1, x2, y2); + angle = atan2((double)y2-y1, (double)x2-x1); + + pcb_fprintf(f, " pcb_line_rc(%mm, %mm, %mm, %f, %mm, 0.1);\n", + x1, y1, (pcb_coord_t)pcb_round(length), angle * PCB_RAD_TO_DEG, gc->width); } static void openscad_draw_arc(pcb_hid_gc_t gc, pcb_coord_t cx, pcb_coord_t cy, pcb_coord_t width, pcb_coord_t height, pcb_angle_t start_angle, pcb_angle_t delta_angle) Index: trunk/src_plugins/export_openscad/scad_draw.c =================================================================== --- trunk/src_plugins/export_openscad/scad_draw.c (revision 11200) +++ trunk/src_plugins/export_openscad/scad_draw.c (revision 11201) @@ -1,12 +1,24 @@ #include "../lib_polyhelp/topoly.h" - #define TRX(x) -#define TRY(y) \ -do { \ - y = PCB->MaxHeight - y; \ -} while(0) +#define TRY(y) y = (PCB->MaxHeight - (y)) +static scad_draw_primitives(void) +{ + fprintf(f, "// Round cap line\n"); + fprintf(f, "module pcb_line_rc(x1, y1, length, angle, width, thick) {\n"); + fprintf(f, " translate([x1,y1,0]) {\n"); + fprintf(f, " rotate([0,0,angle]) {\n"); + fprintf(f, " translate([length/2, 0, 0])\n"); + fprintf(f, " cube([length,width, thick], center=true);\n"); + fprintf(f, " cylinder(r=width/2, h=thick, center=true, $fn=30);\n"); + fprintf(f, " translate([length, 0, 0])\n"); + fprintf(f, " cylinder(r=width/2, h=thick, center=true, $fn=30);\n"); + fprintf(f, " }\n"); + fprintf(f, " }\n"); + fprintf(f, "}\n"); +} + static int scad_draw_outline(void) { pcb_any_obj_t *start = pcb_topoly_find_1st_outline(PCB);