Esempio n. 1
0
        public static void GetToolpathLimits(string Toolpath, out double MinX, out double MinY, out double MinZ, out double MaxX, out double MaxY, out double MaxZ)
        {
            // Get NC prog Infos
            PowerMILLAutomation.Execute("DIALOGS MESSAGE OFF");
            string sSize = PowerMILLAutomation.ExecuteEx("SIZE TOOLPATH '" + Toolpath + "'");

            PowerMILLAutomation.Execute("DIALOGS MESSAGE ON");

            // Split the Line
            string[] sSizeInfos = Regex.Split(sSize, Environment.NewLine);// sProgCN.Split(Convert.ToChar("\n\r"));

            string[] sMinInfos = sSizeInfos[1].Split(new Char[] { ' ' });
            string[] sMaxInfos = sSizeInfos[2].Split(new Char[] { ' ' });

            MinX = 0;
            MinY = 0;
            MinZ = 0;

            for (int i = 0; i <= sMinInfos.Length - 1; i++)
            {
                if (!string.IsNullOrEmpty(sMinInfos[i].Trim()) && sMinInfos[i].Trim() != "Minimum:")
                {
                    if (MinX == 0)
                    {
                        MinX = double.Parse(sMinInfos[i].Trim());
                    }
                    else if (MinY == 0)
                    {
                        MinY = double.Parse(sMinInfos[i].Trim());
                    }
                    else if (MinZ == 0)
                    {
                        MinZ = double.Parse(sMinInfos[i].Trim());
                    }
                }
            }

            MaxX = 0;
            MaxY = 0;
            MaxZ = 0;

            for (int i = 0; i <= sMaxInfos.Length - 1; i++)
            {
                if (!string.IsNullOrEmpty(sMaxInfos[i].Trim()) && sMaxInfos[i].Trim() != "Maximum:")
                {
                    if (MaxX == 0)
                    {
                        MaxX = double.Parse(sMaxInfos[i].Trim());
                    }
                    else if (MaxY == 0)
                    {
                        MaxY = double.Parse(sMaxInfos[i].Trim());
                    }
                    else if (MaxZ == 0)
                    {
                        MaxZ = double.Parse(sMaxInfos[i].Trim());
                    }
                }
            }
        }
Esempio n. 2
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;
        }
Esempio n. 3
0
        private void UpdateFeatureSetForm(string ComponentName, int ComponentID)
        {
            int ComponentList = 0;

            foreach (TaggedHoles UnknownHole in UnRecognizedHolesList)
            {
                ComponentList = 0;
                foreach (NewHoleInfos Hole in HoleData)
                {
                    if (UnknownHole.HoleTag == Hole.HoleNumber.ToString() && UnknownHole.HoleName == UnrecognizedHolesCombo.Text && ComponentID == Hole.ComponentID)
                    {
                        UpperDiameterADD.Text = Math.Round(Hole.UpperDiameter, 4).ToString();
                        HoleDepthADD.Text     = Math.Round(Hole.Depth, 4).ToString();
                        LowerDiameterADD.Text = Math.Round(Hole.LowerDiameter, 4).ToString();
                        R_Color.Text          = Hole.RColor.ToString();
                        G_Color.Text          = Hole.GColor.ToString();
                        B_Color.Text          = Hole.BColor.ToString();
                    }
                    ComponentList = ComponentList + 1;
                }
            }
            PowerMILLAutomation.ExecuteEx("EDIT FEATURESET ; DESELECT ALL");
            PowerMILLAutomation.ExecuteEx("EDIT FEATURESET ; SELECT '" + ComponentName + "'");
            PowerMILLAutomation.ExecuteEx("ACTIVATE FEATURESET ; FORM EDITHOLE");
            PowerMILLAutomation.ExecuteEx("EDIT FEATURESET ; FEATURE SELECTION " + ComponentID);
        }
Esempio n. 4
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 + "'");
        }
