Пример #1
0
        public void KojtoCAD_3D_Node_To_CNC()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            Matrix3d old = ed.CurrentUserCoordinateSystem;

            ed.CurrentUserCoordinateSystem = Matrix3d.Identity;

            try
            {
                if ((container != null) && (container.Nodes.Count > 0))
                {
                    CNC_Settings form = new CNC_Settings();
                    form.ShowDialog();
                    if (form.DialogResult == DialogResult.OK)
                    {
                        PromptStringOptions pStrOpts = new PromptStringOptions("\nEnter Project name <" + ConstantsAndSettings.ProjectName.Trim() + ">: ");
                        pStrOpts.AllowSpaces = true;
                        PromptResult pStrRes = Application.DocumentManager.MdiActiveDocument.Editor.GetString(pStrOpts);
                        if (pStrRes.Status == PromptStatus.OK)
                        {
                            string pjName = pStrRes.StringResult;
                            if (pjName == "")
                            {
                                pjName = ConstantsAndSettings.ProjectName;
                            }

                            PromptStringOptions pStrOpts_ = new PromptStringOptions("\nEnter Material Name <St3>: ");
                            pStrOpts_.AllowSpaces = true;
                            PromptResult pStrRes_ = Application.DocumentManager.MdiActiveDocument.Editor.GetString(pStrOpts_);
                            if (pStrRes_.Status == PromptStatus.OK)
                            {
                                string matName = pStrRes_.StringResult;
                                if (matName == "")
                                {
                                    matName = "St3";
                                }

                                FolderBrowserDialog dlg = new FolderBrowserDialog();
                                if (dlg.ShowDialog() == DialogResult.OK)
                                {
                                    if ((container != null) && (container.Nodes.Count > 0))
                                    {
                                        foreach (WorkClasses.Node node in container.Nodes)
                                        {
                                            NodeToCNC(dlg.SelectedPath + "\\", node.Numer, form.L, form.Lp, form.Ls, form.R, form.toolR, pjName, form.Workpiece_Length, form.Workpiece_Width, form.Workpiece_Height, matName, " MILLM550, FANUC 0-MC", "4,5OS", "X-300.",
                                                      "/M6T13(FREZA 36-SANDVIK)", "H13G0Z150.", "G0 X0 Y170.");
                                        }

                                        MessageBox.Show("Files were Created Successfully !", "CNC Files", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    }
                                    else
                                    {
                                        MessageBox.Show("Node missing !", "Range Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Data Base Missing !", "E R R O R", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch { }
            finally { ed.CurrentUserCoordinateSystem = old; }
        }
Пример #2
0
        public void KojtoCAD_3D_Node_To_Csv()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            Matrix3d old = ed.CurrentUserCoordinateSystem;

            ed.CurrentUserCoordinateSystem = Matrix3d.Identity;

            try
            {
                if (container != null)
                {
                    if (container.Nodes.Count > 0)
                    {
                        SaveFileDialog dlg = new SaveFileDialog();
                        dlg.Filter     = "CSV or Text Files|*.csv;*.txt|Text Files|*.txt|Office Files|*.doc|All Files|*.*";
                        dlg.Title      = "Enter CSV File Name ";
                        dlg.DefaultExt = "csv";
                        dlg.FileName   = "*.csv";
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            string fileName = dlg.FileName;

                            CNC_Settings form = new CNC_Settings();
                            form.ShowDialog();
                            if (form.DialogResult == DialogResult.OK)
                            {
                                using (StreamWriter sw = new StreamWriter(fileName))
                                {
                                    #region firstline
                                    int max = 0;
                                    foreach (WorkClasses.Node Node in container.Nodes)
                                    {
                                        if (Node.Bends_Numers_Array.Count > max)
                                        {
                                            max = Node.Bends_Numers_Array.Count;
                                        }
                                    }
                                    string LINE = "NodeNumer ; Position ;";
                                    for (int i = 0; i < max; i++)
                                    {
                                        LINE += " bendNumer ; ; cota +/- ; alpha ; beta ; gama ; deltaX ; deltaZ ; Z1 ; Z2 ;";
                                    }
                                    sw.WriteLine(LINE);
                                    #endregion
                                    foreach (WorkClasses.Node Node in container.Nodes)
                                    {
                                        string line = (Node.Numer + 1).ToString() + " ;";

                                        bool perereferial = false;
                                        foreach (int nN in Node.Bends_Numers_Array)
                                        {
                                            if (container.Bends[nN].IsPeripheral())
                                            {
                                                perereferial = true;
                                                break;
                                            }
                                        }
                                        if (perereferial)
                                        {
                                            line += "Pereferial ;";
                                        }
                                        else
                                        {
                                            line += " NoPereferial ;";
                                        }

                                        CNC_bends(ref line, Node, form.L, form.Lp, form.Ls, form.R, form.toolR, form.Workpiece_Length, form.Workpiece_Width, form.Workpiece_Height);

                                        sw.WriteLine(line);
                                    }

                                    sw.Flush();
                                    sw.Close();
                                    MessageBox.Show("The File is saved successfully !", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("\nData Base Empty !\n\nMissing Nodes !", "Range Error !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("\nData Base Empty !\n\nMissing Nodes !", "Range Error !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch { }
            finally { ed.CurrentUserCoordinateSystem = old; }
        }