示例#1
0
        public void AddFile(string L)
        {
            var T = GerberLibrary.Gerber.FindFileType(L);

            switch (T)
            {
            case GerberLibrary.Core.BoardFileType.Drill:
            {
                GerberLibrary.ExcellonFile EF = new GerberLibrary.ExcellonFile();
                EF.Load(L);
                DrillCount += EF.TotalDrillCount();
            }
            break;

            case GerberLibrary.Core.BoardFileType.Gerber:
            {
                GerberLibrary.Core.BoardSide  Side;
                GerberLibrary.Core.BoardLayer Layer;
                GerberLibrary.Gerber.DetermineBoardSideAndLayer(L, out Side, out Layer);
                if (Layer == GerberLibrary.Core.BoardLayer.Outline || Layer == GerberLibrary.Core.BoardLayer.Mill)
                {
                    var G = GerberLibrary.PolyLineSet.LoadGerberFile(L);
                    Box.AddBox(G.BoundingBox);
                }
                else
                {
                    var G = GerberLibrary.PolyLineSet.LoadGerberFile(L);
                }
            }
            break;
            }
        }
示例#2
0
        private void WriteContained(PolyLine boundary, string outputfilename, ProgressLog log)
        {
            ExcellonFile Out = new ExcellonFile();

            foreach (var T in Tools)
            {
                Out.Tools[T.Key] = new ExcellonTool()
                {
                    ID = T.Value.ID, Radius = T.Value.Radius
                };
                foreach (var d in T.Value.Drills)
                {
                    if (boundary.PointInPoly(new PointD(d.X, d.Y)))
                    {
                        Out.Tools[T.Key].Drills.Add(d);
                    }
                }
                foreach (var d in T.Value.Slots)
                {
                    if (boundary.PointInPoly(d.Start) || boundary.PointInPoly(d.End))
                    {
                        Out.Tools[T.Key].Slots.Add(d);
                    }
                }
            }

            Out.Write(outputfilename, 0, 0, 0, 0);
        }
示例#3
0
        public void AddFile(MemoryStream L, string filename)
        {
            L.Seek(0, SeekOrigin.Begin);

            var T = GerberLibrary.Gerber.FindFileTypeFromStream(new StreamReader(L), filename);

            switch (T)
            {
            case GerberLibrary.Core.BoardFileType.Drill:
            {
                GerberLibrary.ExcellonFile EF = new GerberLibrary.ExcellonFile();
                L.Seek(0, SeekOrigin.Begin);

                EF.Load(new StreamReader(L));
                DrillCount += EF.TotalDrillCount();
            }
            break;

            case GerberLibrary.Core.BoardFileType.Gerber:
            {
                GerberLibrary.Core.BoardSide  Side;
                GerberLibrary.Core.BoardLayer Layer;
                GerberLibrary.Gerber.DetermineBoardSideAndLayer(filename, out Side, out Layer);
                if (Layer == GerberLibrary.Core.BoardLayer.Outline || Layer == GerberLibrary.Core.BoardLayer.Mill)
                {
                    L.Seek(0, SeekOrigin.Begin);
                    var G = GerberLibrary.PolyLineSet.LoadGerberFileFromStream(new StreamReader(L), filename);
                    Box.AddBox(G.BoundingBox);
                }
            }
            break;
            }
        }
示例#4
0
        private static void MultiMerge(string file1, List <string> otherfiles, string output, ProgressLog Log)
        {
            int MM = Log.PushActivity("Excellon MultiMerge");

            if (File.Exists(file1) == false)
            {
                Log.AddString(String.Format("{0} not found! stopping process!", file1));
                Log.PopActivity(MM);
                return;
            }
            foreach (var otherfile in otherfiles)
            {
                if (File.Exists(otherfile) == false)
                {
                    Log.AddString(String.Format("{0} not found! stopping process!", otherfile));
                    Log.PopActivity(MM);
                    return;
                }
            }

            Log.AddString(String.Format("Reading {0}:", file1));
            ExcellonFile File1Parsed = new ExcellonFile();

            File1Parsed.Load(Log, file1);
            List <ExcellonFile> OtherFilesParsed = new List <ExcellonFile>();

            foreach (var otherfile in otherfiles)
            {
                Log.AddString(String.Format("Reading {0}:", otherfile));
                ExcellonFile OtherFileParsed = new ExcellonFile();
                OtherFileParsed.Load(Log, otherfile);
                OtherFilesParsed.Add(OtherFileParsed);
            }
            int MaxID = 0;

            foreach (var D in File1Parsed.Tools)
            {
                if (D.Value.ID > MaxID)
                {
                    MaxID = D.Value.ID + 1;
                }
            }
            foreach (var F in OtherFilesParsed)
            {
                foreach (var D in F.Tools)
                {
                    File1Parsed.AddToolWithHoles(D.Value);;
                    //                D.Value.ID += MaxID;
                    //              File1Parsed.Tools[D.Value.ID] = D.Value;
                }
            }
            File1Parsed.Write(output, 0, 0, 0, 0);

            Log.PopActivity(MM);
        }
