From 313163721e69d86cc1bdec181f672fe6f6e59e2d Mon Sep 17 00:00:00 2001 From: Skateboss Date: Sat, 27 Aug 2011 08:45:35 +0200 Subject: [PATCH 1/6] Edited pronterface.py via GitHub --- pronterface.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pronterface.py b/pronterface.py index be9f435..999b135 100755 --- a/pronterface.py +++ b/pronterface.py @@ -1023,7 +1023,13 @@ class PronterWindow(wx.Frame,pronsole.pronsole): threading.Thread(target=self.loadviz).start() def loadviz(self): - print pronsole.totalelength(self.f), _("mm of filament used in this print") + Xtot,Ytot,Ztot = pronsole.measurements(self.f) + Xmin,Xmax,Ymin,Ymax,Zmin,Zmax = pronsole.minmaxpoints(self.f) + print pronsole.totalelength(self.f), _("mm of filament used in this print\n") + Xtot,Ytot,Ztot= pronsole.measurements(self.f) + print ("the print goes from"),_(Xmin),("mm to"),_(Xmax),("mm in X\nand is"),_(Xtot),("mm wide\n") + print ("the print goes from"),_(Ymin),("mm to"),_(Ymax),("mm in Y\nand is"),_(Ytot),("mm wide\n") + print ("the print goes from"),_(Zmin),("mm to"),_(Zmax),("mm in Z\nand is"),_(Ztot),("mm high\n") self.gviz.clear() self.gwindow.p.clear() for i in self.f: From 52bb2bf919b626e9d5f29f3ae3202e3b56714960 Mon Sep 17 00:00:00 2001 From: Skateboss Date: Sat, 27 Aug 2011 08:51:01 +0200 Subject: [PATCH 2/6] Added two functions to return measurements in 'mm' when loading a .stl or gcode file. --- pronsole.py | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/pronsole.py b/pronsole.py index af01dba..b698b68 100755 --- a/pronsole.py +++ b/pronsole.py @@ -18,6 +18,88 @@ except: def dosify(name): return os.path.split(name)[1].split(".")[0][:8]+".g" + +def minmaxpoints(g): + Xcur=0.0 + Ycur=0.0 + Zcur=0.0 + Xmin=1000000 + Ymin=1000000 + Zmin=1000000 + Xmax=-1000000 + Ymax=-1000000 + Zmax=-1000000 + for i in g: + if "X" in i and ("G1" in i or "G0" in i): + try: + Xcur = float(i.split("X")[1].split(" ")[0]) + if Xcur5.0: Xmin=Xcur + if Xcur>Xmax: Xmax=Xcur + except: + pass + if "Y" in i and ("G1" in i or "G0" in i): + try: + Ycur = float(i.split("Y")[1].split(" ")[0]) + if Ycur5.0: Ymin=Ycur + if Ycur>Ymax: Ymax=Ycur + except: + pass + + if "Z" in i and ("G1" in i or "G0" in i): + try: + Zcur = float(i.split("Z")[1].split(" ")[0]) + if ZcurZmax: Zmax=Zcur + except: + pass + return (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax) + +def measurements(g): + Xcur=0.0 + Ycur=0.0 + Zcur=0.0 + Xmin=1000000 + Ymin=1000000 + Zmin=1000000 + Xmax=-1000000 + Ymax=-1000000 + Zmax=-1000000 + Xtot=0 + Ytot=0 + Ztot=0 + + + for i in g: + if "X" in i and ("G1" in i or "G0" in i): + try: + Xcur = float(i.split("X")[1].split(" ")[0]) + if Xcur5.0: Xmin=Xcur + if Xcur>Xmax: Xmax=Xcur + except: + pass + if "Y" in i and ("G1" in i or "G0" in i): + try: + Ycur = float(i.split("Y")[1].split(" ")[0]) + if Ycur5.0: Ymin=Ycur + if Ycur>Ymax: Ymax=Ycur + except: + pass + + if "Z" in i and ("G1" in i or "G0" in i): + try: + Zcur = float(i.split("Z")[1].split(" ")[0]) + if ZcurZmax: Zmax=Zcur + except: + pass + + + Xtot = Xmax - Xmin + Ytot = Ymax - Ymin + Ztot = Zmax - Zmin + + + return (Xtot,Ytot,Ztot) def totalelength(g): tot=0 From 4f8cffd9b0984ff73c4e6663959ccda3d85bb56a Mon Sep 17 00:00:00 2001 From: Skateboss Date: Sat, 27 Aug 2011 09:11:52 +0200 Subject: [PATCH 3/6] removed minmax() --- pronsole.py | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/pronsole.py b/pronsole.py index b698b68..ada848d 100755 --- a/pronsole.py +++ b/pronsole.py @@ -19,41 +19,6 @@ except: def dosify(name): return os.path.split(name)[1].split(".")[0][:8]+".g" -def minmaxpoints(g): - Xcur=0.0 - Ycur=0.0 - Zcur=0.0 - Xmin=1000000 - Ymin=1000000 - Zmin=1000000 - Xmax=-1000000 - Ymax=-1000000 - Zmax=-1000000 - for i in g: - if "X" in i and ("G1" in i or "G0" in i): - try: - Xcur = float(i.split("X")[1].split(" ")[0]) - if Xcur5.0: Xmin=Xcur - if Xcur>Xmax: Xmax=Xcur - except: - pass - if "Y" in i and ("G1" in i or "G0" in i): - try: - Ycur = float(i.split("Y")[1].split(" ")[0]) - if Ycur5.0: Ymin=Ycur - if Ycur>Ymax: Ymax=Ycur - except: - pass - - if "Z" in i and ("G1" in i or "G0" in i): - try: - Zcur = float(i.split("Z")[1].split(" ")[0]) - if ZcurZmax: Zmax=Zcur - except: - pass - return (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax) - def measurements(g): Xcur=0.0 Ycur=0.0 @@ -99,7 +64,7 @@ def measurements(g): Ztot = Zmax - Zmin - return (Xtot,Ytot,Ztot) + return (Xtot,Ytot,Ztot,Xmin,Xmax,Ymin,Ymax,Zmin,Zmax) def totalelength(g): tot=0 From d01621d5e51598b66671a1c58c6d4c1f15fba5a8 Mon Sep 17 00:00:00 2001 From: Skateboss Date: Sat, 27 Aug 2011 09:15:22 +0200 Subject: [PATCH 4/6] condensed measurements code. --- pronterface.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pronterface.py b/pronterface.py index 999b135..b3665c6 100755 --- a/pronterface.py +++ b/pronterface.py @@ -1023,8 +1023,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): threading.Thread(target=self.loadviz).start() def loadviz(self): - Xtot,Ytot,Ztot = pronsole.measurements(self.f) - Xmin,Xmax,Ymin,Ymax,Zmin,Zmax = pronsole.minmaxpoints(self.f) + Xtot,Ytot,Ztot,Xmin,Xmax,Ymin,Ymax,Zmin,Zmax = pronsole.measurements(self.f) print pronsole.totalelength(self.f), _("mm of filament used in this print\n") Xtot,Ytot,Ztot= pronsole.measurements(self.f) print ("the print goes from"),_(Xmin),("mm to"),_(Xmax),("mm in X\nand is"),_(Xtot),("mm wide\n") From d4285ad1e2e480ec4000acc5c06bd8bff50f6ae3 Mon Sep 17 00:00:00 2001 From: Skateboss Date: Sat, 27 Aug 2011 09:26:07 +0200 Subject: [PATCH 5/6] removed brackets --- pronterface.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pronterface.py b/pronterface.py index b3665c6..23862ea 100755 --- a/pronterface.py +++ b/pronterface.py @@ -1026,9 +1026,9 @@ class PronterWindow(wx.Frame,pronsole.pronsole): Xtot,Ytot,Ztot,Xmin,Xmax,Ymin,Ymax,Zmin,Zmax = pronsole.measurements(self.f) print pronsole.totalelength(self.f), _("mm of filament used in this print\n") Xtot,Ytot,Ztot= pronsole.measurements(self.f) - print ("the print goes from"),_(Xmin),("mm to"),_(Xmax),("mm in X\nand is"),_(Xtot),("mm wide\n") - print ("the print goes from"),_(Ymin),("mm to"),_(Ymax),("mm in Y\nand is"),_(Ytot),("mm wide\n") - print ("the print goes from"),_(Zmin),("mm to"),_(Zmax),("mm in Z\nand is"),_(Ztot),("mm high\n") + print ("the print goes from"),Xmin,("mm to"),Xmax,("mm in X\nand is"),Xtot,("mm wide\n") + print ("the print goes from"),Ymin,("mm to"),Ymax,("mm in Y\nand is"),Ytot,("mm wide\n") + print ("the print goes from"),Zmin,("mm to"),Zmax,("mm in Z\nand is"),Ztot,("mm high\n") self.gviz.clear() self.gwindow.p.clear() for i in self.f: From f23f62098a27c96cc36e6216d224f65de62697e1 Mon Sep 17 00:00:00 2001 From: Skateboss Date: Sat, 27 Aug 2011 09:31:32 +0200 Subject: [PATCH 6/6] Edited pronterface.py via GitHub --- pronterface.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pronterface.py b/pronterface.py index 23862ea..5171957 100755 --- a/pronterface.py +++ b/pronterface.py @@ -1026,9 +1026,9 @@ class PronterWindow(wx.Frame,pronsole.pronsole): Xtot,Ytot,Ztot,Xmin,Xmax,Ymin,Ymax,Zmin,Zmax = pronsole.measurements(self.f) print pronsole.totalelength(self.f), _("mm of filament used in this print\n") Xtot,Ytot,Ztot= pronsole.measurements(self.f) - print ("the print goes from"),Xmin,("mm to"),Xmax,("mm in X\nand is"),Xtot,("mm wide\n") - print ("the print goes from"),Ymin,("mm to"),Ymax,("mm in Y\nand is"),Ytot,("mm wide\n") - print ("the print goes from"),Zmin,("mm to"),Zmax,("mm in Z\nand is"),Ztot,("mm high\n") + print _("the print goes from"),Xmin,_("mm to"),Xmax,_("mm in X\nand is"),Xtot,_("mm wide\n") + print _("the print goes from"),Ymin,_("mm to"),Ymax,_("mm in Y\nand is"),Ytot,_("mm wide\n") + print _("the print goes from"),Zmin,_("mm to"),Zmax,_("mm in Z\nand is"),Ztot,_("mm high\n") self.gviz.clear() self.gwindow.p.clear() for i in self.f: