1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2024-12-23 05:01:10 +02:00

sfc/slicer.py: new option -o to add an offset to the last layer

This commit is contained in:
Werner Almesberger 2015-01-21 02:46:29 -03:00
parent 84889441f3
commit 4d084a6191

View File

@ -33,6 +33,7 @@ height = None # height of the workpiece above the Z plane (can be
# negative). Default: use model dimensions. # negative). Default: use model dimensions.
align_top = None # align the Z position of the model to the workpiece align_top = None # align the Z position of the model to the workpiece
align_bottom = None align_bottom = None
end = 0 # Z adjustment of final layer
def dist(a, b): def dist(a, b):
@ -92,7 +93,7 @@ def dump_level(wires, z):
def usage(): def usage():
print >>sys.stderr, "usage:", sys.argv[0], \ print >>sys.stderr, "usage:", sys.argv[0], \
"[-a (top|bottom)(+|-)offset] [-f] [-h height]" + \ "[-a (top|bottom)(+|-)offset] [-f] [-h height]" + \
"\t[-b piece_distance] [-s max_step] file.stl" "\t[-b piece_distance] [-o z_offset] [-s max_step] file.stl"
sys.exit(1) sys.exit(1)
@ -105,7 +106,7 @@ stdout = os.dup(1)
os.dup2(2, 1) os.dup2(2, 1)
sys.stdout = os.fdopen(stdout, "w") sys.stdout = os.fdopen(stdout, "w")
opts, args = getopt.getopt(sys.argv[1:], "a:fh:p:s:") opts, args = getopt.getopt(sys.argv[1:], "a:e:fh:p:s:")
for opt, arg in opts: for opt, arg in opts:
if opt == "-a": if opt == "-a":
if arg[0:3] == "top": if arg[0:3] == "top":
@ -114,6 +115,8 @@ for opt, arg in opts:
align_bottom = float(arg[6:]) align_bottom = float(arg[6:])
else: else:
usage() usage()
elif opt == "-o":
end = float(arg)
elif opt == "-f": elif opt == "-f":
flip = True flip = True
elif opt == "-h": elif opt == "-h":
@ -214,6 +217,8 @@ else:
if height is not None and height < 0 and z_levels[-1] > height: if height is not None and height < 0 and z_levels[-1] > height:
z_levels.append(height - z_off) z_levels.append(height - z_off)
z_levels[-1] += end
for next_z in z_levels: for next_z in z_levels:
wires = shape.slice(Base.Vector(0, 0, 1), next_z + epsilon) wires = shape.slice(Base.Vector(0, 0, 1), next_z + epsilon)
if z_step is None or last_z is None or last_z - z_step <= next_z: if z_step is None or last_z is None or last_z - z_step <= next_z: