public void AddFile(NCFileMerger file) { //Finds commens about tools used at top of tile int i = 2; while (i < file.AmountLines()) { if (file.CheckLineBlock(i)) { break; } else { string line = file.GetLine(i); if (line.Contains("(") || line.Contains(")")) { toolComments = ToolComments(toolComments, line); } } i++; } //Adds tools while (i < file.AmountLines()) { if (file.CheckLineBlock(i)) { string line = file.GetCode(i); if (line.Contains("T")) { line = line.Substring(line.IndexOf("T")); int t = Convert.ToInt32(line.Substring(1, line.IndexOf(" "))); int j = 0; bool toolExists = false; while (j < tools.Count) { if (t == tools[j].ToolID) { i = tools[j].AddTool(file, i + 1); toolExists = true; } j++; } if (!toolExists) { tools.Add(new Tool(t)); i = tools[j].AddTool(file, i + 1); } } } i++; } }
public int AddTool(NCFileMerger file, int i) { while (i < file.AmountLines()) { if (file.CheckLineBlock(i)) { string line = file.GetCode(i); if (line.StartsWith("S")) { toolStart = line; } else if (line.StartsWith("G54") || line.StartsWith("G56")) { toolOffset = line; } else if (line.StartsWith("G43")) { toolHeightOffset = line; } else if (line.StartsWith("M05")) { return(i); } else if (line.StartsWith("G28") || line.StartsWith("G90") || line.StartsWith("G49")) { i++; continue; } else if (line.StartsWith("T")) { return(i - 1); } else { Gcode.Add(file.ReturnActualXYZ(i)); } } i++; } return(i); }