From 396f03ea9b87f3cd2613316957e6c4d23afc820f Mon Sep 17 00:00:00 2001 From: Eric Trombly Date: Wed, 22 Apr 2020 10:37:24 -0500 Subject: [PATCH] pass endVectorin PathAreaOp and clean up gcode generation --- src/Mod/Path/App/Area.cpp | 28 +++++++++++++++++++------- src/Mod/Path/PathScripts/PathAreaOp.py | 5 +++-- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/Mod/Path/App/Area.cpp b/src/Mod/Path/App/Area.cpp index c0f775879b..a9d9df0c8f 100644 --- a/src/Mod/Path/App/Area.cpp +++ b/src/Mod/Path/App/Area.cpp @@ -3176,14 +3176,19 @@ static void addG0(bool verbose, Toolpath &path, last = pt; pt = next; (pt.*setter)(retraction); - addGCode(verbose,path,last,pt,"G0"); + if(!last.IsEqual(pt, Precision::Confusion())) + addGCode(verbose,path,last,pt,"G0"); } if(resume_height>Precision::Confusion()) { if(resume_height+(next.*getter)() < retraction) { + if(!last.IsEqual(pt, Precision::Confusion())) + addGCode(verbose,path,last,pt,"G0"); last = pt; pt = next; - (pt.*setter)((next.*getter)()+resume_height); - addGCode(verbose,path,last,pt,"G0"); + // was originally set to resume height, but retraction gives correct paths + (pt.*setter)(retraction); + if(!last.IsEqual(pt, Precision::Confusion())) + addGCode(verbose,path,last,pt,"G0"); } addG1(verbose,path,pt,next,f,last_f); }else @@ -3303,15 +3308,19 @@ void Area::toPath(Toolpath &path, const std::list &shapes, addGCode(false,path,plast,p,"G0"); plast = p; p = pstart; + // rapid horizontal move if start Z is below retraction if(fabs((p.*getter)()-retraction) > Precision::Confusion()) { + if(_pstart && p.IsEqual(plast, Precision::Confusion())){ + plast.SetCoord(10.0, 10.0, 10.0); + (plast.*setter)(retraction); + } (p.*setter)(retraction); addGCode(false,path,plast,p,"G0"); plast = p; p = pstart; } - // vertical rapid down to feed start - addGCode(false,path,plast,p,"G0"); + plast = p; bool first = true; @@ -3334,10 +3343,15 @@ void Area::toPath(Toolpath &path, const std::list &shapes, (pTmp.*setter)(0.0); (plastTmp.*setter)(0.0); - if(!first && pTmp.SquareDistance(plastTmp)>threshold) + if(first) { addG0(verbose,path,plast,p,getter,setter,retraction,resume_height,vf,cur_f); - else + // vertical rapid down to feed start + addGCode(false,path,plast,p,"G0"); + }else if(pTmp.SquareDistance(plastTmp)>threshold){ + addG0(verbose,path,plast,p,getter,setter,retraction,resume_height,vf,cur_f); + }else{ addG1(verbose,path,plast,p,vf,cur_f); + } plast = p; first = false; for(;xp.More();xp.Next(),plast=p) { diff --git a/src/Mod/Path/PathScripts/PathAreaOp.py b/src/Mod/Path/PathScripts/PathAreaOp.py index b40e932eb8..8bcf1b4577 100644 --- a/src/Mod/Path/PathScripts/PathAreaOp.py +++ b/src/Mod/Path/PathScripts/PathAreaOp.py @@ -476,8 +476,9 @@ class ObjectOp(PathOp.ObjectOp): sims.append(sim) # Eif - if self.areaOpRetractTool(obj): - self.endVector = None # pylint: disable=attribute-defined-outside-init + if self.areaOpRetractTool(obj) and self.endVector is not None: + self.endVector[2] = obj.ClearanceHeight.Value + self.commandlist.append(Path.Command('G0', {'Z': obj.ClearanceHeight.Value, 'F': self.vertRapid})) # Raise cutter to safe height and rotate back to original orientation if self.rotateFlag is True: