Skip to content

Commit

Permalink
Workarounds for bugs in the OpenSCAD snapshots.
Browse files Browse the repository at this point in the history
  • Loading branch information
nophead committed Sep 12, 2021
1 parent 588a1ed commit f0c25d3
Show file tree
Hide file tree
Showing 20 changed files with 8,620 additions and 8,616 deletions.
11,854 changes: 5,927 additions & 5,927 deletions examples/MainsBreakOutBox/stls/foot.stl

Large diffs are not rendered by default.

5,358 changes: 2,679 additions & 2,679 deletions examples/MainsBreakOutBox/stls/socket_box.stl

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions global_defs.scad
Expand Up @@ -24,13 +24,10 @@
// bom defaults to 0
// Setting $bom on the command line or in the main file before including lib.scad overrides it everywhere.
// Setting $bom after including lib overrides bom in the libs but not in the local file.
// Setting $_bom in the local file overrides it in the local file but not in the libs.
//
rr_green = [0, 146/255, 0]; // RepRap logo colour
crimson = [220/255, 20/255, 60/255];

$_bom = is_undef($bom) ? 0 : $bom; // 0 no bom, 1 assemblies and stls, 2 vitamins as well
$exploded = is_undef($explode) ? 0 : $explode; // 1 for exploded view
layer_height = is_undef($layer_height) ? 0.25 : $layer_height; // layer height when printing
extrusion_width = is_undef($extrusion_width) ? 0.5 : $extrusion_width; // filament width when printing
nozzle = is_undef($nozzle) ? 0.45 : $nozzle; // 3D printer nozzle
Expand Down
1 change: 1 addition & 0 deletions scripts/exports.py
Expand Up @@ -139,6 +139,7 @@ def make_parts(target, part_type, parts = None):
#
part_maker_name = tmp_dir + '/' + part_type + ".scad"
with open(part_maker_name, "w") as f:
f.write("include <NopSCADlib/global_defs.scad>\n")
f.write("use <%s/%s>\n" % (reltmp(dir, target), filename))
f.write("%s();\n" % module);
t = time.time()
Expand Down
4 changes: 3 additions & 1 deletion scripts/render.py
Expand Up @@ -94,11 +94,13 @@ def render(target, type):
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' or colour != pp1 else "--render"
tmp_name = tmp_dir + '/' + part[:-4] + '.png'
openscad.run("-o", tmp_name, png_maker_name, colour_scheme, "--projection=p", "--imgsize=4096,4096", cam, render, "--autocenter", "--viewall");
dummy_deps_name = tmp_dir + '/tmp.deps' # work around for OpenSCAD issue #3879
openscad.run("-o", tmp_name, png_maker_name, colour_scheme, "--projection=p", "--imgsize=4096,4096", cam, render, "--autocenter", "--viewall", "-d", dummy_deps_name)
do_cmd(("magick "+ tmp_name + " -trim -resize 280x280 -background %s -gravity Center -extent 280x280 -bordercolor %s -border 10 %s"
% (background, background, tmp_name)).split())
update_image(tmp_name, png_name)
os.remove(png_maker_name)
os.remove(dummy_deps_name)
#
# Remove tmp dir
#
Expand Down
2 changes: 2 additions & 0 deletions scripts/tests.py
Expand Up @@ -72,6 +72,8 @@ def update_image(tmp_name, png_name):
if pixels < 0 or pixels > threshold:
shutil.copyfile(tmp_name, png_name)
print(Fore.YELLOW + png_name + " updated" + Fore.WHITE, pixels if pixels > 0 else '')
if png_name.endswith('_tn.png'):
os.remove(diff_name)
else:
os.utime(png_name, None)
os.remove(diff_name)
Expand Down
1 change: 1 addition & 0 deletions scripts/tmpdir.py
Expand Up @@ -25,6 +25,7 @@
def mktmpdir(top_dir):
tmp_dir = top_dir + 'tmp'
if not os.path.isdir(tmp_dir):
time.sleep(0.1)
os.makedirs(tmp_dir)
else:
for file in os.listdir(tmp_dir):
Expand Down
1 change: 1 addition & 0 deletions scripts/views.py
Expand Up @@ -216,6 +216,7 @@ def views(target, do_assemblies = None):
#
png_maker_name = tmp_dir + '/png.scad'
with open(png_maker_name, "w") as f:
f.write("include <NopSCADlib/global_defs.scad>\n")
f.write("use <%s/%s>\n" % (reltmp(dir, target), filename))
f.write("%s();\n" % module);
t = time.time()
Expand Down
Binary file modified tests/png/annotation.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/png/belts.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/png/bezier.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/png/dip.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/png/green_terminals.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/png/hygrometer.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/png/led_meters.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/png/pcb.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/png/rounded_polygon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/png/smds.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions utils/core/bom.scad
Expand Up @@ -42,24 +42,24 @@
//! * To get the parameter values make the GUI window square, pose the view with the mouse and then copy the viewport parameters from the Edit menu and paste them into the pose invocation.
//! * Two `pose()` modules can be chained to allow different poses for exploded and assembled views.
//
function bom_mode(n = 1) = $_bom >= n && (is_undef($on_bom) || $on_bom); //! Current BOM mode, 0 = none, 1 = printed and routed parts and assemblies, 2 includes vitamins as well
function exploded() = is_undef($exploded_parent) ? $exploded : 0; //! Returns the value of `$exploded` if it is defined, else `0`
function bom_mode(n = 1) = (is_undef($bom) ? 0 : $bom) >= n && (is_undef($on_bom) || $on_bom); //! Current BOM mode, 0 = none, 1 = printed and routed parts and assemblies, 2 includes vitamins as well
function exploded() = is_undef($exploded_parent) ? is_undef($explode) ? 0 : $explode : 0; //! Returns the value of `$exploded` if it is defined, else `0`
function show_supports() = !$preview || exploded(); //! True if printed support material should be shown

module no_explode() let($exploded_parent = true) children(); //! Prevent children being exploded
module explode(d, explode_children = false, offset = [0,0,0]) { //! Explode children by specified Z distance or vector `d`, option to explode grand children
v = is_list(d) ? d : [0, 0, d];
o = is_list(offset) ? offset : [0, 0, offset];
if($exploded && is_undef($exploded_parent) && norm(v)) {
if(exploded() && norm(v)) {
translate(o) // Draw the line first in case the child is transparent
color("yellow") hull() {
sphere(0.2);

translate(v * $exploded)
translate(v * exploded())
sphere(0.2);
}

translate(v * $exploded)
translate(v * exploded())
let($exploded_parent = explode_children ? undef : true)
children();
}
Expand Down
2 changes: 1 addition & 1 deletion vitamins/nut.scad
Expand Up @@ -116,7 +116,7 @@ module wingnut(type) { //! Draw a wingnut
polygon([
[hole_rad, 0],
[bottom_rad, 0],
[top_rad,, thickness],
[top_rad, thickness],
[hole_rad, thickness]
]);
for(rot = [0, 180])
Expand Down

0 comments on commit f0c25d3

Please sign in to comment.