Example #1
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);
        }
Example #2
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);
        }
Example #3
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);
        }
Example #4
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);
        }
Example #6
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);
        }
Example #7
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);
        }