Exemple #1
0
        public void Execute(IPCBIWindow mainWindowPCBI)
        {
            IStep step = mainWindowPCBI.GetCurrentStep();

            if (step == null)
            {
                return;
            }

            ICMPLayer layerCMPsTop = step.GetCMPLayer(true);

            //exisits the compnenent layer?
            if (layerCMPsTop == null)
            {
                return;
            }

            foreach (string layername in step.GetAllLayerNames())
            {
                List <ILayer> layers = new List <ILayer>();
                layers.Add(step.GetLayer(layername));
                SaveImageFromComponent(step, layers, FileLocation);
            }
            //something went wrong?
            string errorLog = IAutomation.GetErrorLog();

            if (errorLog.Length > 0)
            {
                System.Diagnostics.Debug.WriteLine(errorLog);
            }
        }
        public void Execute(IPCBIWindow parent)
        {
            IStep step = parent.GetCurrentStep();

            if (step == null)
            {
                return;
            }
            Dictionary <string, string> NetDiffs = new Dictionary <string, string>();

            foreach (string layername in step.GetAllLayerNames())
            {
                ILayer layer = step.GetLayer(layername);

                if (layer == null)
                {
                    continue;
                }
                if (!(layer is IODBLayer))
                {
                    continue;
                }

                IODBLayer mainLayer = (IODBLayer)layer;

                foreach (IODBObject obj in mainLayer.GetAllLayerObjects())
                {
                    if (obj.FreeText.Trim() != obj.NetName.Trim())
                    {
                        if (!NetDiffs.ContainsKey(obj.NetName))
                        {
                            NetDiffs.Add(obj.NetName, obj.FreeText);
                        }
                    }
                }
            }

            //have a list of all differences of netname and freetext
            StringBuilder MessageTextBuilder = new StringBuilder();

            MessageTextBuilder.AppendLine("Differences of FreeText and Net name for:");
            foreach (string key in NetDiffs.Keys)
            {
                MessageTextBuilder.AppendLine("Net " + key + " - " + NetDiffs[key]);
            }

            MessageBox.Show(MessageTextBuilder.ToString(), "Differences", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        public void Execute(IPCBIWindow parent)
        {
            RectangleF boundsJob = parent.GetJobBounds();

            if (boundsJob.IsEmpty)
            {
                IStep step = parent.GetCurrentStep();
                if (step == null)
                {
                    return;
                }
                boundsJob = step.GetBounds();

                if (boundsJob.IsEmpty)
                {
                    IMatrix matrix = parent.GetMatrix();
                    if (matrix == null)
                    {
                        return;
                    }

                    RectangleD boundsLayerCombination = new RectangleD();

                    //check signal layers
                    foreach (string layerName in step.GetAllLayerNames())
                    {
                        if (matrix.IsSignalLayer(layerName))
                        {
                            IODBLayer odbLayer = (IODBLayer)step.GetLayer(layerName);

                            RectangleF layerBounds = odbLayer.GetBounds();

                            boundsLayerCombination = IMath.AddRectangleD(boundsLayerCombination, new RectangleD(layerBounds));
                        }
                    }

                    boundsJob = boundsLayerCombination.ToRectangleF();
                }
            }


            MessageBox.Show("The Job has following bounds in mils:" + Environment.NewLine + " X " + boundsJob.X.ToString() + " ; Y " + boundsJob.Y.ToString() + " ; width " + boundsJob.Width + " ; height " + boundsJob.Height, "Job Bounds", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        public void Execute(IPCBIWindow Parent)
        {
            IStep   step   = Parent.GetCurrentStep();
            IMatrix matrix = Parent.GetMatrix();

            if (step == null)
            {
                return;
            }
            IODBObject profile = step.GetPCBOutlineAsODBObject();

            foreach (string layerName in step.GetAllLayerNames())
            {
                if (matrix.GetMatrixLayerType(layerName) == MatrixLayerType.Component)
                {
                    continue; //no component layer
                }
                ILayer Layer = step.GetLayer(layerName);
                if (Layer is IODBLayer)
                {
                    bool      foundOne = false;
                    IODBLayer layer    = (IODBLayer)Layer;
                    foreach (IODBObject obj in layer.GetAllLayerObjects())
                    {
                        if (profile.IsPointOfSecondObjectIncluded(obj))
                        {
                            //inside not relevant
                        }
                        else
                        {
                            obj.Select(true);
                            foundOne = true;
                        }
                    }
                    if (foundOne)
                    {
                        Layer.EnableLayer(true);
                    }
                }
            }
            Parent.UpdateSelection();
            Parent.UpdateView();
        }
Exemple #5
0
        /// <summary>
        /// Set for all layers netnames, if no connection it will be named with $NONE$
        /// </summary>
        /// <param name="parent">The parent IPCBIWindow</param>
        /// <param name="NetList">A list of all created nets</param>
        /// <param name="netName">The selected net name</param>
        public static void AutoCreateNetNames(IPCBIWindow parent, Dictionary <string, netItem> NetList, string netNameStart)
        {
            IStep currentStep = parent.GetCurrentStep();

            if (currentStep == null)
            {
                return;                      //maybe there are no Job loaded?
            }
            IMatrix matrix = parent.GetMatrix();

            foreach (string layername in currentStep.GetAllLayerNames()) //fo all layers
            {
                //check type
                if (matrix.IsImageLayer(layername))
                {
                    continue;
                }
                if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Component)
                {
                    continue;
                }

                IODBLayer parentLayer = (IODBLayer)currentStep.GetLayer(layername); //this works only because we have no image and no cmp layers

                parentLayer.CreateLayerNetList(true);                               //create internal net list

                foreach (IODBObject objODB in parentLayer.GetAllLayerObjects())     //all items
                {
                    if (objODB.LayerNetNumber == -1)
                    {
                        AddNetInfos(NetList, currentStep, parentLayer, "$NONE$", objODB);       //no connection -> $NONE$-Net
                    }
                    else
                    {
                        AddNetInfos(NetList, currentStep, parentLayer, netNameStart + layername + "_" + objODB.LayerNetNumber, objODB);
                    }
                }
            }
        }
Exemple #6
0
        public void Execute(IPCBIWindow Parent)
        {
            IStep   step   = Parent.GetCurrentStep();
            IMatrix matrix = Parent.GetMatrix();

            if (step == null)
            {
                return;
            }
            IODBObject profile = step.GetPCBOutlineAsODBObject();

            foreach (string layerName in step.GetAllLayerNames())
            {
                if (matrix.GetMatrixLayerType(layerName) == MatrixLayerType.Component)
                {
                    continue; //no component layers
                }
                ILayer Layer = step.GetLayer(layerName);
                if (Layer is IODBLayer)
                {
                    List <IODBObject> objectsToDelete = new List <IODBObject>();
                    IODBLayer         layer           = (IODBLayer)Layer;
                    foreach (IODBObject obj in layer.GetAllLayerObjects())
                    {
                        if (profile.IsPointOfSecondObjectIncluded(obj))
                        {
                            //inside not delete
                        }
                        else
                        {
                            objectsToDelete.Add(obj);
                        }
                    }
                    layer.RemoveObjects(objectsToDelete);
                }
            }
            Parent.UpdateView();
        }
        public void Execute(IPCBIWindow parent)
        {
            //this script replace mini arcs by lines
            try
            {
                IStep step = parent.GetCurrentStep();

                if (step == null)
                {
                    return;
                }

                double  minLenghtArcToReplaceByLine = IMath.MM2Mils(0.02); //20?m maximum for arcs
                IFilter objectCreator = new IFilter(parent);

                foreach (string layerName in step.GetAllLayerNames()) //check all layer
                {
                    ILayer gerberLayer = step.GetLayer(layerName);

                    if (gerberLayer == null)
                    {
                        continue;
                    }

                    if (gerberLayer is ICMPLayer)
                    {
                        continue;                           //should not be for gerberlayers
                    }
                    if (gerberLayer is IPictureLayer)
                    {
                        continue;                               //should not be for gerberlayers
                    }
                    //gerber layers always contain IODBObjects
                    foreach (IODBObject obj in gerberLayer.GetAllLayerObjects())
                    {
                        if (obj.Type == IObjectType.Arc)
                        {
                            #region one arc
                            IArcSpecificsD arc = (IArcSpecificsD)obj.GetSpecificsD();

                            double radius = IMath.DistancePointToPoint(arc.Start, arc.Center);
                            double angle  = IMath.GetAngle(arc.Start, arc.End, arc.Center, arc.ClockWise); //always >=0

                            if (angle > 0)                                                                 //ODB++ spec define arcs with Start == End as full circles (angle = 0 in this calculation)
                            {
                                double bogen = 2 * Math.PI * radius * angle / 360;

                                if (bogen < minLenghtArcToReplaceByLine && arc.PenWidth > bogen)//simple condition to identify mini arcs
                                {
                                    //replace by line
                                    IODBObject lineObj = objectCreator.CreateLine((IODBLayer)gerberLayer); //we know it's a gerber layer -> it must be a IODBLayer

                                    lineObj.SetSpecifics(new ILineSpecificsD()
                                    {
                                        Start = arc.Start, End = arc.End, ShapeIndex = arc.ShapeIndex, Positive = arc.Positive
                                    });

                                    if (!obj.ReplaceItemBy(lineObj)) //replace it
                                    {
                                        Console.WriteLine("Could not replace item!");
                                    }
                                }
                            }
                            #endregion
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error! " + ex.ToString());
            }
            parent.UpdateView(); //to show the replaced elements
        }
        public void Execute(IPCBIWindow parent)
        {
            //check all pads on top and bot signal layers and mask layers for open space in mask...

            IMatrix matrix = parent.GetMatrix();
            IStep   step   = parent.GetCurrentStep();

            if (step == null || matrix == null)
            {
                return;
            }

            PCB_Investigator.PCBIWindows.PCBIWorkingDialog working = new PCB_Investigator.PCBIWindows.PCBIWorkingDialog();
            working.CanCancel(false);
            working.SetStatusText("Checking for free pads on Solder Mask...");
            working.SetAnimationStatus(true);

            working.ShowWorkingDlgAsThread();

            IODBLayer SMTLayerTop      = null;
            IODBLayer SMTLayerBot      = null;
            IODBLayer SignalTop        = (IODBLayer)step.GetLayer(matrix.GetTopSignalLayer());
            IODBLayer SignalBot        = (IODBLayer)step.GetLayer(matrix.GetBotSignalLayer(false));
            bool      signalBlockFound = false;

            foreach (string layername in step.GetAllLayerNames())
            {
                if (!signalBlockFound && matrix.GetMatrixLayerType(layername) == MatrixLayerType.Solder_mask && SMTLayerTop == null)
                {
                    SMTLayerTop = (IODBLayer)step.GetLayer(layername);
                }
                else if (signalBlockFound && matrix.GetMatrixLayerType(layername) == MatrixLayerType.Solder_mask && SMTLayerBot == null)
                {
                    SMTLayerBot = (IODBLayer)step.GetLayer(layername);
                }
            }
            //check signal pads free?

            bool topPadsFree = true;
            bool botPadsFree = true;

            if (SignalTop != null && SMTLayerTop != null)
            {
                ICMPLayer topCMPLayer = step.GetCMPLayer(true);
                if (topCMPLayer == null)
                {
                    foreach (IODBObject checkingPad in SignalTop.GetAllLayerObjects())
                    {
                        bool?foundFreeArea = CheckPadsForFreeMask(SMTLayerTop, checkingPad);
                        if (foundFreeArea == false)
                        {
                            checkingPad.ObjectColorTemporary(Color.DarkBlue);
                            topPadsFree = false;
                        }
                    }
                }
                else
                {
                    topPadsFree = CheckPadsForFreeMask(SMTLayerTop, SignalTop, topCMPLayer);
                }
            }
            if (SignalBot != null && SMTLayerBot != null)
            {
                ICMPLayer botCMPLayer = step.GetCMPLayer(false);
                if (botCMPLayer == null)
                {
                    foreach (IODBObject checkingPad in SignalBot.GetAllLayerObjects())
                    {
                        bool?foundFreeArea = CheckPadsForFreeMask(SMTLayerBot, checkingPad);
                        if (foundFreeArea == false)
                        {
                            checkingPad.ObjectColorTemporary(Color.DarkBlue);
                            botPadsFree = false;
                        }
                    }
                }
                else
                {
                    botPadsFree = CheckPadsForFreeMask(SMTLayerTop, SignalBot, botCMPLayer);
                }
            }

            working.DoClose();

            if (topPadsFree && botPadsFree)
            {
                PCB_Investigator.Localization.PCBILocalization.ShowMsgBox("Top and Bot Signal Layer Pads free on mask layers.", "Both Sides free", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (!topPadsFree && !botPadsFree)
            {
                PCB_Investigator.Localization.PCBILocalization.ShowMsgBox("Please check both sides manualy, there are closed pads found.", "No Side free", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                if (topPadsFree)
                {
                    PCB_Investigator.Localization.PCBILocalization.ShowMsgBox("Top Side is ok, all pads free on mask layer top.  Check bot layer for blue elements!", "Top OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    PCB_Investigator.Localization.PCBILocalization.ShowMsgBox("Bot Side is ok, all pads free on mask layer bot.  Check top layer for blue elements!", "Bot OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            parent.UpdateView();
        }
        public void Execute(IPCBIWindow parent)
        {
            //remove all informations of developing
            string pathForWorkingODB = System.IO.Path.GetTempPath() + "\\example\\WorkingJob" + DateTime.Now.DayOfYear;

            parent.SaveJob(pathForWorkingODB, false);

            if (!parent.LoadODBJob(pathForWorkingODB))
            {
                MessageBox.Show("Can't create a temporary working copy of ODB-Data.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            IStep step = parent.GetCurrentStep();

            if (step == null)
            {
                return;
            }

            int counter = 1;

            foreach (INet net in step.GetNets()) //change netnames
            {
                net.NetName       = "Net_" + counter;
                net.ComponentList = new List <INetObject>();
                counter++;
            }

            IMatrix matrix = parent.GetMatrix();

            if (matrix == null)
            {
                return;
            }

            foreach (string layername in step.GetAllLayerNames())
            {
                if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Component || matrix.GetMatrixLayerType(layername) == MatrixLayerType.Document)
                {
                    matrix.DelateLayer(layername, true); //remove components and document from the matrix.
                }
            }
            foreach (IPackageSpecifics pack in step.GetAllPackages())             //destroy packages
            {
                pack.SetGraphicsPath(new System.Drawing.Drawing2D.GraphicsPath());
                pack.SetOutline(pack.CreatePolygonPinSurface());
            }

            parent.SaveJobImperative();
            parent.UpdateControlsAndResetView();

            SaveFileDialog saveEmbedded = new SaveFileDialog();

            saveEmbedded.FileName = "embeddedJob.zip";

            if (saveEmbedded.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                parent.SaveEmbeddedAsZIP(saveEmbedded.FileName);
            }
        }
        public void Execute(IPCBIWindow parent)
        {
            //example to check first solder paste with first solder mask distances.
            double maxDist = 2; //mils

            wdlg = new PCB_Investigator.PCBIWindows.PCBIWorkingDialog();
            wdlg.SetAnimationStatus(false);
            wdlg.SetStatusPercent(0);
            wdlg.SetStatusText("Working");
            wdlg.CanCancel(true);


            IMatrix matrix = parent.GetMatrix();
            IStep   step   = parent.GetCurrentStep();

            wdlg.ShowWorkingDlgAsThread();

            List <string> layerNames = step.GetAllLayerNames();
            double        value      = 0;
            double        valueStep  = ((100.0 / layerNames.Count));

            Dictionary <IODBObject.DistanceResultClass, IODBObject> DistanceList = new Dictionary <IODBObject.DistanceResultClass, IODBObject>();
            IODBLayer SMTLayer = null;
            IODBLayer SPLayer  = null;

            foreach (string layername in step.GetAllLayerNames())
            {
                wdlg.SetStatusText("Working on " + layername + "...");
                value += valueStep;
                wdlg.SetStatusPercent((int)(value));

                if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Solder_paste && SPLayer == null) //find top solderpaste
                {
                    SPLayer = (IODBLayer)step.GetLayer(layername);
                }
                else if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Solder_mask && SMTLayer == null) //find top mask layer
                {
                    SMTLayer = (IODBLayer)step.GetLayer(layername);
                }

                if (SMTLayer != null && SPLayer != null)
                {
                    foreach (IODBObject IODBO1 in SPLayer.GetAllLayerObjects())
                    {
                        RectangleD boundsToInflate = IODBO1.GetBoundsD();
                        boundsToInflate.Inflate(maxDist, maxDist);
                        foreach (IODBObject IODBO2 in SMTLayer.GetAllObjectInRectangle(boundsToInflate))
                        {
                            IODBObject.DistanceResultClass distance = IODBO1.DistanceTo(IODBO2);
                            if (distance.Distance >= 0)
                            {
                                DistanceList.Add(distance, IODBO2);
                                IODBO2.ObjectColorTemporary(Color.DarkRed);
                            }
                        }
                    }
                    break;
                }
            }
            wdlg.Dispose();
            if (DistanceList.Count > 0) //write result to excel
            {
                StringBuilder sb = new StringBuilder();

                var     excelType = Type.GetTypeFromProgID("Excel.Application");
                dynamic excel     = Activator.CreateInstance(excelType);
                excel.Visible = true;
                excel.Workbooks.Add();

                foreach (IODBObject.DistanceResultClass distanceResult in DistanceList.Keys)
                {
                    sb.Append("\t" + DistanceList[distanceResult].PcbNetNumber + "\t" + distanceResult.From + "\t" + distanceResult.To + "\t" + distanceResult.Distance + Environment.NewLine);
                }

                string     LVText       = "Distances\tNet Number\tMask Layer\tSolder Paste\tValue" + Environment.NewLine + sb.ToString();
                string     LVCsv        = sb.ToString();
                DataObject LVDataObject = new DataObject();
                LVDataObject.SetData(DataFormats.Text, true, LVText);
                LVDataObject.SetData(DataFormats.CommaSeparatedValue, true, LVCsv);
                Clipboard.SetDataObject(LVDataObject, true);

                excel.ActiveSheet.Paste();

                //release the object
                System.Runtime.InteropServices.Marshal.ReleaseComObject(excel);
            }
            else
            {
                MessageBox.Show("No Results found...\n Please check Layers for Paste- or Mask layers!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public void Execute(IPCBIWindow parent)
        {
            //your code here
            if (parent == null)
            {
                return;
            }
            System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo();
            nfi.NumberDecimalSeparator = ".";
            nfi.NumberGroupSeparator   = "";
            IStep         step       = parent.GetCurrentStep();
            IFilter       filter     = new IFilter(parent);
            StringBuilder sb         = new StringBuilder();
            IMatrix       m          = parent.GetMatrix();
            List <int>    netnumbers = step.GetAllNetNrs();

            Dictionary <int, List <PCBIObject> > allNetNrsWithItems = PCBI.Automation.NetCreation.NetCreator.CreateGlobalNet(step, m, true);

            foreach (int netlist in allNetNrsWithItems.Keys)
            {
                foreach (PCBIObject oObject in allNetNrsWithItems[netlist])
                {
                    oObject.iObj.PcbNetNumber = oObject.NetNrGlobal;
                }
            }
            List <string> names = step.GetAllLayerNames();

            foreach (string layername in names)
            {
                if (step.GetLayer(layername).GetType() == typeof(IODBLayer))
                {
                    IODBLayer layer = (IODBLayer)step.GetLayer(layername);
                    if (m.GetMatrixLayerType(layername) == MatrixLayerType.Signal || m.GetMatrixLayerType(layername) == MatrixLayerType.Rout || m.GetMatrixLayerType(layername) == MatrixLayerType.Drill || m.GetMatrixLayerType(layername) == MatrixLayerType.Mask)
                    {
                        foreach (IODBObject obj in layer.GetAllLayerObjects())
                        {
                            int PCB_NetNum  = obj.PcbNetNumber;
                            int LayerNetNum = obj.LayerNetNumber;
                            obj.FreeText = PCB_NetNum.ToString();
                            //sb.Append("P: " + PCB_NetNum.ToString() + "L: " + LayerNetNum.ToString() + Environment.NewLine);
                        }
                    }
                }
            }
            sb.Append("P VER IPC D 356" + Environment.NewLine);
            sb.Append("P IMAGE PRIMARY" + Environment.NewLine);
            sb.Append("C Created with PCB-Investigator" + Environment.NewLine);
            sb.Append("P Creation date:" + DateTime.Now.ToShortDateString() + Environment.NewLine);
            sb.Append("C " + step.Name + "  " + parent.GetJobName() + Environment.NewLine);
            sb.Append("C" + Environment.NewLine);
            sb.Append("P CUST 0" + Environment.NewLine);
            #region descriptions
            //            Units of measurement :
            //SI Metric
            //CUST 0 or CUST Inches and degrees
            //CUST 1 Millimeters and degrees
            //CUST 2 Inches and radians

            //ALLOWED OPERATION CODES (columns 1-3)
            //317 Through hole. Alternatively it can represent a feature and through hole at a point.
            //017 Continuation record that defines a through hole associated with the previous record
            //367 Non-plated tooling hole
            //327 Surface mount feature
            //027 Continuation record that defines a through hole associated with the previous record
            //099 Test point location of the feature described in the previous record
            //088 Solder mask clearance of the feature described in the previous record
            //307 Blind or buried via
            //309 Image 2 through NNNN offset data
            //370 In-board resistor, capacitor or inductor
            //070 Continuation of In-board resistor, capacitor or inductor
            //378 Conductor segment data
            //078 Continuation record of conductor segment data
            //379 Adjacency data record
            //079 Continuation of adjacency data record
            //380 On-board resistor, capacitor or inductor
            //080 Continuation of on-board resistor, capacitor or inductor
            //389 Board, panel or sub-panel , scoring or other fabrication outline data
            //089 Continuation of outline data
            //390 Non-test feature such as fiducials , targets , test status marking location , etc …
            //090 Reference for high-voltage isolation , impedance and other specified tests
            //999 End of Job data file
            #endregion
            List <string> drillNames = m.GetAllDrillLayerNames();
            foreach (string drilName in drillNames)
            {
                IODBLayer layer       = (IODBLayer)step.GetLayer(drilName);
                string    LayerNumber = m.GetRawIndexByName(layer.LayerName).ToString();
                foreach (IODBObject via in layer.GetAllLayerObjects())
                {
                    string           NetName = via.PcbNetNumber.ToString();;
                    IObjectSpecifics viaSpec = via.GetSpecifics();
                    if (viaSpec.GetType() == typeof(IPadSpecifics))
                    {
                        float  x           = ((IPadSpecifics)viaSpec).Location.X;
                        float  y           = ((IPadSpecifics)viaSpec).Location.Y;
                        double diameter    = ((IPadSpecifics)viaSpec).Diameter;
                        string currentLine = new string(' ', 255);
                        currentLine = currentLine.Insert(0, "317");
                        currentLine = currentLine.Insert(4, NetName);
                        currentLine = currentLine.Insert(21, "VIA");
                        currentLine = currentLine.Insert(27, "-");
                        //currentLine = currentLine.Insert(28, LayerNumber);
                        currentLine = currentLine.Insert(33, "D");
                        currentLine = currentLine.Insert(34, diameter.ToString("N2", nfi));
                        currentLine = currentLine.Insert(38, "P   ");
                        currentLine = currentLine.Insert(42, "X");
                        if (Math.Sign(x) == 1)
                        {
                            currentLine = currentLine.Insert(43, "+");
                        }
                        else
                        {
                            currentLine = currentLine.Insert(43, "-");
                        }
                        currentLine = currentLine.Insert(44, x.ToString("N2", nfi));
                        currentLine = currentLine.Insert(50, "Y");
                        if (Math.Sign(y) == 1)
                        {
                            currentLine = currentLine.Insert(51, "+");
                        }
                        else
                        {
                            currentLine = currentLine.Insert(51, "-");
                        }
                        currentLine = currentLine.Insert(52, y.ToString("N2", nfi));

                        currentLine = currentLine.Insert(58, "X");
                        currentLine = currentLine.Insert(59, diameter.ToString("N2", nfi));

                        currentLine = currentLine.Insert(63, "Y");
                        currentLine = currentLine.Insert(64, diameter.ToString("N2", nfi));
                        currentLine = currentLine.Insert(73, "S");
                        currentLine = currentLine.Insert(74, "3");
                        sb.Append(currentLine + Environment.NewLine);
                    }
                }
            }
            IODBLayer LayerPTop = (IODBLayer)step.GetLayer(m.GetTopSignalLayer());
            if (LayerPTop != null)
            {
                string LayerNumber = m.GetRawIndexByName(LayerPTop.LayerName).ToString();
                foreach (IODBObject padTop in LayerPTop.GetAllLayerObjects())
                {
                    string           NetName = padTop.PcbNetNumber.ToString();;
                    IObjectSpecifics os      = padTop.GetSpecifics();
                    if (os.GetType() == typeof(IPadSpecifics))
                    {
                        IPadSpecifics oPad        = (IPadSpecifics)os;
                        PointF        PadMidPoint = new PointF(padTop.GetBounds().X + padTop.GetBounds().Width / 2, padTop.GetBounds().Y + padTop.GetBounds().Height / 2);
                        string        currentLine = new string(' ', 255);
                        currentLine = currentLine.Insert(0, "327");
                        currentLine = currentLine.Insert(4, NetName);
                        currentLine = currentLine.Insert(21, "PAD");
                        currentLine = currentLine.Insert(27, " ");
                        currentLine = currentLine.Insert(28, LayerNumber);
                        currentLine = currentLine.Insert(33, "D");
                        currentLine = currentLine.Insert(34, padTop.GetBounds().Width.ToString("N2", nfi));
                        currentLine = currentLine.Insert(38, "P   ");
                        currentLine = currentLine.Insert(42, "X");
                        if (Math.Sign(PadMidPoint.X) == 1)
                        {
                            currentLine = currentLine.Insert(43, "+");
                        }
                        else
                        {
                            currentLine = currentLine.Insert(43, "-");
                        }
                        currentLine = currentLine.Insert(44, PadMidPoint.X.ToString("N2", nfi));
                        currentLine = currentLine.Insert(50, "Y");
                        if (Math.Sign(PadMidPoint.Y) == 1)
                        {
                            currentLine = currentLine.Insert(51, "+");
                        }
                        else
                        {
                            currentLine = currentLine.Insert(51, "-");
                        }
                        currentLine = currentLine.Insert(52, PadMidPoint.Y.ToString("N2", nfi));

                        currentLine = currentLine.Insert(58, "W");
                        currentLine = currentLine.Insert(59, padTop.GetBounds().Width.ToString("N2", nfi));

                        currentLine = currentLine.Insert(63, "H");
                        currentLine = currentLine.Insert(64, padTop.GetBounds().Height.ToString("N2", nfi));
                        currentLine = currentLine.Insert(73, "S");
                        currentLine = currentLine.Insert(74, "1");
                        sb.Append(currentLine + Environment.NewLine);
                    }
                }
            }
            IODBLayer LayerPBot = (IODBLayer)step.GetLayer(m.GetBotSignalLayer());
            if (LayerPBot != null)
            {
                string LayerNumber = m.GetRawIndexByName(LayerPBot.LayerName).ToString();
                foreach (IODBObject padBot in LayerPBot.GetAllLayerObjects())
                {
                    string           NetName = padBot.PcbNetNumber.ToString();;
                    IObjectSpecifics os      = padBot.GetSpecifics();
                    if (os.GetType() == typeof(IPadSpecifics))
                    {
                        IPadSpecifics oPad        = (IPadSpecifics)os;
                        PointF        PadMidPoint = new PointF(padBot.GetBounds().X + padBot.GetBounds().Width / 2, padBot.GetBounds().Y + padBot.GetBounds().Height / 2);
                        string        currentLine = new string(' ', 255);
                        currentLine = currentLine.Insert(0, "327");
                        currentLine = currentLine.Insert(4, NetName);
                        currentLine = currentLine.Insert(21, "PAD");
                        currentLine = currentLine.Insert(27, " ");
                        currentLine = currentLine.Insert(28, LayerNumber);
                        currentLine = currentLine.Insert(33, "D");
                        currentLine = currentLine.Insert(34, padBot.GetBounds().Width.ToString("N2", nfi));
                        currentLine = currentLine.Insert(38, "P   ");
                        currentLine = currentLine.Insert(42, "X");
                        if (Math.Sign(PadMidPoint.X) == 1)
                        {
                            currentLine = currentLine.Insert(43, "+");
                        }
                        else
                        {
                            currentLine = currentLine.Insert(43, "-");
                        }
                        currentLine = currentLine.Insert(44, PadMidPoint.X.ToString("N2", nfi));
                        currentLine = currentLine.Insert(50, "Y");
                        if (Math.Sign(PadMidPoint.Y) == 1)
                        {
                            currentLine = currentLine.Insert(51, "+");
                        }
                        else
                        {
                            currentLine = currentLine.Insert(51, "-");
                        }
                        currentLine = currentLine.Insert(52, PadMidPoint.Y.ToString("N2", nfi));

                        currentLine = currentLine.Insert(58, "W");
                        currentLine = currentLine.Insert(59, padBot.GetBounds().Width.ToString("N2", nfi));

                        currentLine = currentLine.Insert(63, "H");
                        currentLine = currentLine.Insert(64, padBot.GetBounds().Height.ToString("N2", nfi));
                        currentLine = currentLine.Insert(73, "S");
                        currentLine = currentLine.Insert(74, "1");
                        sb.Append(currentLine + Environment.NewLine);
                    }
                }
            }
            sb.Append("999" + Environment.NewLine); // End of File

            string text = sb.ToString();
            Directory.CreateDirectory(parent.GetODBJobDirectory() + "\\user\\");
            FileStream   fs = new FileStream(parent.GetODBJobDirectory() + "\\user\\IPC356.txt", FileMode.OpenOrCreate);
            StreamWriter sr = new StreamWriter(fs, Encoding.UTF8);
            fs.SetLength(0);
            sr.WriteLine(text);
            sr.Close();
            fs.Close();
            parent.UpdateView();
        }