Beispiel #1
0
        public void CreatePads()
        {
            IFilter filter = new IFilter(Parent);

            IStep curStep = Parent.GetCurrentStep();

            if (curStep == null)
            {
                MessageBox.Show("No Job loaded, please load a job before start this script!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                return;
            }
            IODBLayer fiducialLayer = filter.CreateEmptyODBLayer("copper", curStep.Name);

            if (fiducialLayer == null)
            {
                MessageBox.Show("Can't create new layer!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                return;
            }

            float outerDiameter = 1800;
            float innerDiameter = 1000;

            int shapeIndex = IFilter.AddToolDefinitionDonut(fiducialLayer, outerDiameter / 25.4f, innerDiameter / 25.4f, 0);

            PCBI.MathUtils.PointD startLine = new PCBI.MathUtils.PointD(0, 0);
            float distance = 2540 / 25.4f;

            for (int y = 0; y < 39; y++)
            {
                for (int i = 0; i < 63; i++)
                {
                    IODBObject     pad = filter.CreatePad(fiducialLayer);
                    IPadSpecificsD ps  = new IPadSpecificsD();
                    ps.Location   = new PCBI.MathUtils.PointD(startLine.X, startLine.Y);
                    ps.ShapeIndex = shapeIndex;
                    ps.Positive   = true;
                    pad.SetSpecifics(ps);
                    startLine.X += distance;
                }
                startLine.Y += distance;
                startLine.X  = 0;
            }
            IMatrix matrix = Parent.GetMatrix();

            matrix.UpdateDataAndList();
            Parent.UpdateView();
        }
        public void Execute(IPCBIWindow parent)
        {
            IMatrix m    = parent.GetMatrix();
            IStep   step = parent.GetCurrentStep();


            foreach (ICMPObject comp in step.GetAllCMPObjects())
            {
                IPackageSpecificsD pack     = comp.GetPackageSpecificsD();
                RectangleD         rectBody = pack.GetBodyBounds();
                RectangleD         rect     = pack.GetBounds();
                comp.AddComponentAttribute("Body_Width", rectBody.Width.ToString());
                comp.AddComponentAttribute("Body_Height", rectBody.Height.ToString());
                // rect = GetPinBounds(comp);
                comp.AddComponentAttribute("Pin_Width", rect.Width.ToString());
                comp.AddComponentAttribute("Pin_Height", rect.Height.ToString());
                comp.AddComponentAttribute("Pin_Area", (rect.Height * rect.Width).ToString());
                //   if(comp.GetPinList().Count == 2)
                // {
                //   string shouldBe = GetGeometrieName(rect.Height * rect.Width);
                //  comp.AddComponentAttribute("Geometry_Calculated", shouldBe );
                // }
            }

            parent.UpdateView();
        }
Beispiel #3
0
        private void PrepareFor3D_inNBI(IPCBIWindow Parent)
        {
            IMatrix matrix = Parent.GetMatrix();
            IStep   step   = Parent.GetCurrentStep();

            MakeSolderMaskPositive(matrix);
            MakeDrillCutOutOnCopperLayers(Parent, matrix, step);

            Parent.UIAction.Execute(ID_ActionItem.ID_CLEAR_SELECTION);
            Parent.UIAction.Execute(ID_ActionItem.ID_ALL_LAYER_OFF);
            Parent.UIAction.Execute(ID_ActionItem.ID_ALL_SIGNAL_LAYER_ON);
            Parent.UpdateView();

            Parent.UIAction.Execute(ID_ActionItem.ID_SAVE);

            String JobLocation = Parent.GetODBJobDirectory();

            if (File.Exists(pathNBICatia))
            {
                try
                {
                    ProcessStartInfo ps = new ProcessStartInfo(pathNBICatia, "\"" + JobLocation + "\"");
                    Process.Start(ps);
                    //  Process.Start(pathNBICatia + " " + "\"" +  JobLocation + "\"");
                }

                catch (Exception ex)
                {
                    PCB_Investigator.Localization.PCBILocalization.ShowMsgBox("Can not open NBI, because " + ex.Message.ToString(), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
        }
        public void Execute(IPCBIWindow parentPCBI)
        {
            if (parentPCBI == null)
            {
                MessageBox.Show("No license!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return;
            }

            if (!parentPCBI.JobIsLoaded)
            {
                return;
            }
            IStep curStep = parentPCBI.GetCurrentStep();

            if (curStep == null)
            {
                return;                  //no step -> no job -> break;
            }
            IFilter filter = new IFilter(parentPCBI);

            foreach (ILayer layer in curStep.GetActiveLayerList())
            {
                IODBLayer  newLayer    = filter.CreateEmptyODBLayer("newLayerWithCutting_" + layer.GetLayerName(), curStep.Name, false);
                IPolyClass outlinePoly = curStep.GetPCBOutlinePoly();

                if ((!(layer is IODBLayer)) || !CutRectangle(outlinePoly, (IODBLayer)layer, newLayer, filter, parentPCBI))
                {
                    MessageBox.Show("Something is wrong, cutting has not worked!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            parentPCBI.UpdateView();
            IMatrix matrix = parentPCBI.GetMatrix();

            matrix.UpdateDataAndList();
        }
Beispiel #5
0
        public void Execute(IPCBIWindow parent)
        {
            IStep   step   = parent.GetCurrentStep();
            IMatrix matrix = parent.GetMatrix();

            if (matrix == null || step == null)
            {
                return;                                 //if there is no data loaded -> return
            }
            IODBLayer topLayer = step.GetOutsideODBLayer(true);

            if (topLayer != null)
            {
                MarkAllSMDPadsOnLayer(topLayer, matrix.GetAllDrillLayersForThisLayer(topLayer.LayerName), step);
                topLayer.EnableLayer(true); //to see the result for top side immidiatly, it will be enabled
            }
            IODBLayer botLayer = step.GetOutsideODBLayer(false);

            if (botLayer != null)
            {
                MarkAllSMDPadsOnLayer(botLayer, matrix.GetAllDrillLayersForThisLayer(botLayer.LayerName), step);
            }

            parent.UpdateView(); //redraw to show marked smd pads
        }
        public void Execute(IPCBIWindow parent)
        {
            IStep   step   = parent.GetCurrentStep();
            IMatrix matrix = parent.GetMatrix();

            if (matrix == null || step == null)
            {
                return;                                 //if there is no data loaded -> return
            }
            ILayer topMaskLayer  = step.GetLayer(matrix.FindSideLayerLayerName(MatrixLayerType.Solder_mask, true));
            ILayer topPasteLayer = step.GetLayer(matrix.FindSideLayerLayerName(MatrixLayerType.Solder_paste, true));

            if (topMaskLayer != null && topPasteLayer != null)
            {
                MarkMaskOverPadsOnPaste((IODBLayer)topMaskLayer, (IODBLayer)topPasteLayer, step);
            }

            ILayer botMaskLayer  = step.GetLayer(matrix.FindSideLayerLayerName(MatrixLayerType.Solder_mask, false));
            ILayer botPasteLayer = step.GetLayer(matrix.FindSideLayerLayerName(MatrixLayerType.Solder_paste, false));

            if (botMaskLayer != null && botPasteLayer != null)
            {
                MarkMaskOverPadsOnPaste((IODBLayer)botMaskLayer, (IODBLayer)botPasteLayer, step);
            }


            parent.UpdateView(); //redraw to show marked smd pads
        }
        public void Execute(IPCBIWindow parent)
        {
            IStep     step          = parent.GetCurrentStep();
            IFilter   filter        = new IFilter(parent);
            IODBLayer layerPolygons = filter.CreateEmptyODBLayer("polygons_n", step.Name);

            bool polyStart = true;
            List <IODBObject> listOfSelection = step.GetSelectedElements();

            PCBI.MathUtils.IPolyClass poly = new PCBI.MathUtils.IPolyClass();

            foreach (IODBObject obj in listOfSelection)
            {
                IObjectSpecificsD os = obj.GetSpecificsD();

                if (os.GetType() == typeof(IArcSpecificsD))
                {
                    IArcSpecificsD aEdge = (IArcSpecificsD)os;

                    if (polyStart)
                    {
                        polyStart = false;
                    }
                    poly.AddEdge(aEdge.Start, aEdge.End, aEdge.Center, aEdge.ClockWise);
                }
                else if (os.GetType() == typeof(ILineSpecificsD))
                {
                    ILineSpecificsD aEdge = (ILineSpecificsD)os;
                    if (polyStart)
                    {
                        polyStart = false;
                    }
                    poly.AddEdge(aEdge.Start, aEdge.End);
                }
            }

            if (poly.GetSubPolygons().Count > 0)
            {
                foreach (PCBI.MathUtils.IPolyClass polyC in poly.GetSubPolygons())
                {
                    if (polyC.GetBounds().Width > 0.001 && polyC.GetBounds().Height > 0.001)
                    {
                        IODBObject surfaceFromPoly = polyC.GetSurfaceFromPolygon(layerPolygons);
                    }
                }
                layerPolygons.EnableLayer(true);
            }
            else
            {
                IODBObject suf = poly.GetSurfaceFromPolygon(layerPolygons);
                layerPolygons.EnableLayer(true);
            }

            parent.UpdateView();
            IMatrix matrix = parent.GetMatrix();

            matrix.UpdateDataAndList();
        }
Beispiel #8
0
 public void Execute(IPCBIWindow parent)
 {
     PCBI.Automation.IMatrix matrix = parent.GetMatrix();
     PCBI.Automation.IStep   step   = parent.GetCurrentStep();
     SetMatrixOrder(matrix, step);
     matrix.Save();
     parent.UpdateControlsAndResetView();
     parent.UpdateView();
     parent.UpdateView();
 }
 public void Execute(IPCBIWindow parent)
 {
     //your code here
     if (parent.JobIsLoaded)
     {
         List <string> columheader = new List <string>();
         columheader.Add("Layer Name");
         columheader.Add("Layer Thickness µm");
         columheader.Add("Layer Position µm");
         PCB_Investigator.PCBIWindows.PCBIResultDialog layerDlg = new PCBIResultDialog(columheader, "Matrix");
         IStep   step   = parent.GetCurrentStep();
         IMatrix matrix = parent.GetMatrix();
         //	bool toggle = true;
         foreach (string layername in matrix.GetAllLayerNames())
         {
             ListViewItem lvi = new ListViewItem(layername);
             // if (toggle)
             //  {
             //      lvi.BackColor = Color.LightBlue;
             //   }
             //  toggle = !toggle;
             if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Signal)
             {
                 lvi.BackColor = Color.Orange;
             }
             if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Power_ground)
             {
                 lvi.BackColor = Color.Orange;
             }
             if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Solder_mask)
             {
                 lvi.BackColor = Color.LightGreen;
             }
             if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Solder_paste)
             {
                 lvi.BackColor = Color.LightYellow;
             }
             if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Dielectric)
             {
                 lvi.BackColor = Color.GreenYellow;
             }
             if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Component)
             {
                 lvi.BackColor = Color.LightSteelBlue;
             }
             double Layerpos       = IMath.Mils2MM(MatrixHelpers.GetLayerPositionInStackUp(layername, step, matrix)) * 1000;
             double layerthickness = IMath.Mils2MM(step.GetHeightOfLayer(layername)) * 1000;
             lvi.SubItems.Add(layerthickness.ToString("N2"));
             lvi.SubItems.Add(Layerpos.ToString("N2"));
             layerDlg.AddListViewItem(lvi);
         }
         layerDlg.ShowDlg(PCBIResultDialog.WindowType.Modal);
         parent.UpdateView();
     }
 }
Beispiel #10
0
        public void Execute(IPCBIWindow parent)
        {
            string Attrib = "";

            ShowInputDialog(ref Attrib);
            IMatrix m    = parent.GetMatrix();
            IStep   step = parent.GetCurrentStep();


            foreach (ICMPObject comp in step.GetSelectedCMPs())
            {
                comp.AddComponentAttribute("MType", Attrib);
            }
            parent.UpdateView();
        }
Beispiel #11
0
        public void Execute(IPCBIWindow parent)
        {
            string Attrib = "";

            ShowInputDialog(ref Attrib);
            IMatrix m    = parent.GetMatrix();
            IStep   step = parent.GetCurrentStep();


            foreach (ICMPObject comp in step.GetAllCMPObjects())
            {
                comp.RemoveAttribute(Attrib);
            }
            parent.UpdateView();
        }
Beispiel #12
0
        public void Execute(IPCBIWindow parent)
        {
            if (parent == null || !parent.JobIsLoaded)
            {
                MessageBox.Show("No job loaded.");
                return;
            }

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

            if (matrix == null || step == null)
            {
                MessageBox.Show("No job loaded.");
                return;
            }

            PCB_Investigator.PCBIWindows.PCBIReportDialog reportDlg = new PCB_Investigator.PCBIWindows.PCBIReportDialog("TP Check Cell Outline to Cell Outline and TP to high Componen", "Result:");


            //Check Top Component Layer
            tpCountTotal = 0;
            string topComponentLayerName = matrix.GetTopComponentLayer();

            if (!string.IsNullOrWhiteSpace(topComponentLayerName))
            {
                ILayer dataLayer = step.GetLayer(topComponentLayerName);
                if (dataLayer != null && dataLayer is ICMPLayer)
                {
                    CheckTestpoints((ICMPLayer)dataLayer, ref reportDlg);
                }
            }

            //Check Bot Component Layer
            string botComponentLayerName = matrix.GetBotComponentLayer();

            if (!string.IsNullOrWhiteSpace(botComponentLayerName))
            {
                ILayer dataLayer = step.GetLayer(botComponentLayerName);
                if (dataLayer != null && dataLayer is ICMPLayer)
                {
                    CheckTestpoints((ICMPLayer)dataLayer, ref reportDlg);
                }
            }

            parent.UpdateView();
            reportDlg.ShowDlg(PCB_Investigator.PCBIWindows.PCBIReportDialog.WindowType.Modal);
        }
        private void SetOriginBotLeft(IPCBIWindow parent)
        {
            IStep              step           = parent.GetCurrentStep();
            IMatrix            PCB_Matrix     = parent.GetMatrix();
            IODBObject         profile        = step.GetPCBOutlineAsODBObject();
            ISurfaceSpecificsD profileSurface = (ISurfaceSpecificsD)profile.GetSpecificsD();;

            RectangleD profileRect = profileSurface.GetBounds();
            PointD     OriginPoint = new PointD(-profileRect.Left, -profileRect.Top);;

            foreach (string layerName in PCB_Matrix.GetAllBoardLayerNames(true))
            {
                step.GetLayer(layerName).MoveLayer(OriginPoint.ToPointF());
            }
            profile.SetOffset(OriginPoint);

            parent.UpdateView();
        }
        public void Execute(IPCBIWindow parent)
        {
            bool allCMPHeightsInMM = true;
            //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("Creating 2D side views...");
            working.SetAnimationStatus(true);

            working.ShowWorkingDlgAsThread();

            ICMPLayer topCMPLayer = step.GetCMPLayer(true);
            ICMPLayer botCMPLayer = step.GetCMPLayer(false);

            IFilter filter = new IFilter(parent);

            IODBLayer frontLayer     = filter.CreateEmptyODBLayer("side_front", step.Name, false);
            IODBLayer sideLayer      = filter.CreateEmptyODBLayer("side_side", step.Name, false);
            float     boardThickness = GetBoardHeight(step);

            //board from side and front
            CreateBoardView(step, filter, frontLayer, boardThickness, true);
            CreateBoardView(step, filter, sideLayer, boardThickness, false);

            CreateComponents(true, topCMPLayer, frontLayer, sideLayer, boardThickness / 2, filter, allCMPHeightsInMM);
            CreateComponents(false, botCMPLayer, frontLayer, sideLayer, boardThickness / 2, filter, allCMPHeightsInMM);



            working.DoClose();

            PCB_Investigator.Localization.PCBILocalization.ShowMsgBox("See new layers side... for results.", "Views created", MessageBoxButtons.OK, MessageBoxIcon.Information);
            matrix.UpdateDataAndList();
            parent.UpdateView();
        }
        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();
        }
        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();

            if (step == null)
            {
                return;
            }

            IFilter   PCBI_filter     = new IFilter(parent);
            IODBLayer newOutlineLayer = PCBI_filter.CreateEmptyODBLayer("poly_to_line", step.Name);

            float LineWith = 10;     //diameter symbol

            foreach (IODBObject obj in step.GetSelectedElements())
            {
                foreach (IObjectSpecifics os in obj.GetOutline())
                {
                    if (os.GetType() == typeof(ILineSpecifics))
                    {
                        ILineSpecifics lineEdges = (ILineSpecifics)os;
                        IODBObject     line      = PCBI_filter.CreateLine(newOutlineLayer);
                        lineEdges.ShapeIndex = CheckShapeIndexRound(PCBI_filter, newOutlineLayer, LineWith);
                        lineEdges.Type       = PCBI.Symbol_Type.r;
                        line.SetSpecifics(lineEdges, lineEdges.ShapeIndex);
                    }
                    else if (os.GetType() == typeof(IArcSpecifics))
                    {
                        IArcSpecifics arcEdges = (IArcSpecifics)os;
                        IODBObject    arc      = PCBI_filter.CreateArc(newOutlineLayer);
                        arcEdges.ShapeIndex = CheckShapeIndexRound(PCBI_filter, newOutlineLayer, LineWith);
                        arcEdges.Type       = PCBI.Symbol_Type.r;
                        arc.SetSpecifics(arcEdges, arcEdges.ShapeIndex);
                    }
                }
            }
            parent.UpdateView();
            IMatrix matrix = parent.GetMatrix();

            matrix.UpdateDataAndList();
        }
Beispiel #18
0
        public void Execute(IPCBIWindow parent)
        {
            IFilter filter  = new IFilter(parent);
            IStep   curStep = parent.GetCurrentStep();

            if (curStep == null)
            {
                MessageBox.Show("No Job loaded, please load a job before start this script!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                return;
            }

            IODBLayer newLayer = filter.CreateEmptyODBLayer("help_layer", curStep.Name);

            newLayer.EnableLayer(true);

            IMatrix matrix = parent.GetMatrix();

            matrix.UpdateDataAndList();
            parent.UpdateView();
        }
        private void CreateNewLayer(IPCBIWindow parent, string newlayername)
        {
            IFilter filter  = new IFilter(parent);
            IStep   curStep = parent.GetCurrentStep();

            if (curStep == null)
            {
                MessageBox.Show("No Job loaded, please load a job before start this script!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }

            IODBLayer newLayer = filter.CreateEmptyODBLayer(newlayername, curStep.Name);

            newLayer.EnableLayer(true);

            IMatrix matrix = parent.GetMatrix();

            matrix.SetMatrixLayerContext(newlayername, MatrixLayerContext.Board);
            matrix.SetMatrixLayerType(newlayername, MatrixLayerType.Signal);
            matrix.UpdateDataAndList();
            parent.UpdateView();
        }
        public void Report_Via_Pad()
        {
            dynamic wordApp = Activator.CreateInstance(Type.GetTypeFromProgID("Word.Application"));

            wordApp.Visible = true;

            dynamic wordDoc = wordApp.Documents.Add();
            //////

            StringBuilder sb = new StringBuilder();

            IStep   step = Parent.GetCurrentStep();
            IMatrix m    = Parent.GetMatrix();

            foreach (INet NetList in step.GetNets())
            {
                foreach (IODBObject obj in NetList.GetAllNetObjects(Parent))
                {
                    if (m.GetMatrixLayerType(obj.GetParentLayerName()) == MatrixLayerType.Drill)
                    {
                        if (obj.Type == IObjectType.Pad)
                        {
                            IPadSpecifics ps = (IPadSpecifics)obj.GetSpecifics();
                            float         x  = ps.Location.X;
                            float         Y  = ps.Location.Y;
                            sb.Append("Via;" + obj.NetName + ";" + x.ToString("N3") + ";" + Y.ToString("N3") + Environment.NewLine);
                        }
                    }
                }
            }
            //////
            string LVText = "Type\tNetName\tposx\tposy" + Environment.NewLine + sb.ToString();

            dynamic rng = wordApp.ActiveDocument.Range(0, 0);

            rng.Text = LVText;

            System.Runtime.InteropServices.Marshal.ReleaseComObject(wordApp);
        }
Beispiel #21
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);
                    }
                }
            }
        }
