1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-08-09 00:46:32 +02:00

Workarounds for bugs in the OpenSCAD snapshots.

This commit is contained in:
Chris Palmer
2021-09-12 18:02:43 +01:00
parent 588a1edf62
commit f0c25d37b0
20 changed files with 8632 additions and 8628 deletions

View File

@@ -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()

View File

@@ -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
#

View File

@@ -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)

View File

@@ -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):

View File

@@ -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()