1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-09-05 13:02:35 +02:00

Compare commits

..

9 Commits

Author SHA1 Message Date
Chris Palmer
8649d59e8a Merge branch 'martinbudden-print_search_path' 2020-02-25 00:05:12 +00:00
Chris Palmer
e9bc300b8d Fix for printed directory not present. 2020-02-24 23:58:22 +00:00
Chris Palmer
dcb1e74894 Merge branch 'print_search_path' of https://github.com/martinbudden/NopSCADlib into martinbudden-print_search_path 2020-02-24 19:02:50 +00:00
Chris Palmer
42b9479094 Merge branch 'martinbudden-tnuts_and_hammer_nuts' 2020-02-24 18:37:40 +00:00
Chris Palmer
f46f35e909 Updated readme 2020-02-24 18:37:25 +00:00
Chris Palmer
0513b151b2 Merge branch 'tnuts_and_hammer_nuts' of https://github.com/martinbudden/NopSCADlib into martinbudden-tnuts_and_hammer_nuts 2020-02-24 18:22:05 +00:00
Chris Palmer
dcf258f11a Brass colour now distinct from gold. 2020-02-24 18:15:20 +00:00
Martin Budden
4ff6c7d0a8 Unified tnuts and hammer nuts. 2020-02-24 17:40:39 +00:00
Martin Budden
ad3e8d85af Added scad/printed to stl search path. 2020-02-23 17:54:28 +00:00
31 changed files with 119 additions and 128 deletions

View File