Beispiel #22
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)
        {
            IMatrix       matrix       = parent.GetMatrix();
            List <string> errorLogFile = new List <string>();
            IStep         step         = parent.GetCurrentStep();
            string        fileName     = string.Empty;

            parFile(parent, ref fileName, step, ref errorLogFile);
            if (!string.IsNullOrWhiteSpace(fileName))
            {
                try
                {
                    nodFile(parent, fileName, step, matrix, ref errorLogFile);
                }
                catch (Exception exc)
                {
                    fileName = Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName) + ".txt");
                    writeToFile(fileName, errorLogFile);
                }
            }

            parent.UpdateView();
        }
            internal void doWork(IPCBIWindow parent, bool splitRoutItem, bool activateNewLayer)
            {
                IStep   step   = parent.GetCurrentStep();
                IMatrix matrix = parent.GetMatrix();
                IFilter filter = new IFilter(parent);

                //if true the new layer need to be activated
                activateNewCreatedLayer = activateNewLayer;

                //sets the bool if rout should be used
                withRout = splitRoutItem;

                foreach (string currLayerName in matrix.GetAllDrillLayerNames())
                {
                    Dictionary <string, List <IODBObject> > allNewLayerDict = new Dictionary <string, List <IODBObject> >();

                    drill_ = new List <IODBObject>();

                    drillPlatedNormal    = new List <IODBObject>();
                    drillNonPlatedNormal = new List <IODBObject>();
                    drillViaNormal       = new List <IODBObject>();

                    drillRout          = new List <IODBObject>();
                    drillPlatedRout    = new List <IODBObject>();
                    drillNonPlatedRout = new List <IODBObject>();
                    drillViaRout       = new List <IODBObject>();

                    noAttributesPadsLayerNameCreated    = false;
                    noAttributesNotPadsLayerNameCreated = false;

                    platedLayerNameCreatedRout    = false;
                    nonPlatedLayerNameCreatedRout = false;
                    viaLayerNameCreatedRout       = false;

                    platedLayerNameCreatedNormal    = false;
                    nonPlatedLayerNameCreatedNormal = false;
                    viaLayerNameCreatedNormal       = false;

                    //only activate layer can be splitted
                    if (activateNewCreatedLayer)
                    {
                        if (!step.GetActiveLayerList().Contains(step.GetLayer(currLayerName)))
                        {
                            continue;
                        }
                    }

                    //checks if the layer is a splitted layer
                    if ((currLayerName.Length > 7 && currLayerName.Substring(currLayerName.Length - 7, 7).Equals("_plated")) || (currLayerName.Length > 4 && currLayerName.Substring(currLayerName.Length - 4, 4).Equals("_via")))
                    {
                        continue;
                    }

                    //checks if the new layer wasn't already splitted last time
                    foreach (string allOtherLayerName in matrix.GetAllDrillLayerNames())
                    {
                        if (activateNewCreatedLayer)
                        {
                            string searchedLayerName = currLayerName.ToLower() + "_plated";
                            if (allOtherLayerName.ToLower().Equals(searchedLayerName))
                            {
                                step.GetLayer(searchedLayerName).EnableLayer(true);
                            }
                            searchedLayerName = currLayerName.ToLower() + "_non_plated";
                            if (allOtherLayerName.ToLower().Equals(searchedLayerName))
                            {
                                step.GetLayer(searchedLayerName).EnableLayer(true);
                            }
                            searchedLayerName = currLayerName.ToLower() + "_via";
                            if (allOtherLayerName.ToLower().Equals(searchedLayerName))
                            {
                                step.GetLayer(searchedLayerName).EnableLayer(true);
                            }
                        }
                        if (allOtherLayerName.ToLower().Equals(currLayerName.ToLower() + "_plated") || allOtherLayerName.ToLower().Equals(currLayerName.ToLower() + "_non_plated") || allOtherLayerName.ToLower().Equals(currLayerName.ToLower() + "_via"))
                        {
                            skipLayerWasAlreadySplitted = true;
                            continue;
                        }
                    }

                    //if it was already splitted then skip it
                    if (skipLayerWasAlreadySplitted)
                    {
                        skipLayerWasAlreadySplitted = false;
                        continue;
                    }

                    //checks if layer is a drilllayer
                    if (matrix.GetMatrixLayerType(currLayerName) == MatrixLayerType.Drill)
                    {
                        ILayer         lay     = step.GetLayer(currLayerName);
                        List <IObject> objects = lay.GetAllLayerObjects();
                        foreach (IODBObject currObj in objects)
                        {
                            Dictionary <PCBI.FeatureAttributeEnum, string> objDict = currObj.GetAttributesDictionary();
                            if (objDict.Count != 0)
                            {
                                if (objDict.ContainsKey(PCBI.FeatureAttributeEnum.drill))
                                {
                                    if (currObj.Type == IObjectType.Pad)
                                    {
                                        #region Rout
                                        if (withRout)
                                        {
                                            if (objDict[PCBI.FeatureAttributeEnum.drill] == "non_plated")
                                            {
                                                drillNonPlatedNormal.Add(currObj);
                                                if (!nonPlatedLayerNameCreatedNormal)
                                                {
                                                    allNewLayerDict.Add(currLayerName + "_non_plated", drillNonPlatedNormal);
                                                    nonPlatedLayerNameCreatedNormal = true;
                                                }
                                            }
                                            else if (objDict[PCBI.FeatureAttributeEnum.drill] == "plated")
                                            {
                                                drillPlatedNormal.Add(currObj);
                                                if (!platedLayerNameCreatedNormal)
                                                {
                                                    allNewLayerDict.Add(currLayerName + "_plated", drillPlatedNormal);
                                                    platedLayerNameCreatedNormal = true;
                                                }
                                            }
                                            else if (objDict[PCBI.FeatureAttributeEnum.drill] == "via")
                                            {
                                                drillViaNormal.Add(currObj);
                                                if (!viaLayerNameCreatedNormal)
                                                {
                                                    allNewLayerDict.Add(currLayerName + "_via", drillViaNormal);
                                                    viaLayerNameCreatedNormal = true;
                                                }
                                            }
                                            else
                                            {
                                                drill_.Add(currObj);
                                                if (!noAttributesPadsLayerNameCreated)
                                                {
                                                    allNewLayerDict.Add(currLayerName + "_", drill_);
                                                    noAttributesPadsLayerNameCreated = true;
                                                }
                                            }
                                        }
                                        #endregion
                                        #region Without Rout
                                        else
                                        {
                                            if (objDict[PCBI.FeatureAttributeEnum.drill] == "non_plated")
                                            {
                                                drillNonPlatedRout.Add(currObj);
                                                if (!nonPlatedLayerNameCreatedRout)
                                                {
                                                    allNewLayerDict.Add(currLayerName + "_non_plated_rout", drillNonPlatedRout);
                                                    nonPlatedLayerNameCreatedRout = true;
                                                }
                                            }
                                            else if (objDict[PCBI.FeatureAttributeEnum.drill] == "plated")
                                            {
                                                drillPlatedRout.Add(currObj);
                                                if (!platedLayerNameCreatedRout)
                                                {
                                                    allNewLayerDict.Add(currLayerName + "_plated_rout", drillPlatedRout);
                                                    platedLayerNameCreatedRout = true;
                                                }
                                            }
                                            else if (objDict[PCBI.FeatureAttributeEnum.drill] == "via")
                                            {
                                                drillViaRout.Add(currObj);
                                                if (!viaLayerNameCreatedRout)
                                                {
                                                    allNewLayerDict.Add(currLayerName + "_via_rout", drillViaRout);
                                                    viaLayerNameCreatedRout = true;
                                                }
                                            }
                                            else
                                            {
                                                drill_.Add(currObj);
                                                if (!noAttributesPadsLayerNameCreated)
                                                {
                                                    allNewLayerDict.Add(currLayerName + "_", drill_);
                                                    noAttributesPadsLayerNameCreated = true;
                                                }
                                            }
                                        }
                                        #endregion
                                    }
                                    else if (withRout)
                                    {
                                        #region Line-Arcs-Surfaces-Text + Rout
                                        if (objDict[PCBI.FeatureAttributeEnum.drill] == "non_plated")
                                        {
                                            drillNonPlatedRout.Add(currObj);
                                            if (!nonPlatedLayerNameCreatedRout)
                                            {
                                                allNewLayerDict.Add("rout_" + currLayerName + "_non_plated", drillNonPlatedRout);
                                                nonPlatedLayerNameCreatedRout = true;
                                            }
                                        }
                                        else if (objDict[PCBI.FeatureAttributeEnum.drill] == "plated")
                                        {
                                            drillPlatedRout.Add(currObj);
                                            if (!platedLayerNameCreatedRout)
                                            {
                                                allNewLayerDict.Add("rout_" + currLayerName + "_plated", drillPlatedRout);
                                                platedLayerNameCreatedRout = true;
                                            }
                                        }
                                        else if (objDict[PCBI.FeatureAttributeEnum.drill] == "via")
                                        {
                                            drillViaRout.Add(currObj);
                                            if (!viaLayerNameCreatedRout)
                                            {
                                                allNewLayerDict.Add("rout_" + currLayerName + "_via", drillViaRout);
                                                viaLayerNameCreatedRout = true;
                                            }
                                        }
                                        else
                                        {
                                            drillRout.Add(currObj);
                                            if (!noAttributesNotPadsLayerNameCreated)
                                            {
                                                allNewLayerDict.Add("rout_" + currLayerName, drillRout);
                                                noAttributesNotPadsLayerNameCreated = true;
                                            }
                                        }
                                        #endregion
                                    }
                                }
                            }
                            else
                            {
                                #region No Attributes + Rout
                                if (withRout)
                                {
                                    if (currObj.Type == IObjectType.Pad)
                                    {
                                        drill_.Add(currObj);
                                        if (!noAttributesPadsLayerNameCreated)
                                        {
                                            allNewLayerDict.Add(currLayerName + "_", drill_);
                                            noAttributesPadsLayerNameCreated = true;
                                        }
                                    }
                                    else
                                    {
                                        drillRout.Add(currObj);
                                        if (!noAttributesNotPadsLayerNameCreated)
                                        {
                                            allNewLayerDict.Add("rout_" + currLayerName, drillRout);
                                            noAttributesNotPadsLayerNameCreated = true;
                                        }
                                    }
                                }
                                #endregion
                                #region No Attributes Without Rout
                                else
                                {
                                    if (currObj.Type == IObjectType.Pad)
                                    {
                                        drill_.Add(currObj);
                                        if (!noAttributesPadsLayerNameCreated)
                                        {
                                            allNewLayerDict.Add(currLayerName + "_", drill_);
                                            noAttributesPadsLayerNameCreated = true;
                                        }
                                    }
                                }
                                #endregion
                            }
                        }

                        if (allNewLayerDict.Count > 1) //wenn alle vom gleichen Typ sind muss nicht gesplittet werden!
                        {
                            foreach (string currNewLayerName in allNewLayerDict.Keys)
                            {
                                filter = new IFilter(parent);
                                CreateNewDrillODBLayer(filter, currNewLayerName, parent, allNewLayerDict[currNewLayerName], activateNewCreatedLayer);
                            }
                        }
                    }
                }
                matrix.UpdateDataAndList();
            }
            private void CreateNewDrillODBLayer(PCBI.Automation.IFilter filter, string newLayerName, IPCBIWindow parent, List <IODBObject> currIODBObjectList, bool activateLayer)
            {
                if (currIODBObjectList.Count == 0)
                {
                    return;
                }

                IODBLayer layer = filter.CreateEmptyODBLayer(newLayerName, parent.GetCurrentStep().Name);
                Dictionary <string, int> shapeList = new Dictionary <string, int>();

                foreach (IODBObject obj in currIODBObjectList)
                {
                    if (obj.Type == IObjectType.Pad)
                    {
                        IPadSpecificsD specPad = (IPadSpecificsD)obj.GetSpecificsD();
                        if (!shapeList.ContainsKey(specPad.ODBSymbol_String))
                        {
                            int newShapeIndex = IFilter.AddToolFromODBString(layer, specPad.ODBSymbol_String, shapeList.Count);
                            shapeList.Add(specPad.ODBSymbol_String, newShapeIndex);
                        }
                        IODBObject     pad       = filter.CreatePad(layer);
                        IPadSpecificsD padInfosD = (IPadSpecificsD)obj.GetSpecificsD();
                        padInfosD.ShapeIndex = shapeList[specPad.ODBSymbol_String];
                        pad.SetSpecifics(padInfosD, shapeList[specPad.ODBSymbol_String]);
                    }
                    else if (obj.Type == IObjectType.Line)
                    {
                        ILineSpecificsD specLine = (ILineSpecificsD)obj.GetSpecificsD();
                        if (!shapeList.ContainsKey(specLine.ODBSymbol_String))
                        {
                            int newShapeIndex = IFilter.AddToolFromODBString(layer, specLine.ODBSymbol_String, shapeList.Count);
                            shapeList.Add(specLine.ODBSymbol_String, newShapeIndex);
                        }
                        IODBObject      line           = filter.CreateLine(layer);
                        ILineSpecificsD lineSpecificsD = (ILineSpecificsD)obj.GetSpecificsD();
                        lineSpecificsD.ShapeIndex = shapeList[specLine.ODBSymbol_String];
                        line.SetSpecifics(lineSpecificsD);
                    }
                    else if (obj.Type == IObjectType.Arc)
                    {
                        IArcSpecificsD specArc = (IArcSpecificsD)obj.GetSpecificsD();
                        if (!shapeList.ContainsKey(specArc.ODBSymbol_String))
                        {
                            int newShapeIndex = IFilter.AddToolFromODBString(layer, specArc.ODBSymbol_String, shapeList.Count);
                            shapeList.Add(specArc.ODBSymbol_String, newShapeIndex);
                        }
                        IODBObject     arc           = filter.CreateArc(layer);
                        IArcSpecificsD specificsArcD = (IArcSpecificsD)obj.GetSpecificsD();
                        specificsArcD.ShapeIndex = shapeList[specArc.ODBSymbol_String];
                        arc.SetSpecifics(specificsArcD);
                    }
                    else if (obj.Type == IObjectType.Surface)
                    {
                        IODBObject         surface           = filter.CreatePolygon(layer);
                        ISurfaceSpecificsD surfaceSpecificsD = (ISurfaceSpecificsD)obj.GetSpecificsD();
                        surface.SetSpecifics(surfaceSpecificsD);
                    }
                    else if (obj.Type == IObjectType.Text)
                    {
                        IODBObject      text           = filter.CreateText(layer);
                        ITextSpecificsD textSpecificsD = (ITextSpecificsD)obj.GetSpecificsD();
                        text.SetSpecifics(textSpecificsD);
                    }
                }
                if (activateLayer)
                {
                    layer.EnableLayer(true);
                }

                IMatrix matrix = parent.GetMatrix();

                matrix.SetMatrixLayerType(layer.LayerName, MatrixLayerType.Drill);
                matrix.SetMatrixLayerContext(layer.LayerName, MatrixLayerContext.Board);
            }
        public void Report_Via_Pad()
        {
            var excelType = Type.GetTypeFromProgID("Excel.Application");

            dynamic excel = Activator.CreateInstance(excelType);

            excel.Visible = true;
            excel.Workbooks.Add();
            //////

            StringBuilder sb = new StringBuilder();

            IStep   step = Parent.GetCurrentStep();
            IMatrix m    = Parent.GetMatrix();

            foreach (INet NetList in step.GetNets())
            {
                foreach (IODBObject obj in NetList.GetAllNetObjects(Parent))
                {
                    if (m.GetMatrixLayerType(obj.GetParentLayerName()) == MatrixLayerType.Drill)
                    {
                        if (obj.Type == IObjectType.Pad)
                        {
                            IPadSpecifics ps = (IPadSpecifics)obj.GetSpecifics();
                            float         x  = ps.Location.X;
                            float         Y  = ps.Location.Y;
                            if (Parent.GetUnit())
                            {
                                float unit = 25.4f / 1000;
                                x = x * unit;
                                Y = Y * unit;
                            }
                            sb.Append("Via;" + obj.NetName + ";" + x.ToString("N3") + ";" + Y.ToString("N3") + Environment.NewLine);
                        }
                    }
                    else
                    if (obj.GetParentLayerName().ToLower() == m.GetTopSignalLayer().ToLower())
                    {
                        if (obj.Type == IObjectType.Pad)
                        {
                            IPadSpecifics ps = (IPadSpecifics)obj.GetSpecifics();
                            if (ps.Type != PCBI.Symbol_Type.r)
                            {
                                float x = ps.Location.X;
                                float Y = ps.Location.Y;
                                if (Parent.GetUnit())
                                {
                                    float unit = 25.4f / 1000;
                                    x = x * unit;
                                    Y = Y * unit;
                                }
                                sb.Append("PAD_top;" + obj.NetName + ";" + x.ToString("N3") + ";" + Y.ToString("N3") + Environment.NewLine);
                            }
                        }
                    }
                    else
                    if (obj.GetParentLayerName().ToLower() == m.GetBotSignalLayer().ToLower())
                    {
                        if (obj.Type == IObjectType.Pad)
                        {
                            IPadSpecifics ps = (IPadSpecifics)obj.GetSpecifics();
                            if (ps.Type != PCBI.Symbol_Type.r)
                            {
                                float x = ps.Location.X;
                                float Y = ps.Location.Y;
                                if (Parent.GetUnit())
                                {
                                    float unit = 25.4f / 1000;
                                    x = x * unit;
                                    Y = Y * unit;
                                }
                                sb.Append("PAD_bot;" + obj.NetName + ";" + x.ToString("N3") + ";" + Y.ToString("N3") + Environment.NewLine);
                            }
                        }
                    }
                }
            }
            //////

            //string LVText = "Type\tNetName\tposx\tposy" + Environment.NewLine + sb.ToString();
            string     LVText       = "Type;NetName;posx;posy" + Environment.NewLine + sb.ToString();
            string     LVCsv        = sb.ToString();
            DataObject LVDataObject = new DataObject();

            LVDataObject.SetData(DataFormats.Text, false, LVText);
            LVDataObject.SetData(DataFormats.CommaSeparatedValue, false, LVCsv);
            Clipboard.SetDataObject(LVDataObject, true);

            excel.ActiveSheet.Paste();

            //release the object
            System.Runtime.InteropServices.Marshal.ReleaseComObject(excel);
        }
        private void CalculateCopperFinish()
        {
            IFilter filter = new IFilter(Parent);

            IStep curStep = Parent.GetCurrentStep();

            if (curStep == null)
            {
                MessageBox.Show("No Job loaded, please load a job before start this script!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                return;
            }
            IODBLayer fiducialLayer = filter.CreateEmptyODBLayer("copper", curStep.Name);

            if (fiducialLayer == null)
            {
                MessageBox.Show("Can't create new layer!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                return;
            }

            IMatrix matrix = Parent.GetMatrix();

            string topLayerName = matrix.GetTopSignalLayer();
            string topMaskName  = matrix.GetNameByRowIndex(matrix.GetRawIndexByName(topLayerName) - 1);
            string botLayerName = matrix.GetBotSignalLayer();
            string botMaskName  = matrix.GetNameByRowIndex(matrix.GetRawIndexByName(botLayerName) + 1);

            IODBLayer topLayer     = (IODBLayer)curStep.GetLayer(topLayerName);
            IODBLayer topMaskLayer = (IODBLayer)curStep.GetLayer(topMaskName);
            IODBLayer botLayer     = (IODBLayer)curStep.GetLayer(botLayerName);
            IODBLayer botMaskLayer = (IODBLayer)curStep.GetLayer(botMaskName);

            //topLayer.PolygonizeLayer();
            //botLayer.PolygonizeLayer();

            matrix.MakeLayerPositive(topMaskName);
            matrix.MakeLayerPositive(botMaskName);

            Parent.UpdateControlsAndResetView();

            MakeObjectsNegative(topMaskLayer);
            MakeObjectsNegative(botMaskLayer);

            Parent.UIAction.Execute(ID_ActionItem.ID_CLEAR_SELECTION);
            SelectAllObjectsOnLayer(topMaskLayer);
            Parent.UIAction.Execute(ID_ActionItem.ID_COPY_SELECTED_ODBOBJECTS);
            topLayer.EnableLayer(true);
            Parent.UIAction.Execute(ID_ActionItem.ID_PASTE_COPIED_ITEMS);

            Parent.UIAction.Execute(ID_ActionItem.ID_CLEAR_SELECTION);
            SelectAllObjectsOnLayer(botMaskLayer);
            Parent.UIAction.Execute(ID_ActionItem.ID_COPY_SELECTED_ODBOBJECTS);
            botLayer.EnableLayer(true);
            Parent.UIAction.Execute(ID_ActionItem.ID_PASTE_COPIED_ITEMS);

            Parent.UIAction.Execute(ID_ActionItem.ID_CLEAR_SELECTION);
            Parent.UIAction.Execute(ID_ActionItem.ID_ALL_LAYER_OFF);

            topLayer.PolygonizeLayer();
            botLayer.PolygonizeLayer();
            Parent.UpdateControlsAndResetView();

            Parent.UIAction.Execute(ID_ActionItem.ID_CALCULATE_AREA);
        }
Beispiel #28
0
        public void Execute(IPCBIWindow parent)
        {
            if (parent == null)
            {
                return;
            }
            TextType tt = TextType.angle;

            ShowInputDialog(ref tt);

            // MessageBox.Show( tt.ToString());
            IMatrix m    = parent.GetMatrix();
            IStep   step = parent.GetCurrentStep();

            if (tt == TextType.angle)
            {
                foreach (string layerName in m.GetAllSignalLayerNames())
                {
                    IODBLayer layer = (IODBLayer)step.GetLayer(layerName);

                    foreach (IODBObject obj in layer.GetAllLayerObjects())
                    {
                        IObjectSpecifics os = obj.GetSpecifics();
                        if (os.GetType() == typeof(ILineSpecifics))
                        {
                            ILineSpecifics lineEdges = (ILineSpecifics)os;
                            double         angle     = PCBI.MathUtils.IMath.GetAngle(PCBI.MathUtils.PointD.FromPointF(lineEdges.Start), PCBI.MathUtils.PointD.FromPointF(lineEdges.End));
                            obj.FreeText = "? " + angle.ToString();
                        }
                        if (os.GetType() == typeof(IPadSpecifics))
                        {
                            IPadSpecifics PAD   = (IPadSpecifics)os;
                            double        angle = PAD.Rotation;
                            obj.FreeText = "? " + angle.ToString();
                        }
                    }
                }
            }
            if (tt == TextType.lenght)
            {
                foreach (string layerName in m.GetAllSignalLayerNames())
                {
                    IODBLayer layer = (IODBLayer)step.GetLayer(layerName);

                    foreach (IODBObject obj in layer.GetAllLayerObjects())
                    {
                        IObjectSpecifics os = obj.GetSpecifics();
                        if (os.GetType() == typeof(ILineSpecifics))
                        {
                            ILineSpecifics lineEdges = (ILineSpecifics)os;

                            double length = PCBI.MathUtils.IMath.DistancePointToPoint(PCBI.MathUtils.PointD.FromPointF(lineEdges.Start), PCBI.MathUtils.PointD.FromPointF(lineEdges.End)) / 100;
                            if (parent.GetUnit())
                            {
                                length *= 2.54f;
                            }
                            length       = Math.Round(length, 2);
                            obj.FreeText = "L: " + length.ToString();
                        }
                        if (os.GetType() == typeof(IPadSpecifics))
                        {
                            IPadSpecifics PAD    = (IPadSpecifics)os;
                            RectangleF    bounds = obj.GetBounds();
                            double        w      = bounds.Width / 100;
                            double        h      = bounds.Height / 100;

                            if (parent.GetUnit())
                            {
                                w *= 2.54f;
                                h *= 2.54f;
                            }
                            w            = Math.Round(w, 2);
                            h            = Math.Round(h, 2);
                            obj.FreeText = "w: " + w.ToString() + " h: " + h.ToString();
                        }
                    }
                }
            }
            if (tt == TextType.ViaCount)
            {
                foreach (INet NetList in step.GetNets())
                {
                    int drillCount = 0;
                    foreach (IODBObject obj in NetList.GetAllNetObjects(parent))
                    {
                        if (m.GetMatrixLayerType(obj.GetParentLayerName()) == MatrixLayerType.Drill)
                        {
                            drillCount++;
                        }
                    }
                    foreach (IODBObject obj in NetList.GetAllNetObjects(parent))
                    {
                        obj.FreeText = "DrillCount: " + drillCount.ToString();
                    }
                }
            }
            if (tt == TextType.NetOnLayer)
            {
                foreach (INet NetList in step.GetNets())
                {
                    string LNames = "";
                    foreach (string LayerNames in NetList.GetAllUsedLayers(step))
                    {
                        if (m.GetMatrixLayerType(LayerNames) == MatrixLayerType.Signal)
                        {
                            LNames += LayerNames + "; ";
                        }
                    }
                    foreach (IODBObject obj in NetList.GetAllNetObjects(parent))
                    {
                        obj.FreeText = "layer: " + LNames;
                    }
                }
            }
            if (tt == TextType.NetLength)
            {
                foreach (INet NetList in step.GetNets())
                {
                    double length = CalculateNetLenth(NetList.GetAllNetObjects(parent)) / 100;
                    if (parent.GetUnit())
                    {
                        length *= 2.54f;
                    }
                    foreach (IODBObject obj in NetList.GetAllNetObjects(parent))
                    {
                        obj.FreeText = "Netlength: " + Math.Round(length, 2);
                    }
                }
            }
            parent.ShowFreeTextInfoOnAllLayer = true;
            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)
        {
            //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();
        }