This is different - it’s not a question!
It’s a free offer!
I just finished whipping up a little Python program that looks like it succeeded at inverting the z-axis values (that lie below zero) about a Z-level mid-point.
Back story…
Just got a SainSmart 3018 up-n-running, made a fine-looking ‘dragon.nc’ in a block of hardwood (after using G-Code_Ripper to scale down Z a bit).
I’m also a potter - saw that the dragon would be better as a negative - could then use it to press clay into - make tiles.
BUT… G-Code_Ripper did not do ‘negative scaling’.
SO… after a couple hours with Geany and python, I have a program.
How do I get it to you? Where do we upload things? Can you contact me if you want to have a look at it? It’s really small - doesn’t do much but seems to do it well. I say ‘seems’ because my 3018 is still busy for a few hours so haven’t actually tested it yet, but the gcode file looks like it did the job.
OK - got a clue as to how to post code, so here goes…
#!/usr/bin python
#THIS PROGRAM offered by MakerMarlyn to fellow Makers.
#It can pick out the 'Z' if 'Zxxx' or 'Fxxx' is the last
# thing on a line - maybe following X,Y commands.
#Fortunately, this seems to be S.O.P. in G-code world.
# goes through a gcode file (fileIN) ,
# gets Z-value out of a line
# gets 'most negative' value (minZ)
# divides it by 2 - assigns to 'zMid'
#THEN...
# goes through fileIN again,
# if Z is below zero, flips Z about zMid,
# writes line to fileOUT = ("inv_" + fileIN).
# YOUR FILE NAME GOES HERE...
#Oh yes, it is good if this program and your file are in the same directory/folder.
fileIN = "dragon.nc"
fileOUT="inv_"+fileIN
minZ=0.0
fIN=open(fileIN,"r")
fOUT=open(fileOUT,"w")
#what's the minimum Z value?
with fIN:
for line in fIN:
L=line.strip()
try:
zSplit=L.split("Z")
try:
fSplit=zSplit[1].split("F")
zVal=float(fSplit[0])
except:
zVal=float(zSplit[1])
pass
if (zVal<minZ): minZ=zVal
except: pass
fIN.close()
print ("minZ=",minZ)
zMid=float(minZ/2.0)
print ("zMid=",zMid)
fIN=open(fileIN,"r")
with fIN:
for line in fIN:
L=line.strip()
eol="\n"
zVal=0
try:
zSplit=L.split("Z")
try:
fSplit=zSplit[1].split("F")
zVal=float(fSplit[0])
eol="F"+fSplit[1]+"\n"
except:
zVal=float(zSplit[1])
pass
if (zVal<0):
zVal=(zMid-zVal)+zMid
# set the precision - '4f' is four places, '3f' is three places.
L=zSplit[0]+ "Z"+"{0:.3f}".format(zVal)
except:
pass
L=L+eol
fOUT.write(L)
fIN.close()
fOUT.close()