示例#5
0
        public static void WriteContainedOnly(string inputfile, PolyLine Boundary, string outputfilename, ProgressLog Log)
        {
            if (File.Exists(inputfile) == false)
            {
                Console.WriteLine("{0} not found! stopping process!", Path.GetFileName(inputfile));
                return;
            }
            Log.AddString(String.Format("Clipping {0} to {1}", Path.GetFileName(inputfile), Path.GetFileName(outputfilename)));

            ExcellonFile EF = new ExcellonFile();

            EF.Load(Log, inputfile);
            EF.WriteContained(Boundary, outputfilename, Log);
        }
示例#6
0
        private static void MultiMerge(string file1, List <string> otherfiles, string output, IProgressLog log)
        {
            if (File.Exists(file1) == false)
            {
                Console.WriteLine("{0} not found! stopping process!", file1);
                return;
            }
            foreach (var otherfile in otherfiles)
            {
                if (File.Exists(otherfile) == false)
                {
                    Console.WriteLine("{0} not found! stopping process!", otherfile);
                    return;
                }
            }

            Console.WriteLine("*** Reading {0}:", file1);
            ExcellonFile file1Parsed = new ExcellonFile();

            file1Parsed.Load(file1);
            List <ExcellonFile> otherFilesParsed = new List <ExcellonFile>();

            foreach (var otherfile in otherfiles)
            {
                Console.WriteLine("*** Reading {0}:", otherfile);
                ExcellonFile otherFileParsed = new ExcellonFile();
                otherFileParsed.Load(otherfile);
                otherFilesParsed.Add(otherFileParsed);
            }
            int maxID = 0;

            foreach (var D in file1Parsed.Tools)
            {
                if (D.Value.ID > maxID)
                {
                    maxID = D.Value.ID + 1;
                }
            }
            foreach (var F in otherFilesParsed)
            {
                foreach (var D in F.Tools)
                {
                    file1Parsed.AddToolWithHoles(D.Value);;
                    // D.Value.ID += MaxID;
                    // File1Parsed.Tools[D.Value.ID] = D.Value;
                }
            }
            file1Parsed.Write(output, 0, 0, 0, 0);
        }
示例#7
0
        public static void Merge(string file1, string file2, string outputfile, ProgressLog Log)
        {
            Log.PushActivity("Excellon Merge");
            if (File.Exists(file1) == false)
            {
                Log.AddString(String.Format("{0} not found! stopping process!", file1));
                Log.PopActivity();
                return;
            }

            if (File.Exists(file2) == false)
            {
                Log.AddString(String.Format("{0} not found! stopping process!", file2));
                Log.PopActivity();
                return;
            }

            Log.AddString(String.Format("Reading {0}:", file1));
            ExcellonFile File1Parsed = new ExcellonFile();

            File1Parsed.Load(Log, file1);
            Log.AddString(String.Format("Reading {0}:", file2));
            ExcellonFile File2Parsed = new ExcellonFile();

            File2Parsed.Load(Log, file2);

            Log.AddString(String.Format("Merging {0} with {1}", file1, file2));

            int MaxID = 0;

            foreach (var D in File1Parsed.Tools)
            {
                if (D.Value.ID > MaxID)
                {
                    MaxID = D.Value.ID + 1;
                }
            }

            foreach (var D in File2Parsed.Tools)
            {
                D.Value.ID += MaxID;
                File1Parsed.Tools[D.Value.ID] = D.Value;
            }

            File1Parsed.Write(outputfile, 0, 0, 0, 0);

            Log.PopActivity();
        }
        public List <string> Write(string targetfolder, string basename, PointD offset = null)
        {
            if (offset == null)
            {
                offset = new PointD(0, 0);
            }

            List <string> Files      = new List <string>();
            ExcellonFile  EF         = new ExcellonFile();
            int           drillcount = 0;

            foreach (var h in DrillHoles)
            {
                ExcellonTool DrillBit = new ExcellonTool();
                DrillBit.Radius = h.Key / 2.0f;

                foreach (var a in h.Value)
                {
                    DrillBit.Drills.Add(a);
                }
                EF.Tools[10 + drillcount] = DrillBit;
                drillcount++;
            }
            string DrillFile = Path.Combine(targetfolder, basename + ".txt");

            EF.Write(DrillFile, offset.X, offset.Y, 0, 0);
            Files.Add(DrillFile);

            string OutName = Path.Combine(targetfolder, basename);

            Outline.Write(OutName + ".gko", offset); Files.Add(OutName + ".gko");
            TopSilk.Write(OutName + ".gto", offset); Files.Add(OutName + ".gto");
            TopCopper.Write(OutName + ".gtl", offset); Files.Add(OutName + ".gtl");

            TopSolderMask.Write(OutName + ".gts", offset); Files.Add(OutName + ".gts");

            BottomSilk.Write(OutName + ".gbo", offset); Files.Add(OutName + ".gbo");
            BottomCopper.Write(OutName + ".gbl", offset); Files.Add(OutName + ".gbl");
            BottomSolderMask.Write(OutName + ".gbs", offset); Files.Add(OutName + ".gbs");


            return(Files);
        }
