Index: trunk/src_plugins/export_openscad/scad_draw.c =================================================================== --- trunk/src_plugins/export_openscad/scad_draw.c (revision 28509) +++ trunk/src_plugins/export_openscad/scad_draw.c (revision 28510) @@ -80,22 +80,11 @@ static int scad_draw_outline(void) { - pcb_any_obj_t *start = pcb_topoly_find_1st_outline(PCB); - pcb_poly_t *poly; + pcb_poly_t *poly = pcb_topoly_1st_outline(PCB); int n; - if (start == NULL) { - poly = pcb_poly_alloc(PCB->Data->Layer); - pcb_poly_point_new(poly, 0, 0); - pcb_poly_point_new(poly, PCB->hidlib.size_x, 0); - pcb_poly_point_new(poly, PCB->hidlib.size_x, PCB->hidlib.size_y); - pcb_poly_point_new(poly, 0, PCB->hidlib.size_y); - } - else { - poly = pcb_topoly_conn(PCB, start, PCB_TOPOLY_FLOATING); - if (poly == NULL) - return -1; - } + if (poly == NULL) + return -1; fprintf(f, "module pcb_outline() {\n"); fprintf(f, " polygon([\n\t\t"); Index: trunk/src_plugins/lib_polyhelp/topoly.c =================================================================== --- trunk/src_plugins/lib_polyhelp/topoly.c (revision 28509) +++ trunk/src_plugins/lib_polyhelp/topoly.c (revision 28510) @@ -314,6 +314,24 @@ } #undef check +pcb_poly_t *pcb_topoly_1st_outline(pcb_board_t *pcb) +{ + pcb_poly_t *poly; + pcb_any_obj_t *start = pcb_topoly_find_1st_outline(pcb); + + if (start == NULL) { + poly = pcb_poly_alloc(pcb->Data->Layer); + pcb_poly_point_new(poly, 0, 0); + pcb_poly_point_new(poly, pcb->hidlib.size_x, 0); + pcb_poly_point_new(poly, pcb->hidlib.size_x, pcb->hidlib.size_y); + pcb_poly_point_new(poly, 0, pcb->hidlib.size_y); + } + else + poly = pcb_topoly_conn(pcb, start, PCB_TOPOLY_FLOATING); + + return poly; +} + const char pcb_acts_topoly[] = "ToPoly()\nToPoly(outline)\n"; const char pcb_acth_topoly[] = "convert a closed loop of lines and arcs into a polygon"; fgw_error_t pcb_act_topoly(fgw_arg_t *res, int argc, fgw_arg_t *argv) Index: trunk/src_plugins/lib_polyhelp/topoly.h =================================================================== --- trunk/src_plugins/lib_polyhelp/topoly.h (revision 28509) +++ trunk/src_plugins/lib_polyhelp/topoly.h (revision 28510) @@ -43,7 +43,10 @@ /* Find the first line/arc on the outline layer from top-left */ pcb_any_obj_t *pcb_topoly_find_1st_outline(pcb_board_t *pcb); +/* Construct apolygon of the first line/arc on the outline layer from top-left */ +pcb_poly_t *pcb_topoly_1st_outline(pcb_board_t *pcb); + extern const char pcb_acts_topoly[]; extern const char pcb_acth_topoly[]; fgw_error_t pcb_act_topoly(fgw_arg_t *ores, int oargc, fgw_arg_t *oargv);