From f7db793c74fcba50ec3eced55e74b3b6581244d4 Mon Sep 17 00:00:00 2001 From: Chris Palmer Date: Wed, 4 Mar 2020 12:15:48 +0000 Subject: [PATCH] Assembly module search in views.py now case insensitive allowing the module name string to specify the capitalisaing used in the build instructions. --- printed/psu_shroud.scad | 2 +- printed/ssr_shroud.scad | 2 +- scripts/views.py | 15 +++++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/printed/psu_shroud.scad b/printed/psu_shroud.scad index 53d02f9..a7c1eb2 100644 --- a/printed/psu_shroud.scad +++ b/printed/psu_shroud.scad @@ -143,7 +143,7 @@ module psu_shroud(type, cable_d, name, cables = 1) { //! Generate the STL file f } module psu_shroud_assembly(type, cable_d, name, cables = 1) //! The printed parts with inserts fitted -assembly(str("psu_shroud_", name)) { +assembly(str("PSU_shroud_", name)) { translate_z(psu_shroud_height(type)) vflip() diff --git a/printed/ssr_shroud.scad b/printed/ssr_shroud.scad index 156f9a7..6dab709 100644 --- a/printed/ssr_shroud.scad +++ b/printed/ssr_shroud.scad @@ -107,7 +107,7 @@ module ssr_shroud(type, cable_d, name) { //! Generate the STL file for a spec } module ssr_shroud_assembly(type, cable_d, name) //! The printed parts with inserts fitted -assembly(str("ssr_shroud_", name)) { +assembly(str("SSR_shroud_", name)) { translate_z(ssr_shroud_height(type)) vflip() diff --git a/scripts/views.py b/scripts/views.py index c4740fc..bf82868 100755 --- a/scripts/views.py +++ b/scripts/views.py @@ -117,9 +117,10 @@ def views(target, do_assemblies = None): with open(bounds_fname) as json_file: bounds_map = json.load(json_file) # - # Find all the assemblies + # Find all the assemblies and remove any old views # assemblies = bom_to_assemblies(bom_dir, bounds_map) + lc_assemblies = [ass.lower() for ass in assemblies] for file in os.listdir(target_dir): if file.endswith('.png'): assembly = file[:-4].replace('_assembled', '_assembly') @@ -148,22 +149,24 @@ def views(target, do_assemblies = None): if len(words) and words[0] == "module": module = words[1].split('(')[0] if is_assembly(module): - if module in assemblies: + lc_module = module.lower() + if lc_module in lc_assemblies: + real_name = assemblies[lc_assemblies.index(lc_module)] # # Scrape the assembly instructions # for ass in flat_bom: - if ass["name"] == module: + if ass["name"] == real_name: if not "blurb" in ass: ass["blurb"] = blurb.scrape_module_blurb(lines[:line_no]) break - if not do_assemblies or module in do_assemblies: + if not do_assemblies or real_name in do_assemblies: # # Run openscad on the created file # dname = deps_name(deps_dir, filename) for explode in [0, 1]: - png_name = target_dir + '/' + module + '.png' + png_name = target_dir + '/' + real_name + '.png' if not explode: png_name = png_name.replace('_assembly', '_assembled') changed = check_deps(png_name, dname) @@ -189,7 +192,7 @@ def views(target, do_assemblies = None): if mtime(png_name) > mtime(tn_name): do_cmd(("magick "+ png_name + " -trim -resize 280x280 -background " + background + " -gravity Center -extent 280x280 -bordercolor " + background + " -border 10 " + tmp_name).split()) update_image(tmp_name, tn_name) - done_assemblies.append(module) + done_assemblies.append(real_name) else: if module == 'main_assembly': main_blurb = blurb.scrape_module_blurb(lines[:line_no])