1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2024-12-22 23:51:08 +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.
align_top = None # align the Z position of the model to the workpiece
align_bottom = None
end = 0 # Z adjustment of final layer
def dist(a, b):
@ -92,7 +93,7 @@ def dump_level(wires, z):
def usage():
print >>sys.stderr, "usage:", sys.argv[0], \
"[-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)
@ -105,7 +106,7 @@ stdout = os.dup(1)
os.dup2(2, 1)
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:
if opt == "-a":
if arg[0:3] == "top":
@ -114,6 +115,8 @@ for opt, arg in opts:
align_bottom = float(arg[6:])
else:
usage()
elif opt == "-o":
end = float(arg)
elif opt == "-f":
flip = True
elif opt == "-h":
@ -214,6 +217,8 @@ else:
if height is not None and height < 0 and z_levels[-1] > height:
z_levels.append(height - z_off)
z_levels[-1] += end
for next_z in z_levels:
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: