Index: trunk/src_plugins/export_openscad/export_openscad.c =================================================================== --- trunk/src_plugins/export_openscad/export_openscad.c (revision 37244) +++ trunk/src_plugins/export_openscad/export_openscad.c (revision 37245) @@ -82,6 +82,7 @@ static int scad_layer_cnt; static vti0_t scad_comp; static const char *scad_prefix = "pcb"; +static double board_thickness = 1.6; static rnd_hid_attr_val_t *openscad_options; @@ -269,17 +270,17 @@ if (is_pos) { effective_layer_thickness = layer_thickness; if (scad_group_level > 0) - h = 0.8+((double)scad_group_level*1.1) * effective_layer_thickness; + h = board_thickness/2.0+((double)scad_group_level*1.1) * effective_layer_thickness; else - h = -0.8+((double)scad_group_level*1.1) * effective_layer_thickness; + h = -board_thickness/2.0+((double)scad_group_level*1.1) * effective_layer_thickness; } else { double mult = 2.0; effective_layer_thickness = layer_thickness * mult; if (scad_group_level > 0) - h = 0.8+((double)scad_group_level*1.1) * layer_thickness; + h = board_thickness/2.0+((double)scad_group_level*1.1) * layer_thickness; else - h = -0.8+((double)scad_group_level*1.1) * layer_thickness; + h = -board_thickness/2.0+((double)scad_group_level*1.1) * layer_thickness; h -= effective_layer_thickness/2.0; effective_layer_thickness+=1.0; } @@ -320,6 +321,19 @@ scad_prefix = options[HA_prefix].str; if (scad_prefix == NULL) scad_prefix = "pcb"; + + { + rnd_layergrp_id_t from = 0, to = 0; + + pcb_layergrp_list(PCB, PCB_LYT_BOTTOM|PCB_LYT_COPPER, &from, 1); + pcb_layergrp_list(PCB, PCB_LYT_TOP|PCB_LYT_COPPER, &to, 1); + + if (from != to) + board_thickness = RND_COORD_TO_MM(pcb_stack_thickness(PCB, "openscad", PCB_BRDTHICK_PRINT_ERROR, from, 1, to, 0, PCB_LYT_SUBSTRATE|PCB_LYT_COPPER)); + else + board_thickness = 1.6; + } + pcb_cam_begin_nolayer(PCB, &cam, NULL, options[HA_cam].str, &filename); f = rnd_fopen_askovr(&PCB->hidlib, filename, "wb", NULL); Index: trunk/src_plugins/export_openscad/scad_draw.c =================================================================== --- trunk/src_plugins/export_openscad/scad_draw.c (revision 37244) +++ trunk/src_plugins/export_openscad/scad_draw.c (revision 37245) @@ -164,8 +164,8 @@ static void scad_draw_finish(rnd_hid_attr_val_t *options) { fprintf(f, "module %s_board_main() {\n", scad_prefix); - fprintf(f, " translate ([0, 0, -0.8])\n"); - fprintf(f, " linear_extrude(height=1.6)\n"); + fprintf(f, " translate ([0, 0, -%f])\n", board_thickness/2); + fprintf(f, " linear_extrude(height=%f)\n", board_thickness); fprintf(f, " %s_outline();\n", scad_prefix); fprintf(f, "%s", layer_group_calls.array); fprintf(f, "}\n"); @@ -173,8 +173,8 @@ fprintf(f, "module %s_board() {\n", scad_prefix); fprintf(f, " intersection() {\n"); - fprintf(f, " translate ([0, 0, -4])\n"); - fprintf(f, " linear_extrude(height=8)\n"); + fprintf(f, " translate ([0, 0, -%d])\n", (int)(board_thickness+1)*2); + fprintf(f, " linear_extrude(height=%d)\n", (int)(board_thickness+1)*4); fprintf(f, " %s_outline();\n", scad_prefix); fprintf(f, " union() {\n"); fprintf(f, " difference() {\n"); Index: trunk/src_plugins/export_openscad/scad_models.c =================================================================== --- trunk/src_plugins/export_openscad/scad_models.c (revision 37244) +++ trunk/src_plugins/export_openscad/scad_models.c (revision 37245) @@ -84,7 +84,7 @@ if (ref != NULL) { char tab[] = "\t\t\t\t\t\t\t\t"; int ind = 0; - rnd_append_printf(&model_calls, " translate([%mm,%mm,%c0.8])\n", x0, y0, on_bottom ? '-' : '+'); + rnd_append_printf(&model_calls, " translate([%mm,%mm,%f])\n", x0, y0, on_bottom ? -board_thickness/2.0 : +board_thickness/2.0); ind++; tab[ind] = '\0';