Esempio n. 5
0
        //public ToolSheetPaneWPF()
        //{
        //    InitializeComponent();

        //}


        public DrillingAutomationPaneWPF(IPluginCommunicationsInterface comms)
        {
            InitializeComponent();

            oComm = comms;
            PowerMILLAutomation.SetVariables(oComm);

            // subscribe to some events
            comms.EventUtils.Subscribe(new EventSubscription("EntityCreated", EntityCreated));
            comms.EventUtils.Subscribe(new EventSubscription("EntityDeleted", EntityDeleted));
            comms.EventUtils.Subscribe(new EventSubscription("ProjectClosed", ProjectClosed));
            comms.EventUtils.Subscribe(new EventSubscription("ProjectOpened", ProjectOpened));
            comms.EventUtils.Subscribe(new EventSubscription("EntityRenamed", EntityRenamed));

            //LoadProjectComponents();
        }
Esempio n. 6
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");
            }
        }
Esempio n. 7
0
        public static List <string> GetNCProgToolpathes(string NCProgName)
        {
            List <string> sToolpathesList = new List <string>();

            // Get NC prog Infos
            PowerMILLAutomation.Execute("DIALOGS MESSAGE OFF");
            string sProgCN = PowerMILLAutomation.ExecuteEx("EDIT NCPROGRAM '" + NCProgName + "' LIST");

            PowerMILLAutomation.Execute("DIALOGS MESSAGE ON");

            // Split the Line
            string[] sTabCNInfos = Regex.Split(sProgCN, Environment.NewLine);// sProgCN.Split(Convert.ToChar("\n\r"));

            // Add NC prog to the List
            for (int i = 4; i <= sTabCNInfos.Length - 3; i++)
            {
                if (!string.IsNullOrEmpty(sTabCNInfos[i].Trim()))
                {
                    sToolpathesList.Add(sTabCNInfos[i]);
                }
            }

            return(sToolpathesList);
        }
Esempio n. 8
0
        public static List <string> GetListOf(enumEntity Entity)
        {
            List <string> oList = new List <string>();

            switch (Entity)
            {
            case enumEntity.MachineTools:
            {
                foreach (PowerMILL.MachineTool oEntity in oPServices.Project.MachineTools)
                {
                    oList.Add(oEntity.Name);
                }
                return(oList);
            }

            case enumEntity.NCPrograms:
            {
                foreach (PowerMILL.NCProgram oEntity in oPServices.Project.NCPrograms)
                {
                    oList.Add(oEntity.Name);
                }
                return(oList);
            }

            case enumEntity.Toolpaths:
            {
                foreach (PowerMILL.Toolpath oEntity in oPServices.Project.Toolpaths)
                {
                    oList.Add(oEntity.Name);
                }
                return(oList);
            }

            case enumEntity.Tools:
            {
                foreach (PowerMILL.Tool oEntity in oPServices.Project.Tools)
                {
                    oList.Add(oEntity.Name);
                }
                return(oList);
            }

            case enumEntity.Boundaries:
            {
                foreach (PowerMILL.Boundary oEntity in oPServices.Project.Boundaries)
                {
                    oList.Add(oEntity.Name);
                }
                return(oList);
            }

            case enumEntity.Patterns:
            {
                foreach (PowerMILL.Pattern oEntity in oPServices.Project.Patterns)
                {
                    oList.Add(oEntity.Name);
                }
                return(oList);
            }

            case enumEntity.FeatureSets:
            {
                foreach (PowerMILL.FeatureSet oEntity in oPServices.Project.FeatureSets)
                {
                    oList.Add(oEntity.Name);
                }
                return(oList);
            }

            case enumEntity.Workplanes:
            {
                foreach (PowerMILL.Workplane oEntity in oPServices.Project.Workplanes)
                {
                    oList.Add(oEntity.Name);
                }
                return(oList);
            }

            case enumEntity.Models:
            {
                foreach (PowerMILL.Model oEntity in oPServices.Project.Models)
                {
                    oList.Add(oEntity.Name);
                }
                return(oList);
            }

            case enumEntity.MachinableModels:
            {
                foreach (PowerMILL.Model oEntity in oPServices.Project.Models)
                {
                    string isReference = PowerMILLAutomation.ExecuteEx("print $entity('model';'" + oEntity.Name + "').IsReferenceModel");
                    if (isReference == "0")
                    {
                        oList.Add(oEntity.Name);
                    }
                }
                return(oList);
            }

            case enumEntity.StockModels:
            {
                foreach (PowerMILL.StockModel oEntity in oPServices.Project.StockModels)
                {
                    oList.Add(oEntity.Name);
                }
                return(oList);
            }

            default:
            {
                throw new Exception("Unknown entity (GetListOf): " + Entity.ToString());
            }
            }
        }
