コード例 #1
0
        private void SetMatrixOrder(PCBI.Automation.IMatrix Matrix, PCBI.Automation.IStep Step)
        {
            if (Step == null || Matrix == null)
            {
                return;
            }

            List <string> MatrixOrder = new List <string>();
            List <string> TopLayers   = new List <string>();
            List <string> BotLayers   = new List <string>();
            List <string> EndLayers   = new List <string>();

            foreach (string LayerName in Step.GetAllLayerNames(true))
            {
                string layerName = LayerName.Replace(".ger", "");
                layerName = LayerName.Replace(".gbr", "");

                if (layerName.EndsWith("silk_screen"))
                {
                    Matrix.SetMatrixLayerParameter(LayerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Silk_screen, 0, 0);
                }
                else if (layerName.EndsWith("solder_paste"))
                {
                    Matrix.SetMatrixLayerParameter(LayerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Solder_paste, 0, 0);
                }
                else if (layerName.EndsWith("solder_mask"))
                {
                    Matrix.SetMatrixLayerParameter(LayerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Solder_mask, 0, 0);
                }
                else if (layerName.EndsWith("power_ground"))
                {
                    Matrix.SetMatrixLayerParameter(LayerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Power_ground, 0, 0);
                }
                else if (layerName.EndsWith("signal"))
                {
                    Matrix.SetMatrixLayerParameter(LayerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Signal, 0, 0);
                    //if (layerName.Contains("top")) //this do not work, because it will be sorted at the end
                    //    MatrixOrder.Insert(0, layerName);
                    //else
                    MatrixOrder.Add(LayerName);      //always in main list
                    continue;
                }
                else if (layerName.EndsWith("drill"))
                {
                    Matrix.SetMatrixLayerParameter(LayerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Drill, 0, 0);
                    EndLayers.Add(LayerName);
                    continue;
                }
                else if (layerName.EndsWith("rout"))
                {
                    Matrix.SetMatrixLayerParameter(LayerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Rout, 0, 0);
                    EndLayers.Add(LayerName);
                    continue;
                }
                else if (layerName.EndsWith("document"))
                {
                    EndLayers.Add(LayerName);
                    continue;
                }

                if (layerName.Contains("top"))// || layerName.Contains("t")) //second check is dangerous depending on your layer naming
                {
                    TopLayers.Add(LayerName);
                }
                else if (layerName.Contains("bot") || layerName.Contains("b"))
                {
                    BotLayers.Add(LayerName);
                }
                else
                {
                    MatrixOrder.Add(LayerName);
                }
            }
            MatrixOrder.Sort();
            TopLayers.Sort();
            BotLayers.Sort();
            EndLayers.Sort();
            MatrixOrder.InsertRange(0, TopLayers);
            MatrixOrder.AddRange(BotLayers);
            MatrixOrder.AddRange(EndLayers);
            Matrix.SetMatrixOrder(MatrixOrder);
        }