From b6304d16a77f65f94aa5ec79f69688be61a42961 Mon Sep 17 00:00:00 2001 From: Sammel Lothar LTS Date: Mon, 8 Jan 2018 15:17:59 +0100 Subject: [PATCH] Fix Path Keep View and Sim in Sync,typo Linuxcnc_post --- src/Mod/Path/PathScripts/PathSimulatorGui.py | 8 +++---- .../Path/PathScripts/post/linuxcnc_post.py | 7 ++++-- src/Mod/Path/PathSimulator/App/PathSim.cpp | 22 +++++++++++++++---- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathSimulatorGui.py b/src/Mod/Path/PathScripts/PathSimulatorGui.py index 8be9536621..c937230f99 100644 --- a/src/Mod/Path/PathScripts/PathSimulatorGui.py +++ b/src/Mod/Path/PathScripts/PathSimulatorGui.py @@ -186,10 +186,10 @@ class PathSimulation: (pathSolid, self.curpos) = self.GetPathSolid(self.tool, cmd, self.curpos) if cmd.Name in ['G81', 'G82', 'G83']: if self.firstDrill: - extendcommand = Path.Command('G1', {"X": 0.0, "Y": 0.0, "Z": cmd.r}) + extendcommand = Path.Command('G0', {"X": 0.0, "Y": 0.0, "Z": cmd.r}) self.curpos = self.RapidMove(extendcommand, self.curpos) self.firstDrill = False - extendcommand = Path.Command('G1', {"X": cmd.x, "Y": cmd.y, "Z": cmd.r}) + extendcommand = Path.Command('G0', {"X": cmd.x, "Y": cmd.y, "Z": cmd.r}) self.curpos = self.RapidMove(extendcommand, self.curpos) extendcommand = Path.Command('G1', {"X": cmd.x, "Y": cmd.y, "Z": cmd.z}) self.curpos = self.RapidMove(extendcommand, self.curpos) @@ -242,9 +242,9 @@ class PathSimulation: if cmd.Name in ['G81', 'G82', 'G83']: extendcommands = [] if self.firstDrill: - extendcommands.append(Path.Command('G1', {"X": 0.0, "Y": 0.0, "Z": cmd.r})) + extendcommands.append(Path.Command('G0', {"X": 0.0, "Y": 0.0, "Z": cmd.r})) self.firstDrill = False - extendcommands.append(Path.Command('G1', {"X": cmd.x, "Y": cmd.y, "Z": cmd.r})) + extendcommands.append(Path.Command('G0', {"X": cmd.x, "Y": cmd.y, "Z": cmd.r})) extendcommands.append(Path.Command('G1', {"X": cmd.x, "Y": cmd.y, "Z": cmd.z})) extendcommands.append(Path.Command('G1', {"X": cmd.x, "Y": cmd.y, "Z": cmd.r})) for ecmd in extendcommands: diff --git a/src/Mod/Path/PathScripts/post/linuxcnc_post.py b/src/Mod/Path/PathScripts/post/linuxcnc_post.py index 564536cb23..0d9aa84f00 100644 --- a/src/Mod/Path/PathScripts/post/linuxcnc_post.py +++ b/src/Mod/Path/PathScripts/post/linuxcnc_post.py @@ -272,7 +272,7 @@ def parse(pathobj): params = ['X', 'Y', 'Z', 'A', 'B', 'C', 'I', 'J', 'F', 'S', 'T', 'Q', 'R', 'L', 'H', 'D', 'P'] # keep track for no doubles currLocation = {} - firstmove = Path.Command("G0", {"X": -1, "Y": -1, "Z": -1, "F": -1}) + firstmove = Path.Command("G0", {"X": -1, "Y": -1, "Z": -1, "F": 0.0}) currLocation.update(firstmove.Parameters) if hasattr(pathobj, "Group"): # We have a compound or project. @@ -306,8 +306,11 @@ def parse(pathobj): if param == 'F' and (currLocation[param] == c.Parameters[param] and OUTPUT_DOUBLES): if c.Name not in ["G0", "G00"]: # linuxcnc doesn't use rapid speeds speed = Units.Quantity(c.Parameters['F'], FreeCAD.Units.Velocity) - outstring.append( + if speed.getValueAs(UNIT_SPEED_FORMAT) > 0.0: + outstring.append( param + format(float(speed.getValueAs(UNIT_SPEED_FORMAT)), precision_string)) + else: + continue elif param == 'T': outstring.append(param + str(int(c.Parameters['T']))) elif param == 'H': diff --git a/src/Mod/Path/PathSimulator/App/PathSim.cpp b/src/Mod/Path/PathSimulator/App/PathSim.cpp index 4c77a6ddde..97f81f6ce2 100644 --- a/src/Mod/Path/PathSimulator/App/PathSim.cpp +++ b/src/Mod/Path/PathSimulator/App/PathSim.cpp @@ -50,7 +50,7 @@ PathSim::PathSim() PathSim::~PathSim() { if (m_stock != nullptr) - delete m_stock; + delete m_stock; if (m_tool != nullptr) delete m_tool; } @@ -79,6 +79,13 @@ void PathSim::SetCurrentTool(Tool * tool) case Tool::UNDEFINED: case Tool::DRILL: + tp = cSimTool::CHAMFER; + angle = tool->CuttingEdgeAngle; + if (angle > 180) + { + angle = 180; + } + break; case Tool::CENTERDRILL: case Tool::COUNTERSINK: case Tool::COUNTERBORE: @@ -88,13 +95,19 @@ void PathSim::SetCurrentTool(Tool * tool) case Tool::SLOTCUTTER: case Tool::CORNERROUND: case Tool::ENGRAVER: - break; // quiet warnings + tp = cSimTool::CHAMFER; + angle = tool->CuttingEdgeAngle; + if (angle > 180) + { + angle = 180; + } + break; + break; // quiet warnings } m_tool = new cSimTool(tp, tool->Diameter / 2.0, angle); } - Base::Placement * PathSim::ApplyCommand(Base::Placement * pos, Command * cmd) { Point3D fromPos(*pos); @@ -102,7 +115,7 @@ Base::Placement * PathSim::ApplyCommand(Base::Placement * pos, Command * cmd) toPos.UpdateCmd(*cmd); if (cmd->Name == "G0" || cmd->Name == "G1") { - m_stock->ApplyLinearTool(fromPos, toPos, *m_tool); + m_stock->ApplyLinearTool(fromPos, toPos, *m_tool); } else if (cmd->Name == "G2") { @@ -116,6 +129,7 @@ Base::Placement * PathSim::ApplyCommand(Base::Placement * pos, Command * cmd) Point3D cent(vcent); m_stock->ApplyCircularTool(fromPos, toPos, cent, *m_tool, true); } + Base::Placement *plc = new Base::Placement(); Vector3d vec(toPos.x, toPos.y, toPos.z); plc->setPosition(vec);