Exemple #1
0
        static CLIHatches parsehatches(String line)
        {
            CLIHatches    h      = new CLIHatches();
            List <String> values = new List <String>(line.Split(','));

            if (values[0].Contains("$$HATCHES/"))
            {
                values[0] = values[0].Substring("$$HATCHES/".Length);
            }
            h.id = Convert.ToInt32(values[0]);
            values.RemoveAt(0);
            //Parse count.
            h.numberofhatches = Convert.ToInt32(values[0]);
            values.RemoveAt(0);
            for (int i = 0; i < h.numberofhatches; i++)
            {
                CLIHatch hatch = new CLIHatch();
                hatch.startx = Convert.ToInt32(values[0]);
                hatch.starty = Convert.ToInt32(values[1]);
                hatch.endx   = Convert.ToInt32(values[2]);
                hatch.endy   = Convert.ToInt32(values[3]);
                h.hatches.Add(hatch);
                values.RemoveRange(0, 4);
            }
            return(h);
        }
Exemple #2
0
        static void CreateNCFile(List <Layer> layers, string outname, double unitsmultiplier, double[] focii)
        {
            STEPNCLib.AptStepMaker asm = new STEPNCLib.AptStepMaker();
            asm.NewProjectWithCCandWP(outname, 4, "Main");
            asm.Millimeters();
            int toolcount = 1;
            Dictionary <double, int> focustoolmap = new Dictionary <double, int>(); //Map focus to tools.

            foreach (double focus in focii)                                         //Make tools.
            {
                asm.DefineTool(focus, 1, 1, 1, 1, 1, 1);
                asm.SELCTLTool(toolcount);
                asm.SetToolIdentifier(Convert.ToString(toolcount), Convert.ToString(toolcount));
                //asm.ToolGeometry("ROD.stp", Convert.ToString(toolcount));
                focustoolmap[focus] = toolcount;
                toolcount++;
            }
            int i = 0;

            foreach (Layer layer in layers)
            {
                asm.NestWorkplan(String.Format("Layer {0}", i));
                foreach (GeomData operation in layer.operations)
                {
                    asm.LoadTool(focustoolmap[operation.MetaData.focus]);
                    if (operation is CLIHatches)
                    {
                        asm.Workingstep(String.Format("Layer {0} Hatching", i));
                        asm.Rapid();
                        bool       firstop = true;
                        CLIHatches tmp     = operation as CLIHatches;
                        foreach (CLIHatch hatch in tmp.hatches)
                        {
                            if (firstop)
                            {
                                asm.GoToXYZ("HatchStart", hatch.startx * unitsmultiplier, hatch.starty * unitsmultiplier, layer.height * unitsmultiplier);
                                asm.Feedrate(operation.MetaData.speed);
                                asm.SpindleSpeed(operation.MetaData.power);
                                firstop = false;
                            }
                            else
                            {
                                asm.GoToXYZ("HatchStart", hatch.startx * unitsmultiplier, hatch.starty * unitsmultiplier, layer.height * unitsmultiplier);
                            }
                            asm.GoToXYZ("HatchEnd", hatch.endx * unitsmultiplier, hatch.endy * unitsmultiplier, layer.height * unitsmultiplier);
                        }
                    }
                    if (operation is Polyline)
                    {
                        asm.Workingstep(String.Format("Layer {0} Polyline", i));
                        bool firstop = true;
                        asm.Rapid();
                        Polyline tmp = operation as Polyline;
                        for (var j = 0; j < tmp.numberofpoints; j++)
                        {
                            if (firstop)
                            {
                                asm.GoToXYZ(String.Format("PolylinePt{0}", j), tmp.points[j].x * unitsmultiplier, tmp.points[j].y * unitsmultiplier, layer.height * unitsmultiplier);
                                asm.SpindleSpeed(operation.MetaData.power);
                                asm.Feedrate(operation.MetaData.speed);
                                firstop = false;
                            }
                            else
                            {
                                asm.GoToXYZ(String.Format("PolylinePt{0}", j), tmp.points[j].x * unitsmultiplier, tmp.points[j].y * unitsmultiplier, layer.height * unitsmultiplier);
                            }
                        }
                    }
                }
                i++;
                asm.EndWorkplan();
            }
            asm.SaveAsModules(outname);
            return;
        }