示例#9
0
        public static void Merge(string file1, string file2, string outputfile, IProgressLog log)
        {
            if (File.Exists(file1) == false)
            {
                Console.WriteLine("{0} not found! stopping process!", file1);
                return;
            }
            if (File.Exists(file2) == false)
            {
                Console.WriteLine("{0} not found! stopping process!", file2);
                return;
            }
            log.AddString(String.Format("*** Merging {0} with {1}", file1, file2));

            Console.WriteLine("*** Reading {0}:", file1);
            ExcellonFile file1Parsed = new ExcellonFile();

            file1Parsed.Load(file1);
            Console.WriteLine("*** Reading {0}:", file2);
            ExcellonFile file2Parsed = new ExcellonFile();

            file2Parsed.Load(file2);

            int MaxID = 0;

            foreach (var D in file1Parsed.Tools)
            {
                if (D.Value.ID > MaxID)
                {
                    MaxID = D.Value.ID + 1;
                }
            }

            foreach (var D in file2Parsed.Tools)
            {
                D.Value.ID += MaxID;
                file1Parsed.Tools[D.Value.ID] = D.Value;
            }

            file1Parsed.Write(outputfile, 0, 0, 0, 0);
        }
示例#10
0
        public List <string> Write(string targetfolder, string basename, BOM inFiducialBom, PointD offset = null)
        {
            if (offset == null)
            {
                offset = new PointD(0, 0);
            }

            List <string> Files      = new List <string>();
            ExcellonFile  EF         = new ExcellonFile();
            int           drillcount = 0;

            foreach (var h in DrillHoles)
            {
                ExcellonTool DrillBit = new ExcellonTool();
                DrillBit.Radius = h.Key / 2.0f;

                foreach (var a in h.Value)
                {
                    DrillBit.Drills.Add(a);
                }
                EF.Tools[10 + drillcount] = DrillBit;
                drillcount++;
            }
            string DrillFile = Path.Combine(targetfolder, basename + ".txt");

            EF.Write(DrillFile, offset.X, offset.Y, 0, 0);
            Files.Add(DrillFile);

            string OutName = Path.Combine(targetfolder, basename);

            Outline.Write(OutName + ".gko", offset); Files.Add(OutName + ".gko");
            TopSilk.Write(OutName + ".gto", offset); Files.Add(OutName + ".gto");
            TopCopper.Write(OutName + ".gtl", offset); Files.Add(OutName + ".gtl");

            TopSolderMask.Write(OutName + ".gts", offset); Files.Add(OutName + ".gts");

            BottomSilk.Write(OutName + ".gbo", offset); Files.Add(OutName + ".gbo");
            BottomCopper.Write(OutName + ".gbl", offset); Files.Add(OutName + ".gbl");
            BottomSolderMask.Write(OutName + ".gbs", offset); Files.Add(OutName + ".gbs");

            BOM FiducialBom;

            if (inFiducialBom != null)
            {
                FiducialBom = inFiducialBom;
            }
            else
            {
                FiducialBom = new BOM();
            }

            BOMNumberSet set = new BOMNumberSet();
            int          fd  = 1;

            foreach (var a in Fiducials)
            {
                FiducialBom.AddBOMItemExt("FIDUCIAL_" + a.Style.ToString(), "FIDUCIAL_" + a.Style.ToString(), a.Style.ToString(), "__FD" + (fd.ToString()), set, "Frame_" + basename, a.Pos.X + offset.X, a.Pos.Y + offset.Y, 0, a.Side);
            }
            FiducialBom.WriteJLCCSV(targetfolder, basename + "_fiducials");

            return(Files);
        }