Esempio n. 1
0
        private static Feedrate parse_apt_fedrate(string line)
        {
            Feedrate fedrate = new Feedrate();

            switch (dt_flag)
            {
            case d_type.mastercam:    //apt line from mastercam
                string[] substrings = Regex.Split(line.Substring("FEDRAT/".Length), ",");
                fedrate.Fedrat = Convert.ToDouble(substrings[1].Replace(" ", string.Empty));
                fedrate.Unit   = substrings[0].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(fedrate);
        }
Esempio n. 2
0
        private static void apt_to_stepnc(MetaData metadata, string outname)
        {
            double multiplier = 1;

            STEPNCLib.AptStepMaker stnc    = new STEPNCLib.AptStepMaker();
            STEPNCLib.Feature      feature = new STEPNCLib.Feature();
            STEPNCLib.Process      process = new STEPNCLib.Process();

            stnc.NewProjectWithCCandWP(metadata.PartNo.partno(), 1, "Main Workplan");//make new project
            //feature.OpenNewWorkpiece("mastercam");
            process.BlockRawpiece("mastercam block", 0, 0, 0, 70, 100, 50);

            //if (metadata.Units == "IN" || metadata.Units == "Inches")
            //    stnc.Inches();
            //else
            //    stnc.Millimeters();

            stnc.Millimeters();

            if (metadata.Multax.multax() == "ON")
            {
                stnc.MultaxOn();
            }

            stnc.CamModeOn();
            stnc.MultaxOn();

            stnc.SetModeMill();

            CutterTool[] tools = new CutterTool[metadata.CutterTools.Keys.Count];

            metadata.CutterTools.Values.CopyTo(tools, 0);

            for (int i = 0; i < tools.Length; i++)//define all tools
            {
                stnc.DefineTool(tools[i].Tparams.Diameter * multiplier, tools[i].Tparams.Diameter / 2 * multiplier, 10.0 * multiplier, 10.0 * multiplier, 1.0 * multiplier, 0.0, 45.0 * multiplier);
            }
            //stnc.Millimeters();
            foreach (MachineGroup machineGroup in metadata.MachineGroups)
            {
                stnc.NestWorkplan("Machine Group-" + machineGroup.ID.ToString());

                foreach (ToolpathGroup toolpahtGroup in machineGroup.Operations)
                {
                    stnc.LoadTool(toolpahtGroup.Tool);//load tool associated with the current operation
                    stnc.Workingstep("WS-" + toolpahtGroup.ID.ToString());

                    foreach (APT mchData in toolpahtGroup.MachiningData)
                    {
                        if (mchData is Rapid)
                        {
                            stnc.Rapid();
                        }
                        if (mchData is GoTo)
                        {
                            GoTo temp = mchData as GoTo;
                            stnc.GoToXYZ("point", temp.X * multiplier, temp.Y * multiplier, temp.Z * multiplier);
                            //Console.WriteLine("{0},{1},{2}",temp.X,temp.Y,temp.Z);
                        }
                        if (mchData is Circle)
                        {
                            Circle temp = mchData as Circle;
                            //Console.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7}", temp.X, temp.Y, temp.Z, temp.Cx, temp.Cy, temp.Cz, temp.Radius, temp.Direction);
                            stnc.ArcXYPlane("arc", temp.X * multiplier, temp.Y * multiplier, temp.Z * multiplier, temp.Cx * multiplier, temp.Cy * multiplier, temp.Cz * multiplier, temp.Radius * multiplier, temp.Direction);
                        }
                        if (mchData is Feedrate)
                        {
                            Feedrate temp = mchData as Feedrate;
                            stnc.Feedrate(temp.Fedrat);
                        }
                        if (mchData is SpindleSpeed)
                        {
                            SpindleSpeed temp = mchData as SpindleSpeed;
                            stnc.SpindleSpeed(temp.Spindlespeed);
                        }
                        if (mchData is Coolant)
                        {
                            Coolant temp = mchData as Coolant;
                            if (temp.Activation)
                            {
                                stnc.CoolantOn();
                            }
                            else
                            {
                                stnc.CoolantOff();
                            }
                        }
                    }
                }
                stnc.EndWorkplan();
            }
            //stnc.SaveFastAsModules(outname);
            stnc.SaveAsP21(outname);
            //stnc.SaveAsModules(outname);
            return;
        }