Esempio n. 1
0
        public static void MakeBomAndPlacement(string a)
        {
            string BaseFolder = Path.GetDirectoryName(a);
            string Name       = Path.GetFileNameWithoutExtension(a);

            string FactoryFolder = Path.Combine(BaseFolder, "Factory");

            if (Directory.Exists(FactoryFolder) == false)
            {
                Directory.CreateDirectory(FactoryFolder);
            }

            string BoardFactoryFolder = Path.Combine(FactoryFolder, Name);

            if (Directory.Exists(BoardFactoryFolder) == false)
            {
                Directory.CreateDirectory(BoardFactoryFolder);
            }

            Console.WriteLine("Exporting {0} in {1} to {2}", Name, BaseFolder, BoardFactoryFolder);

            GerberLibrary.Core.BOM TheBOM = new GerberLibrary.Core.BOM();


            string schname = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(a), Name + ".sch");

            if (File.Exists(schname))
            {
                try
                {
                    Eagle.EagleLoader Brd = new Eagle.EagleLoader(a);

                    var Sch = new Eagle.EagleLoader(schname);



                    foreach (var p in Brd.DevicePlacements)
                    {
                        var SchDev = Sch.FindPlacement(p.device);
                        if (SchDev != null)
                        {
                            p.deviceset = SchDev.deviceset;
                            TheBOM.AddBOMItemExt(p.package, p.deviceset, p.value, p.device, null, Name, p.x, p.y, p.rot.Degrees, p.rot.Mirrored ? BoardSide.Bottom : BoardSide.Top);
                        }
                        else
                        {
                            Console.WriteLine(" {0} not found in schematic?? ", p.device);
                        }
                    }
                }
                catch (Exception E)
                {
                    Console.WriteLine("apparently not an eagle file..:{0}", E);
                }
            }

            string ascname = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(a), Name + ".asc");

            if (File.Exists(ascname))
            {
                try
                {
                    TheBOM.LoadDiptraceASC(ascname, new StandardConsoleLog());
                }
                catch (Exception E)
                {
                    Console.WriteLine("something went wrong loading diptrace asc..:{0}", E);
                }
            }
            TheBOM.WriteJLCCSV(BoardFactoryFolder, MakeJLCName(Name), false);
            Console.WriteLine("Done exporting.");
        }