コード例 #1
0
        private static Indirv parse_apt_indirv(string line)
        {
            Indirv indirv = new Indirv();

            switch (dt_flag)
            {
            case d_type.mastercam:    //apt line from mastercam
                string[] substrings = Regex.Split(line.Substring("INDIRV/".Length), ",");
                indirv.I = Convert.ToDouble(substrings[0].Replace(" ", string.Empty));
                indirv.J = Convert.ToDouble(substrings[1].Replace(" ", string.Empty));
                indirv.K = Convert.ToDouble(substrings[2].Replace(" ", string.Empty));
                break;

            case d_type.ptc_creo:    //apt line from ptc creo
                break;

            case d_type.siemens_nx:    //apt line from siemens nx
                break;

            default:
                break;
            }

            return(indirv);
        }
コード例 #2
0
        private static Circle parse_apt_circle(GoTo startpoint, Indirv indirv, string line_1, string line_2, string line_3)
        {
            Circle circle = new Circle();

            switch (dt_flag)
            {
            case d_type.mastercam:    //apt line from mastercam
                //getting center
                string[] substrings = Regex.Split(line_1.Substring(line_1.IndexOf("CIRCLE/") + "CIRCLE/".Length), ",");
                circle.Cx = Convert.ToDouble(substrings[0].Replace(" ", string.Empty));
                circle.Cy = Convert.ToDouble(substrings[1].Replace(" ", string.Empty));
                circle.Cz = Convert.ToDouble(substrings[2].Replace(" ", string.Empty));
                //getting radius
                circle.Radius = Convert.ToDouble(line_2.Substring(0, line_2.IndexOf(")") - 1).Replace(" ", string.Empty));
                //getting end point
                string[] substring_2 = line_3.Split(',');
                circle.X = Convert.ToDouble(substring_2[0].Replace(" ", string.Empty));
                circle.Y = Convert.ToDouble(substring_2[1].Replace(" ", string.Empty));
                circle.Z = Convert.ToDouble(substring_2[2].Replace(" ", string.Empty).Replace(")", string.Empty));

                bool d1 = false;
                bool d2 = true;

                //determines the direction of movement
                if (indirv.I <= 0 && indirv.J < 0)
                {
                    if (circle.Cx < startpoint.X && circle.Cy >= startpoint.Y)
                    {
                        circle.Direction = d1;    //CW
                    }
                    else if (circle.Cx > startpoint.X && circle.Cy <= startpoint.Y)
                    {
                        circle.Direction = d2;    //CCW
                    }
                }

                if (indirv.I < 0 && indirv.J >= 0)
                {
                    if (circle.Cx >= startpoint.X && circle.Cy > startpoint.Y)
                    {
                        circle.Direction = d1;    //CW
                    }
                    else if (circle.Cx <= startpoint.X && circle.Cy < startpoint.Y)
                    {
                        circle.Direction = d2;    //CCW
                    }
                }

                if (indirv.I >= 0 && indirv.J > 0)
                {
                    if (circle.Cx > startpoint.X && circle.Cy <= startpoint.Y)
                    {
                        circle.Direction = d1;    //CW
                    }
                    else if (circle.Cx < startpoint.X && circle.Cy >= startpoint.Y)
                    {
                        circle.Direction = d2;    //CCW
                    }
                }

                if (indirv.I > 0 && indirv.J <= 0)
                {
                    if (circle.Cx <= startpoint.X && circle.Cy < startpoint.Y)
                    {
                        circle.Direction = d1;    //CW
                    }
                    else if (circle.Cx >= startpoint.X && circle.Cy > startpoint.Y)
                    {
                        circle.Direction = d2;    //CCW
                    }
                }
                break;

            case d_type.ptc_creo:    //apt line from ptc creo
                break;

            case d_type.siemens_nx:    //apt line from siemens nx
                break;

            default:
                break;
            }

            return(circle);
        }
コード例 #3
0
        private static ToolpathGroup parse_toolpath_group(Queue <string> lines)
        {
            ToolpathGroup tpg = new ToolpathGroup();
            Indirv        current_indirv = new Indirv();
            string        cutter_line = "", tprint_line = "";
            GoTo          current_position = new GoTo();
            //double[] c_p = {0.0, 0.0, 0.0};
            string line;

            while (!lines.Peek().Contains("$$Machine Group-") && !lines.Peek().Contains("FINI"))
            {
                line = lines.Dequeue();

                if (line.Contains("PARTNO"))
                {
                    apt_data.PartNo = parse_apt_partno(line);
                    continue;
                }

                if (line.Contains("UNITS"))
                {
                    apt_data.Units = parse_apt_units(line);
                    continue;
                }

                if (line.Contains("MULTAX"))
                {
                    apt_data.Multax = parse_apt_multax(line);
                    continue;
                }

                /*
                 * if (line.Contains("MACHIN/"))
                 * {
                 *
                 *  continue;
                 * }
                 */

                if (line.Contains("CUTTER"))
                {
                    cutter_line = line;
                    continue;
                }

                if (line.Contains("TPRINT"))
                {
                    tprint_line = line;
                    continue;
                }

                if (line.Contains("LOAD"))
                {
                    LoadTL current_tool = parse_apt_loadtl(line);
                    if (!apt_data.CutterTools.ContainsKey(current_tool.ID))
                    {
                        CutterTool tool = new CutterTool();
                        tpg.Tool     = tool.ID = current_tool.ID;
                        tool.Label   = parse_apt_tprint(tprint_line);
                        tool.Tparams = parse_apt_cutter(cutter_line);
                        apt_data.CutterTools.Add(tool.ID, tool);
                    }
                    continue;
                }

                if (line.Contains("RAPID"))
                {
                    tpg.MachiningData.Add(new Rapid());
                    continue;
                }

                if (line.Contains("GOTO/"))
                {
                    current_position = parse_apt_goto(line);
                    tpg.MachiningData.Add(current_position);

                    continue;
                }

                if (line.Contains("INDIRV"))
                {
                    current_indirv = parse_apt_indirv(line);
                    tpg.MachiningData.Add(current_indirv);
                    continue;
                }

                if (line.Contains("CIRCLE/"))
                {
                    Circle current_circle = parse_apt_circle(current_position, current_indirv, line, lines.Dequeue(), lines.Dequeue());

                    current_position = new GoTo();

                    current_position.X = current_circle.X;
                    current_position.Y = current_circle.Y;
                    current_position.Z = current_circle.Z;

                    tpg.MachiningData.Add(current_circle);
                    continue;
                }

                if (line.Contains("FEDRAT"))
                {
                    tpg.MachiningData.Add(parse_apt_fedrate(line));
                    continue;
                }

                if (line.Contains("SPINDL"))
                {
                    tpg.MachiningData.Add(parse_apt_spinlespeed(line));
                    continue;
                }

                if (line.Contains("COOLNT"))
                {
                    tpg.MachiningData.Add(parse_apt_coolant(line));
                    continue;
                }
            }

            return(tpg);
        }