Workarounds for bugs in the OpenSCAD snapshots.
@@ -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
|
||||
|
@@ -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()
|
||||
|
@@ -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
|
||||
#
|
||||
|
@@ -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)
|
||||
|
@@ -25,6 +25,7 @@ import time
|
||||
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):
|
||||
|
@@ -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()
|
||||
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 162 KiB After Width: | Height: | Size: 162 KiB |
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 102 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 95 KiB |
Before Width: | Height: | Size: 180 KiB After Width: | Height: | Size: 180 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 88 KiB |
@@ -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();
|
||||
}
|
||||
|
@@ -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])
|
||||
|