@@ -60,7 +60,8 @@ grey60 = [0.6, 0.6, 0.6];
grey70 = [0.7, 0.7, 0.7]; grey70 = [0.7, 0.7, 0.7];
grey80 = [0.8, 0.8, 0.8]; grey80 = [0.8, 0.8, 0.8];
grey90 = [0.9, 0.9, 0.9]; grey90 = [0.9, 0.9, 0.9];
brass = [255/255, 215/255, 0/255]; gold = [255/255, 215/255, 0/255];
brass = [255/255, 220/255, 100/255];
silver = [0.75, 0.75, 0.75]; silver = [0.75, 0.75, 0.75];
/* /*

View File

@@ -1623,12 +1623,12 @@ If a nut is given a child then it gets placed on its top surface.
| 1 | ```nut(M2p5_nut)``` | Nut M2.5 x 2.2mm | | 1 | ```nut(M2p5_nut)``` | Nut M2.5 x 2.2mm |
| 1 | ```nut(M2p5_nut, nyloc = true)``` | Nut M2.5 x 2.2mm nyloc | | 1 | ```nut(M2p5_nut, nyloc = true)``` | Nut M2.5 x 2.2mm nyloc |
| 1 | ```nut(M2p5_nut, nylon = true)``` | Nut M2.5 x 2.2mm nylon | | 1 | ```nut(M2p5_nut, nylon = true)``` | Nut M2.5 x 2.2mm nylon |
| 1 | ```hammer_nut(M3_hammer_nut)``` | Nut M3 hammer | | 1 | ```sliding_t_nut(M3_hammer_nut)``` | Nut M3 hammer |
| 1 | ```sliding_t_nut(M3_sliding_t_nut)``` | Nut M3 sliding T | | 1 | ```sliding_t_nut(M3_sliding_t_nut)``` | Nut M3 sliding T |
| 1 | ```nut(M3_nut)``` | Nut M3 x 2.4mm | | 1 | ```nut(M3_nut)``` | Nut M3 x 2.4mm |
| 1 | ```nut(M3_nut, brass = true)``` | Nut M3 x 2.4mm brass | | 1 | ```nut(M3_nut, brass = true)``` | Nut M3 x 2.4mm brass |
| 1 | ```nut(M3_nut, nyloc = true)``` | Nut M3 x 2.4mm nyloc | | 1 | ```nut(M3_nut, nyloc = true)``` | Nut M3 x 2.4mm nyloc |
| 1 | ```hammer_nut(M4_hammer_nut)``` | Nut M4 hammer | | 1 | ```sliding_t_nut(M4_hammer_nut)``` | Nut M4 hammer |
| 1 | ```sliding_t_nut(M4_sliding_t_nut)``` | Nut M4 sliding T | | 1 | ```sliding_t_nut(M4_sliding_t_nut)``` | Nut M4 sliding T |
| 1 | ```nut(M4_nut)``` | Nut M4 x 3.2mm | | 1 | ```nut(M4_nut)``` | Nut M4 x 3.2mm |
| 1 | ```nut(M4_nut, nyloc = true)``` | Nut M4 x 3.2mm nyloc | | 1 | ```nut(M4_nut, nyloc = true)``` | Nut M4 x 3.2mm nyloc |

View File

@@ -85,48 +85,49 @@ def make_parts(target, part_type, parts = None):
# #
lib_dir = os.environ['OPENSCADPATH'] + '/NopSCADlib/printed' lib_dir = os.environ['OPENSCADPATH'] + '/NopSCADlib/printed'
module_suffix = '_dxf' if part_type == 'svg' else '_' + part_type module_suffix = '_dxf' if part_type == 'svg' else '_' + part_type
for dir in [source_dir, lib_dir]: for dir in [source_dir, source_dir + '/printed', lib_dir]:
for filename in os.listdir(dir): if os.path.isdir(dir):
if filename[-5:] == ".scad": for filename in os.listdir(dir):
# if filename[-5:] == ".scad":
# find any modules ending in _<part_type> #
# # find any modules ending in _<part_type>
with open(dir + "/" + filename, "r") as f: #
for line in f.readlines(): with open(dir + "/" + filename, "r") as f:
words = line.split() for line in f.readlines():
if(len(words) and words[0] == "module"): words = line.split()
module = words[1].split('(')[0] if(len(words) and words[0] == "module"):
if module.endswith(module_suffix): module = words[1].split('(')[0]
base_name = module[:-4] if module.endswith(module_suffix):
part = base_name + '.' + part_type base_name = module[:-4]
if part in targets: part = base_name + '.' + part_type
# if part in targets:
# make a file to use the module #
# # make a file to use the module
part_maker_name = part_type + ".scad" #
with open(part_maker_name, "w") as f: part_maker_name = part_type + ".scad"
f.write("use <%s/%s>\n" % (dir, filename)) with open(part_maker_name, "w") as f:
f.write("%s();\n" % module); f.write("use <%s/%s>\n" % (dir, filename))
# f.write("%s();\n" % module);
# Run openscad on the created file #
# # Run openscad on the created file
part_file = target_dir + "/" + part #
dname = deps_name(deps_dir, filename) part_file = target_dir + "/" + part
changed = check_deps(part_file, dname) dname = deps_name(deps_dir, filename)
changed = times.check_have_time(changed, part) changed = check_deps(part_file, dname)
if part_type == 'stl' and not changed and not part in bounds_map: changed = times.check_have_time(changed, part)
changed = "No bounds" if part_type == 'stl' and not changed and not part in bounds_map:
if changed: changed = "No bounds"
print(changed) if changed:
t = time.time() print(changed)
openscad.run("-D$bom=1", "-d", dname, "-o", part_file, part_maker_name) t = time.time()
times.add_time(part, t) openscad.run("-D$bom=1", "-d", dname, "-o", part_file, part_maker_name)
if part_type == 'stl': times.add_time(part, t)
bounds = c14n_stl.canonicalise(part_file) if part_type == 'stl':
bounds_map[part] = bounds bounds = c14n_stl.canonicalise(part_file)
bounds_map[part] = bounds
targets.remove(part) targets.remove(part)
os.remove(part_maker_name) os.remove(part_maker_name)
# #
# Write new bounds file # Write new bounds file
# #

View File

@@ -124,66 +124,67 @@ def views(target, do_assemblies = None):
# #
main_blurb = None main_blurb = None
lib_dir = os.environ['OPENSCADPATH'] + '/NopSCADlib/printed' lib_dir = os.environ['OPENSCADPATH'] + '/NopSCADlib/printed'
for dir in [source_dir, lib_dir]: for dir in [source_dir, source_dir + '/printed', lib_dir]:
for filename in os.listdir(dir): if os.path.isdir(dir):
if filename.endswith('.scad'): for filename in os.listdir(dir):
# if filename.endswith('.scad'):
# find any modules with names ending in _assembly #
# # find any modules with names ending in _assembly
with open(dir + "/" + filename, "r") as f: #
lines = f.readlines() with open(dir + "/" + filename, "r") as f:
line_no = 0 lines = f.readlines()
for line in lines: line_no = 0
words = line.split() for line in lines:
if len(words) and words[0] == "module": words = line.split()
module = words[1].split('(')[0] if len(words) and words[0] == "module":
if is_assembly(module): module = words[1].split('(')[0]
if module in assemblies: if is_assembly(module):
# if module in assemblies:
# Scrape the assembly instructions
#
for ass in flat_bom:
if ass["name"] == module:
if not "blurb" in ass:
ass["blurb"] = blurb.scrape_module_blurb(lines[:line_no])
break
if not do_assemblies or module in do_assemblies:
# #
# make a file to use the module # Scrape the assembly instructions
# #
png_maker_name = 'png.scad' for ass in flat_bom:
with open(png_maker_name, "w") as f: if ass["name"] == module:
f.write("use <%s/%s>\n" % (dir, filename)) if not "blurb" in ass:
f.write("%s();\n" % module); ass["blurb"] = blurb.scrape_module_blurb(lines[:line_no])
# break
# Run openscad on the created file if not do_assemblies or module in do_assemblies:
# #
dname = deps_name(deps_dir, filename) # make a file to use the module
for explode in [0, 1]: #
png_name = target_dir + '/' + module + '.png' png_maker_name = 'png.scad'
if not explode: with open(png_maker_name, "w") as f:
png_name = png_name.replace('_assembly', '_assembled') f.write("use <%s/%s>\n" % (dir, filename))
changed = check_deps(png_name, dname) f.write("%s();\n" % module);
changed = times.check_have_time(changed, png_name) #
changed = options.have_changed(changed, png_name) # Run openscad on the created file
tmp_name = 'tmp.png' #
if changed: dname = deps_name(deps_dir, filename)
print(changed) for explode in [0, 1]:
t = time.time() png_name = target_dir + '/' + module + '.png'
openscad.run_list(options.list() + ["-D$pose=1", "-D$explode=%d" % explode, colour_scheme, "--projection=p", "--imgsize=4096,4096", "--autocenter", "--viewall", "-d", dname, "-o", tmp_name, png_maker_name]); if not explode:
times.add_time(png_name, t) png_name = png_name.replace('_assembly', '_assembled')
do_cmd(["magick", tmp_name, "-trim", "-resize", "1004x1004", "-bordercolor", background, "-border", "10", tmp_name]) changed = check_deps(png_name, dname)
update_image(tmp_name, png_name) changed = times.check_have_time(changed, png_name)
tn_name = png_name.replace('.png', '_tn.png') changed = options.have_changed(changed, png_name)
if mtime(png_name) > mtime(tn_name): tmp_name = 'tmp.png'
do_cmd(("magick "+ png_name + " -trim -resize 280x280 -background " + background + " -gravity Center -extent 280x280 -bordercolor " + background + " -border 10 " + tmp_name).split()) if changed:
update_image(tmp_name, tn_name) print(changed)
os.remove(png_maker_name) t = time.time()
done_assemblies.append(module) openscad.run_list(options.list() + ["-D$pose=1", "-D$explode=%d" % explode, colour_scheme, "--projection=p", "--imgsize=4096,4096", "--autocenter", "--viewall", "-d", dname, "-o", tmp_name, png_maker_name]);
else: times.add_time(png_name, t)
if module == 'main_assembly': do_cmd(["magick", tmp_name, "-trim", "-resize", "1004x1004", "-bordercolor", background, "-border", "10", tmp_name])
main_blurb = blurb.scrape_module_blurb(lines[:line_no]) update_image(tmp_name, png_name)
line_no += 1 tn_name = png_name.replace('.png', '_tn.png')
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)
os.remove(png_maker_name)
done_assemblies.append(module)
else:
if module == 'main_assembly':
main_blurb = blurb.scrape_module_blurb(lines[:line_no])
line_no += 1
times.print_times() times.print_times()
# #
# Build the document # Build the document

View File

@@ -58,10 +58,10 @@ module nuts() {
translate([0, 80]) { translate([0, 80]) {
if(n == M3_nut) if(n == M3_nut)
hammer_nut(M3_hammer_nut); sliding_t_nut(M3_hammer_nut);
if(n == M4_nut) if(n == M4_nut)
hammer_nut(M4_hammer_nut); sliding_t_nut(M4_hammer_nut);
} }
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 KiB

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 KiB

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 KiB

After

Width:  |  Height:  |  Size: 219 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 KiB

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 94 KiB

View File

@@ -132,7 +132,8 @@ module wingnut(type) { //! Draw a wingnut
} }
module sliding_t_nut(type) { module sliding_t_nut(type) {
vitamin(str("sliding_t_nut(", type[0], "): Nut M", nut_size(type), " sliding T")); hammerNut = type[10];
vitamin(str("sliding_t_nut(", type[0], "): Nut M", nut_size(type), hammerNut ? " hammer" : " sliding T"));
size = [type[7], type[2], nut_thickness(type, true)]; size = [type[7], type[2], nut_thickness(type, true)];
tabSizeY1 = type[8]; tabSizeY1 = type[8];
@@ -141,20 +142,7 @@ module sliding_t_nut(type) {
holeRadius = nut_size(type) / 2; holeRadius = nut_size(type) / 2;
color(grey80) color(grey80)
extrusionSlidingNut(size, tabSizeY1, tabSizeY2, tabSizeZ, holeRadius); extrusionSlidingNut(size, tabSizeY1, tabSizeY2, tabSizeZ, holeRadius, 0, hammerNut);
}
module hammer_nut(type) {
vitamin(str("hammer_nut(", type[0], "): Nut M", nut_size(type), " hammer"));
size = [type[7], type[2], nut_thickness(type, true)];
tabSizeY1 = type[8];
tabSizeY2 = type[9];
tabSizeZ = nut_thickness(type);
holeRadius = nut_size(type) / 2;
color(grey80)
extrusionSlidingNut(size, tabSizeY1, tabSizeY2, tabSizeZ, holeRadius, 0, hammerNut = true);
} }
module extrusionSlidingNut(size, tabSizeY1, tabSizeY2, tabSizeZ, holeRadius, holeOffset = 0, hammerNut = false) { module extrusionSlidingNut(size, tabSizeY1, tabSizeY2, tabSizeZ, holeRadius, holeOffset = 0, hammerNut = false) {

View File

@@ -51,12 +51,12 @@ toggle_nut = ["toggle_nut", 6.1, 9.2, 1.5, 1.5, M6_washer, 1.5]
M4_wingnut = ["M4_wingnut", 4, 10, 3.75,8, M4_washer, 0, 22, 10, 6, 3]; M4_wingnut = ["M4_wingnut", 4, 10, 3.75,8, M4_washer, 0, 22, 10, 6, 3];
// sx ty1 ty2 // sx ty1 ty2 hammer
M3_sliding_t_nut = ["M3_sliding_t_nut", 3, 6, 3.0, 4.0, false, 0, 10, 10, 6]; M3_sliding_t_nut = ["M3_sliding_t_nut", 3, 6, 3.0, 4.0, false, 0, 10, 10, 6, false];
M4_sliding_t_nut = ["M4_sliding_t_nut", 4, 6, 3.25,4.5, false, 0, 11, 10, 6]; M4_sliding_t_nut = ["M4_sliding_t_nut", 4, 6, 3.25,4.5, false, 0, 11, 10, 6, false];
M5_sliding_t_nut = ["M5_sliding_t_nut", 5, 6, 3.25,4.5, false, 0, 11, 10, 7]; M5_sliding_t_nut = ["M5_sliding_t_nut", 5, 6, 3.25,4.5, false, 0, 11, 10, 7, false];
M3_hammer_nut = ["M3_hammer_nut", 3, 6, 2.75,4.0, false, 0, 5.5, 10, 6]; M3_hammer_nut = ["M3_hammer_nut", 3, 6, 2.75,4.0, false, 0, 5.5, 10, 6, true];
M4_hammer_nut = ["M4_hammer_nut", 4, 6, 3.25,4.5, false, 0, 5.5, 10, 6]; M4_hammer_nut = ["M4_hammer_nut", 4, 6, 3.25,4.5, false, 0, 5.5, 10, 6, true];
nuts = [M2_nut, M2p5_nut, M3_nut, M4_nut, M5_nut, M6_nut, M8_nut]; nuts = [M2_nut, M2p5_nut, M3_nut, M4_nut, M5_nut, M6_nut, M8_nut];

View File

@@ -117,9 +117,9 @@ module sk_bracket_assembly(type, part_thickness = 2, screw_type = M5_cap_screw,
screw_and_washer(screw_type, screw_length); screw_and_washer(screw_type, screw_length);
translate_z(-nut_offset) translate_z(-nut_offset)
vflip() vflip()
if(!nut_washer_type) if(nut_washer_type)
sliding_t_nut(nut_type);
else
nut_and_washer(nut_type); nut_and_washer(nut_type);
else
sliding_t_nut(nut_type);
} }
} }