diff --git a/scripts/bom.py b/scripts/bom.py index b359584..06b89d6 100755 --- a/scripts/bom.py +++ b/scripts/bom.py @@ -82,7 +82,7 @@ class BOM: def add_part(self, s): args = [] - match = re.match(r'^(.*?\.stl)\((.*)\)$', s) #look for name.stl(...) + match = re.match(r'^(.*?\.stl|.*?\.dxf)\((.*)\)$', s) #look for name.stl(...) or name.dxf(...) if match: s = match.group(1) args = [match.group(2)] diff --git a/scripts/render.py b/scripts/render.py index 160551e..9e35938 100755 --- a/scripts/render.py +++ b/scripts/render.py @@ -81,7 +81,8 @@ def render(target, type): # if mtime(part_file) > mtime(png_name): png_maker_name = "png.scad" - colour = [0, 146/255, 0] + pp1 = [0, 146/255, 0] + colour = pp1 if part in colours: colour = colours[part] if not '[' in colour: @@ -89,7 +90,7 @@ def render(target, type): with open(png_maker_name, "w") as f: f.write('color(%s) import("%s");\n' % (colour, part_file)) cam = "--camera=0,0,0,70,0,315,500" if type == 'stl' else "--camera=0,0,0,0,0,0,500" - render = "--preview" if type == 'stl' else "--render" + render = "--preview" if type == 'stl' or colour != pp1 else "--render" tmp_name = 'tmp.png' openscad.run(colour_scheme, "--projection=p", "--imgsize=4096,4096", cam, render, "--autocenter", "--viewall", "-o", tmp_name, png_maker_name); do_cmd(("magick "+ tmp_name + " -trim -resize 280x280 -background %s -gravity Center -extent 280x280 -bordercolor %s -border 10 %s" diff --git a/utils/core/bom.scad b/utils/core/bom.scad index d19f142..b8e3ca4 100644 --- a/utils/core/bom.scad +++ b/utils/core/bom.scad @@ -107,7 +107,7 @@ module stl_colour(colour = pp1_colour, alpha = 1) { //! Colour an stl where it i children(); } -module stl(name) { //! Name an stl that will appear on the BOM, there needs to a module named ```_stl``` to make it +module stl(name) { //! Name an stl that will appear on the BOM, there needs to a module named ```_stl``` to make it if(bom_mode()) { colour = is_undef($stl_colour) ? pp1_colour : $stl_colour; echo(str("~", name, ".stl(colour='", colour, "')")); @@ -115,8 +115,12 @@ module stl(name) { //! Name an stl that will appear on the BOM, there needs to a } module dxf(name) { //! Name a dxf that will appear on the BOM, there needs to a module named ```_dxf``` to make it - if(bom_mode()) - echo(str("~", name, ".dxf")); + if(bom_mode()) { + if(is_undef($dxf_colour)) + echo(str("~", name, ".dxf")); + else + echo(str("~", name, ".dxf(colour='", $dxf_colour, "')")); + } } function value_string(value) = is_string(value) ? str("\"", value, "\"") : str(value); //! Convert ```value``` to a string or quote it if it is already a string diff --git a/vitamins/sheet.scad b/vitamins/sheet.scad index 5225139..8ec5d43 100644 --- a/vitamins/sheet.scad +++ b/vitamins/sheet.scad @@ -83,6 +83,7 @@ module render_sheet(type, colour = false) //! Render a sheet in the correct colo render() children(); module render_2D_sheet(type, colour = false) //! Extrude a 2D sheet template and give it the correct colour - color(colour ? colour : sheet_colour(type)) - linear_extrude(sheet_thickness(type), center = true) - children(); + let($dxf_colour = colour ? colour : sheet_colour(type)) + color($dxf_colour) + linear_extrude(sheet_thickness(type), center = true) + children();