private void LoadProjectComponents() { double Tolerance = 0; bool UseMethod = false; string TemplateFolder = ""; string CSVPath = ""; bool DepthFromTop = false; bool AllowTagDuplicate = true; listHoleFeatureSet.Items.Clear(); List <string> ncprogs = PowerMILLAutomation.GetListOf(PowerMILLAutomation.enumEntity.FeatureSets); foreach (string ncprog in ncprogs) { listHoleFeatureSet.Items.Add(ncprog); } //Get the template from the option page TagHoles.ExtractINIData(out MachineCells); TagHoles.GetActiveMachineCellInfos(MachineCell_Drop.Text, MachineCells, out CSVPath, out TemplateFolder, out Tolerance, out UseMethod, out DepthFromTop, out AllowTagDuplicate); UpdateMachineCellsDropDown(MachineCells); CurrentMachineCell = MachineCell_Drop.Text; }
private void DatabaseTag_Click(object sender, RoutedEventArgs e) { string TemplateFolder = ""; string Path = System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Substring(8, System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Length - 8); string directory = System.IO.Path.GetDirectoryName(Path); string RenameMacro = directory + "\\Rename.mac"; string EndOfTagging = directory + "\\EndOfTagging.mac"; double Tolerance = 0; bool UseMethod = false; bool DepthFromTop = false; bool AllowTagDuplicate = true; List <RecognizedHoles> RecognizedHolesList = null; if (NCProgramListDB.Text == "") { MessageBox.Show("Please select a Featureset", "Error"); return; } //Get the template from the option page TagHoles.ExtractINIData(out MachineCells); TagHoles.GetActiveMachineCellInfos(MachineCell_Drop.Text, MachineCells, out CSVPath, out TemplateFolder, out Tolerance, out UseMethod, out DepthFromTop, out AllowTagDuplicate); PowerMILLAutomation.ExecuteEx("ACTIVATE Featureset '" + NCProgramListDB.Text + "'"); PowerMILLAutomation.ExecuteEx("MACRO '" + RenameMacro + "'"); TagHoles.ExtractFeatureSetData(CSVPath, DepthFromTop, out HoleData, out List <DBHoleInfos> DBHoleData); TagHoles.MatchAndRenameHolesNew(NCProgramListDB.Text, HoleData, DBHoleData, Tolerance, out RecognizedHolesList, out UnRecognizedHolesList); FillUnrecognizedHolePullDown(); PowerMILLAutomation.ExecuteEx("MACRO '" + EndOfTagging + "'"); }
private void UpdateFields(List <MachineCells> MachineCells) { string CurrentMachineCell = ""; if (MachineCellCombo.SelectedItem == null) { CurrentMachineCell = "Default"; } else { CurrentMachineCell = MachineCellCombo.SelectedItem.ToString(); } TagHoles.ExtractINIData(out MachineCells); foreach (MachineCells Machine in MachineCells) { if (Machine.Name == CurrentMachineCell) { Database.Text = Machine.CSVPath; Toolpath_Folder.Text = Machine.ToolpathsPath; Tolerance.Text = Machine.Tolerance.ToString(); if (Machine.AllowTagDuplicate) { AllowTagDuplicate.Checked = true; } else { AllowTagDuplicate.Checked = false; } if (Machine.UseMethod) { UseMethods.Checked = true; UseToolpaths.Checked = false; } else { UseMethods.Checked = false; UseToolpaths.Checked = true; } if (Machine.DepthFromTop) { TopComponent.Checked = false; TopHole.Checked = true; } else { TopComponent.Checked = true; TopHole.Checked = false; } } } }
private void DelModify_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { DBHoleData = new List <DBHoleInfos>(); string TemplateFolder = ""; string Path = System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Substring(8, System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Length - 8); string directory = System.IO.Path.GetDirectoryName(Path); double Tolerance = 0; bool UseMethod = false; bool DepthFromTop = false; bool AllowTagDuplicate = true; //Get the template from the option page TagHoles.ExtractINIData(out MachineCells); TagHoles.GetActiveMachineCellInfos(MachineCell_Drop.Text, MachineCells, out CSVPath, out TemplateFolder, out Tolerance, out UseMethod, out DepthFromTop, out AllowTagDuplicate); TagHoles.ExtractNewDatabaseData(CSVPath, out DBHoleData); LoadFamilyTypes(); }
public void UpdateMachineCellsDropDown(List <MachineCells> MachineCells) { TagHoles.ExtractINIData(out MachineCells); if (MachineCell_Drop.Items.Count == 1) { foreach (MachineCells Machine in MachineCells) { if (Machine.Name != "Default") { MachineCell_Drop.Items.Add(Machine.Name); } } } else if (MachineCells.Count != MachineCell_Drop.Items.Count) { MachineCell_Drop.Items.Clear(); foreach (MachineCells Machine in MachineCells) { MachineCell_Drop.Items.Add(Machine.Name); } } }
public Options() { InitializeComponent(); string Path = INIPath + "\\Settings.ini"; if (File.Exists(Path)) { TagHoles.ExtractINIData(out MachineCells); MachineCellCombo.Items.Clear(); foreach (MachineCells Machine in MachineCells) { MachineCellCombo.Items.Add(Machine.Name); } MachineCellCombo.SelectedIndex = 0; UpdateFields(MachineCells); } else { MachineCellCombo.Text = "Default"; } }
private void Generate_Click(object sender, RoutedEventArgs e) { string TemplateFolder = ""; string Path = System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Substring(8, System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Length - 8); string directory = System.IO.Path.GetDirectoryName(Path); string RenameMacro = directory + "\\Rename.mac"; string EndOfTagging = directory + "\\EndOfTagging.mac"; double Tolerance = 0; bool UseMethod = false; bool AllowTagDuplicate = true; List <RecognizedHoles> RecognizedHolesList = null; //Get the template from the option page TagHoles.ExtractINIData(out MachineCells); TagHoles.GetActiveMachineCellInfos(MachineCell_Drop.Text, MachineCells, out CSVPath, out TemplateFolder, out Tolerance, out UseMethod, out bool DepthFromTop, out AllowTagDuplicate); foreach (string FeatureSet in listHoleFeatureSetSelected.Items) { PowerMILLAutomation.ExecuteEx("ACTIVATE Featureset '" + FeatureSet + "'"); if (TagOnly.IsChecked == true || TagAndTP.IsChecked == true) { PowerMILLAutomation.ExecuteEx("MACRO '" + RenameMacro + "'"); TagHoles.ExtractFeatureSetData(CSVPath, DepthFromTop, out HoleData, out List <DBHoleInfos> DBHoleData); TagHoles.MatchAndRenameHolesNew(FeatureSet, HoleData, DBHoleData, Tolerance, out RecognizedHolesList, out UnRecognizedHolesList); PowerMILLAutomation.ExecuteEx("MACRO '" + EndOfTagging + "'"); } if (TPOnly.IsChecked == true || TagAndTP.IsChecked == true) { TagHoles.GenerateToolpaths(directory, TemplateFolder, UseMethod); } MessageBox.Show("Process completed", "Hole Tagging Plugin"); } }
private void OK_Click(object sender, EventArgs e) { bool AllParametersOK = false; string Path = INIPath + "\\Settings.ini"; if (Database.Text != "" && Toolpath_Folder.Text != "" && Tolerance.Text != "") { AllParametersOK = true; } if (!AllParametersOK) { MessageBox.Show("Make sure you select a database, a toolpath folder and set a tolerance"); } else { if (File.Exists(Path)) { string Line = null; string TempFileName = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DrillingAutomation\\Temp.ini"; bool FoundMachine = false; bool NoMachine = true; //Get the template from the option page TagHoles.ExtractINIData(out MachineCells); if (File.Exists(TempFileName)) { File.Delete(TempFileName); } File.Copy(Path, TempFileName); File.Delete(Path); using (StreamReader reader = new StreamReader(TempFileName)) { using (StreamWriter writer = new StreamWriter(Path)) { while ((Line = reader.ReadLine()) != null) { if (Line != "") { if (Line.IndexOf(MachineCellCombo.Text) >= 0) { FoundMachine = true; NoMachine = false; writer.WriteLine(Line); writer.WriteLine("Database=" + Database.Text); writer.WriteLine("ToolpathFolder=" + Toolpath_Folder.Text); writer.WriteLine("Tolerance=" + Tolerance.Text); if (AllowTagDuplicate.Checked) { writer.WriteLine("AllowTagDuplicate=True"); } else { writer.WriteLine("AllowTagDuplicate=False"); } if (UseMethods.Checked) { writer.WriteLine("ToolpathORMethods=Methods"); } else { writer.WriteLine("ToolpathORMethods=Toolpaths"); } if (TopComponent.Checked) { writer.WriteLine("DepthReference=TopComponent"); } else { writer.WriteLine("DepthReference=TopHole"); } } else if (Line.IndexOf("[") >= 0) { FoundMachine = false; writer.WriteLine(Line); } else { if (!FoundMachine) { writer.WriteLine(Line); } } } } if (NoMachine) { if (MessageBox.Show("No machine cell with the same name was found, do you want to add a new one?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { writer.WriteLine("[" + MachineCellCombo.Text + "]"); writer.WriteLine("Database=" + Database.Text); writer.WriteLine("ToolpathFolder=" + Toolpath_Folder.Text); writer.WriteLine("Tolerance=" + Tolerance.Text); if (AllowTagDuplicate.Checked) { writer.WriteLine("AllowTagDuplicate=True"); } else { writer.WriteLine("AllowTagDuplicate=False"); } if (UseMethods.Checked) { writer.WriteLine("ToolpathORMethods=Methods"); } else { writer.WriteLine("ToolpathORMethods=Toolpaths"); } if (TopComponent.Checked) { writer.WriteLine("DepthReference=TopComponent"); } else { writer.WriteLine("DepthReference=TopHole"); } } } writer.Close(); } reader.Close(); } File.Delete(TempFileName); } else { using (StreamWriter writer = new StreamWriter(Path)) { writer.WriteLine("[" + MachineCellCombo.Text + "]"); writer.WriteLine("Database=" + Database.Text); writer.WriteLine("ToolpathFolder=" + Toolpath_Folder.Text); writer.WriteLine("Tolerance=" + Tolerance.Text); if (AllowTagDuplicate.Checked) { writer.WriteLine("AllowTagDuplicate=True"); } else { writer.WriteLine("AllowTagDuplicate=False"); } if (UseMethods.Checked) { writer.WriteLine("ToolpathORMethods=Methods"); } else { writer.WriteLine("ToolpathORMethods=Toolpaths"); } if (TopComponent.Checked) { writer.WriteLine("DepthReference=TopComponent"); } else { writer.WriteLine("DepthReference=TopHole"); } writer.Close(); } } } this.Close(); }
public void UpdateCSVFile(bool Modify) { string Line = null; string TempFileName = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DrillingAutomation\\Temp.csv"; string TemplateFolder = ""; double Tolerance = 0; bool UseMethod = false; string FullLine = ""; bool DepthFromTop = false; bool AllowTagDuplicate = true; //Get the template from the option page TagHoles.ExtractINIData(out MachineCells); TagHoles.GetActiveMachineCellInfos(MachineCell_Drop.Text, MachineCells, out CSVPath, out TemplateFolder, out Tolerance, out UseMethod, out DepthFromTop, out AllowTagDuplicate); if (File.Exists(TempFileName)) { File.Delete(TempFileName); } File.Copy(CSVPath, TempFileName); File.Delete(CSVPath); using (StreamReader reader = new StreamReader(TempFileName)) { using (StreamWriter writer = new StreamWriter(CSVPath)) { while ((Line = reader.ReadLine()) != null) { if (Line != "") { if (Line.Substring(0, 1) != "*") { // Split the Line string[] CurrentHole = Regex.Split(Line, ";"); if (CurrentHole.Count() >= 3) { if (CurrentHole[1] == HoleTypes.Text) { if (Modify) { HoleFullSignature(out FullLine, true); SearchForExistingHole(CSVPath, FullLine, Modify, AllowTagDuplicate, out bool HoleExist); if (HoleExist) { if (AllowTagDuplicate) { MessageBox.Show("Hole already exist in the database", "Error"); } else { MessageBox.Show("Hole tag already exist in the database", "Error"); } } else { writer.WriteLine(FullLine); } } continue; } } } writer.WriteLine(Line); } } writer.Close(); } reader.Close(); } File.Delete(TempFileName); TagHoles.ExtractNewDatabaseData(CSVPath, out DBHoleData); }
private void AddToDatabase_Click(object sender, RoutedEventArgs e) { string TemplateFolder = ""; string Path = System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Substring(8, System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Length - 8); string directory = System.IO.Path.GetDirectoryName(Path); double Tolerance = 0; bool UseMethod = false; bool DepthFromTop = false; bool AllowTagDuplicate = false; string FullLine = ""; SaveComponentData(int.Parse(HoleComponentCombo.Text), false); //Get the template from the option page TagHoles.ExtractINIData(out MachineCells); TagHoles.GetActiveMachineCellInfos(MachineCell_Drop.Text, MachineCells, out CSVPath, out TemplateFolder, out Tolerance, out UseMethod, out DepthFromTop, out AllowTagDuplicate); if (NCProgramListDB.Text == "") { MessageBox.Show("Please select a Featureset", "Error"); return; } if (UnrecognizedHolesCombo.Text == "") { MessageBox.Show("Please select an unrecognized hole", "Error"); return; } if (HoleTagADD.Text == "") { MessageBox.Show("Please set a tag name", "Error"); return; } if (HoleDescriptionADD.Text == "") { MessageBox.Show("Please set a description", "Error"); return; } PowerMILLAutomation.ExecuteEx("FORM CANCEL EDITHOLE"); SaveComponentData(int.Parse(HoleComponentCombo.Text), false); HoleFullSignature(out FullLine, false); SearchForExistingHole(CSVPath, FullLine, false, AllowTagDuplicate, out bool HoleExist); if (HoleExist) { if (AllowTagDuplicate) { MessageBox.Show("Hole already exist in the database", "Error"); } else { MessageBox.Show("Hole tag already exist in the database", "Error"); } } else { File.AppendAllText(CSVPath, Environment.NewLine + FullLine); CleanBlankSpaces(CSVPath); MessageBox.Show("Hole Successfully added to the database", "Information"); } }