Index: trunk/src_plugins/export_openscad/export_openscad.c =================================================================== --- trunk/src_plugins/export_openscad/export_openscad.c (revision 37241) +++ trunk/src_plugins/export_openscad/export_openscad.c (revision 37242) @@ -2,7 +2,7 @@ * COPYRIGHT * * pcb-rnd, interactive printed circuit board design - * Copyright (C) 2017,2020 Tibor 'Igor2' Palinkas + * Copyright (C) 2017,2020,2023 Tibor 'Igor2' Palinkas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -81,6 +81,7 @@ static const char *scad_group_color; static int scad_layer_cnt; static vti0_t scad_comp; +static char *scad_prefix = "pcb"; static rnd_hid_attr_val_t *openscad_options; @@ -218,7 +219,7 @@ int id = scad_comp.array[n], is_pos = id > 0; if (id < 0) id = -id; - fprintf(f, " layer_%s_%s_%d();\n", scad_group_name, is_pos ? "pos" : "neg", id); + fprintf(f, " %s_layer_%s_%s_%d();\n", scad_prefix , scad_group_name, is_pos ? "pos" : "neg", id); if ((n > 0) && (n < vti0_len(&scad_comp)-1)) { int id2 = scad_comp.array[n+1]; int p1 = is_pos, p2 = (id2 > 0); @@ -237,11 +238,11 @@ static void scad_close_layer_group() { if (scad_group_name != NULL) { - fprintf(f, "module layer_group_%s() {\n", scad_group_name); + fprintf(f, "module %s_layer_group_%s() {\n", scad_prefix, scad_group_name); scad_dump_comp(); fprintf(f, "}\n\n"); - rnd_append_printf(&layer_group_calls, " layer_group_%s();\n", scad_group_name); + rnd_append_printf(&layer_group_calls, " %s_layer_group_%s();\n", scad_prefix, scad_group_name); scad_group_name = NULL; scad_group_color = NULL; scad_group_level = 0; @@ -278,7 +279,7 @@ h -= effective_layer_thickness/2.0; effective_layer_thickness+=1.0; } - fprintf(f, "module layer_%s_%s_%d() {\n", scad_group_name, is_pos ? "pos" : "neg", scad_layer_cnt); + fprintf(f, "module %s_layer_%s_%s_%d() {\n", scad_prefix, scad_group_name, is_pos ? "pos" : "neg", scad_layer_cnt); fprintf(f, " color([%s])\n", scad_group_color); fprintf(f, " translate([0,0,%f]) {\n", h); layer_open = 1; @@ -493,7 +494,7 @@ TRX(x2); TRY(y2); fix_rect_coords(); - rnd_fprintf(f, " pcb_fill_rect(%mm, %mm, %mm, %mm, %f, %f);\n", + rnd_fprintf(f, " %s_fill_rect(%mm, %mm, %mm, %mm, %f, %f);\n", scad_prefix, x1, y1, x2, y2, 0.0, effective_layer_thickness); } @@ -513,7 +514,7 @@ else cap_style = "rc"; - rnd_fprintf(f, " pcb_line_%s(%mm, %mm, %mm, %f, %mm, %f);\n", cap_style, + rnd_fprintf(f, " %s_line_%s(%mm, %mm, %mm, %f, %mm, %f);\n", scad_prefix, cap_style, x1, y1, (rnd_coord_t)rnd_round(length), angle * RND_RAD_TO_DEG, gc->width, effective_layer_thickness); } @@ -567,13 +568,13 @@ { TRX(cx); TRY(cy); - rnd_fprintf(f, " pcb_fcirc(%mm, %mm, %mm, %f);\n", cx, cy, radius, effective_layer_thickness); + rnd_fprintf(f, " %s_fcirc(%mm, %mm, %mm, %f);\n", scad_prefix, cx, cy, radius, effective_layer_thickness); } static void openscad_fill_polygon_offs(rnd_hid_gc_t gc, int n_coords, rnd_coord_t *x, rnd_coord_t *y, rnd_coord_t dx, rnd_coord_t dy) { int n; - fprintf(f, " pcb_fill_poly(["); + fprintf(f, " %s_fill_poly([", scad_prefix); for(n = 0; n < n_coords-1; n++) rnd_fprintf(f, "[%mm,%mm],", TRX_(x[n]+dx), TRY_(y[n]+dy)); rnd_fprintf(f, "[%mm,%mm]], %f);\n", TRX_(x[n]+dx), TRY_(y[n]+dy), effective_layer_thickness); Index: trunk/src_plugins/export_openscad/scad_draw.c =================================================================== --- trunk/src_plugins/export_openscad/scad_draw.c (revision 37241) +++ trunk/src_plugins/export_openscad/scad_draw.c (revision 37242) @@ -38,7 +38,7 @@ static void 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, "module %s_line_rc(x1, y1, length, angle, width, thick) {\n", scad_prefix); fprintf(f, " translate([x1,y1,0]) {\n"); fprintf(f, " rotate([0,0,angle]) {\n"); fprintf(f, " translate([length/2, 0, 0])\n"); @@ -51,7 +51,7 @@ fprintf(f, "}\n"); fprintf(f, "// Square cap line\n"); - fprintf(f, "module pcb_line_sc(x1, y1, length, angle, width, thick) {\n"); + fprintf(f, "module %s_line_sc(x1, y1, length, angle, width, thick) {\n", scad_prefix); fprintf(f, " translate([x1,y1,0]) {\n"); fprintf(f, " rotate([0,0,angle]) {\n"); fprintf(f, " translate([length/2, 0, 0])\n"); @@ -61,7 +61,7 @@ fprintf(f, "}\n"); fprintf(f, "// filled rectangle\n"); - fprintf(f, "module pcb_fill_rect(x1, y1, x2, y2, angle, thick) {\n"); + fprintf(f, "module %s_fill_rect(x1, y1, x2, y2, angle, thick) {\n", scad_prefix); fprintf(f, " translate([(x1+x2)/2,(y1+y2)/2,0])\n"); fprintf(f, " rotate([0,0,angle])\n"); fprintf(f, " cube([x2-x1, y2-y1, thick], center=true);\n"); @@ -68,13 +68,13 @@ fprintf(f, "}\n"); fprintf(f, "// filled polygon\n"); - fprintf(f, "module pcb_fill_poly(coords, thick) {\n"); + fprintf(f, "module %s_fill_poly(coords, thick) {\n", scad_prefix); fprintf(f, " linear_extrude(height=thick)\n"); fprintf(f, " polygon(coords);\n"); fprintf(f, "}\n"); fprintf(f, "// filled circle\n"); - fprintf(f, "module pcb_fcirc(x1, y1, radius, thick) {\n"); + fprintf(f, "module %s_fcirc(x1, y1, radius, thick) {\n", scad_prefix); fprintf(f, " translate([x1,y1,0])\n"); fprintf(f, " cylinder(r=radius, h=thick, center=true, $fn=30);\n"); fprintf(f, "}\n"); @@ -88,7 +88,7 @@ if (poly == NULL) return -1; - fprintf(f, "module pcb_outline() {\n"); + fprintf(f, "module %s_outline() {\n", scad_prefix); fprintf(f, " polygon([\n\t\t"); /* we need the as-drawn polygon and we know there are no holes */ for(n = 0; n < poly->PointN; n++) @@ -126,7 +126,7 @@ switch(mech->shape) { case PCB_PSSH_POLY: fprintf(f, " translate([0,0,%f])\n", -effective_layer_thickness/2); - fprintf(f, " pcb_fill_poly(["); + fprintf(f, " %s_fill_poly([", scad_prefix); for(n = 0; n < mech->data.poly.len; n++) rnd_fprintf(f, "%s[%mm,%mm]", (n > 0 ? ", " : ""), TRX_(ps->x + mech->data.poly.x[n]), @@ -153,7 +153,7 @@ rnd_rtree_it_t it; rnd_box_t *obj; - fprintf(f, "module pcb_drill() {\n"); + fprintf(f, "module %s_drill() {\n", scad_prefix); for(obj = rnd_r_first(PCB->Data->padstack_tree, &it); obj != NULL; obj = rnd_r_next(&it)) scad_draw_pstk((pcb_pstk_t *)obj); @@ -163,24 +163,24 @@ static void scad_draw_finish(rnd_hid_attr_val_t *options) { - fprintf(f, "module pcb_board_main() {\n"); + 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, " pcb_outline();\n"); + fprintf(f, " %s_outline();\n", scad_prefix); fprintf(f, "%s", layer_group_calls.array); fprintf(f, "}\n"); fprintf(f, "\n"); - fprintf(f, "module pcb_board() {\n"); + 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, " pcb_outline();\n"); + fprintf(f, " %s_outline();\n", scad_prefix); fprintf(f, " union() {\n"); fprintf(f, " difference() {\n"); - fprintf(f, " pcb_board_main();\n"); + fprintf(f, " %s_board_main();\n", scad_prefix); if (options[HA_drill].lng) - fprintf(f, " pcb_drill();\n"); + fprintf(f, " %s_drill();\n", scad_prefix); fprintf(f, " }\n"); fprintf(f, " }\n"); fprintf(f, " }\n"); @@ -188,5 +188,5 @@ fprintf(f, "}\n"); fprintf(f, "\n"); - fprintf(f, "pcb_board();\n"); + fprintf(f, "%s_board();\n", scad_prefix); } Index: trunk/src_plugins/export_openscad/scad_models.c =================================================================== --- trunk/src_plugins/export_openscad/scad_models.c (revision 37241) +++ trunk/src_plugins/export_openscad/scad_models.c (revision 37242) @@ -55,7 +55,7 @@ while(isspace(*mod)) mod++; if (!isalpha(*mod) && (*mod != '_')) rnd_message(RND_MSG_ERROR, "Openscad model '%s': module name must be in the same line as the module keyword\n", full_path); - fprintf(f, " pcb_part_%s", safe_name); + fprintf(f, " %s_part_%s", scad_prefix, safe_name); par = strchr(mod, '('); if (par != NULL) fprintf(f, "%s", par); @@ -71,7 +71,7 @@ fprintf(f, "%s", buff); } fclose(fin); - rnd_snprintf(buff, sizeof(buff), "pcb_part_%s", safe_name); + rnd_snprintf(buff, sizeof(buff), "%s_part_%s", scad_prefix, safe_name); htsp_set(models, (char *)name, rnd_strdup(buff)); free(safe_name); }