Exemple #1
0
        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;
        }
Exemple #2
0
        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 + "'");
        }
Exemple #3
0
        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();
        }
Exemple #4
0
        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");
            }
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        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");
            }
        }