Esempio n. 9
0
        public static void GetModelsLimits(List <string> ModelList, out double MinX, out double MinY, out double MinZ, out double MaxX, out double MaxY, out double MaxZ)
        {
            bool FoundX = false;
            bool FoundY = false;

            // Get NC prog Infos
            PowerMILLAutomation.Execute("DIALOGS MESSAGE OFF");

            MinX = 10000;
            MinY = 10000;
            MinZ = 10000;
            MaxX = -10000;
            MaxY = -10000;
            MaxZ = -10000;

            foreach (string Model in ModelList)
            {
                string sSize = PowerMILLAutomation.ExecuteEx("SIZE MODEL '" + Model + "'");

                // Split the Line
                string[] sSizeInfos = Regex.Split(sSize, Environment.NewLine);// sProgCN.Split(Convert.ToChar("\n\r"));

                string[] sMinInfos = sSizeInfos[2].Split(new Char[] { ' ' });
                string[] sMaxInfos = sSizeInfos[3].Split(new Char[] { ' ' });
                FoundX = false;
                FoundY = false;

                for (int i = 0; i <= sMinInfos.Length - 1; i++)
                {
                    if (!string.IsNullOrEmpty(sMinInfos[i].Trim()) && sMinInfos[i].Trim() != "Minimum:")
                    {
                        if (double.Parse(sMinInfos[i].Trim()) < MinX && FoundX == false)
                        {
                            MinX   = double.Parse(sMinInfos[i].Trim());
                            FoundX = true;
                        }
                        else if (double.Parse(sMinInfos[i].Trim()) < MinY && FoundX && FoundY == false)
                        {
                            MinY   = double.Parse(sMinInfos[i].Trim());
                            FoundY = true;
                        }
                        else if (double.Parse(sMinInfos[i].Trim()) < MinZ && FoundX && FoundY)
                        {
                            MinZ = double.Parse(sMinInfos[i].Trim());
                        }
                    }
                }

                FoundX = false;
                FoundY = false;
                for (int i = 0; i <= sMaxInfos.Length - 1; i++)
                {
                    if (!string.IsNullOrEmpty(sMaxInfos[i].Trim()) && sMaxInfos[i].Trim() != "Maximum:")
                    {
                        if (double.Parse(sMaxInfos[i].Trim()) > MaxX && FoundX == false)
                        {
                            MaxX   = double.Parse(sMaxInfos[i].Trim());
                            FoundX = true;
                        }
                        else if (double.Parse(sMaxInfos[i].Trim()) > MaxY && FoundX && FoundY == false)
                        {
                            MaxY   = double.Parse(sMaxInfos[i].Trim());
                            FoundY = true;
                        }
                        else if (double.Parse(sMaxInfos[i].Trim()) > MaxZ && FoundX && FoundY)
                        {
                            MaxZ = double.Parse(sMaxInfos[i].Trim());
                        }
                    }
                }
            }



            PowerMILLAutomation.Execute("DIALOGS MESSAGE ON");
        }
Esempio n. 10
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");
            }
        }