示例#1
0
        public void WriteSTEPNC(MetaData metadata, string outname)
        {
            STEPNCLib.AptStepMaker stnc = new STEPNCLib.AptStepMaker();

            stnc.NewProjectWithCCandWP(metadata.PartNo, 1, "Main Workplan");//make new project

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

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

            Cutter[] tools = new Cutter[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].Diameter, tools[i].Diameter / 2, 10.0, 10.0, 1.0, 0.0, 45.0);
            }

            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 (MachiningData mchData in toolpahtGroup.MachiningData)
                    {
                        if (mchData is Rapid)
                        {
                            stnc.Rapid();
                        }
                        if (mchData is GoTo)
                        {
                            GoTo temp = mchData as GoTo;
                            stnc.GoToXYZ("point", temp.point.X, temp.point.Y, temp.point.Z);
                        }
                        if (mchData is Circle)
                        {
                            Circle temp = mchData as Circle;
                            stnc.ArcXYPlane("arc", temp.endpoint.X, temp.endpoint.Y, temp.endpoint.Z, temp.center.X, temp.center.Y, temp.center.Z, temp.radius, 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.SaveAsP21(outname);
            return;
        }