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(); }
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); }
private void SetMatrixOrder(PCBI.Automation.IMatrix Matrix, PCBI.Automation.IStep Step) { if (Step == null || Matrix == null) { return; } string SilkScreenTop = "sst"; string PastMaskTop = "pto"; string SolderMaskTop = "mto"; string copperTop = "top"; string copperInner1 = "i1"; string copperInner2 = "i2"; string copperInner3 = "i3"; string copperInner4 = "i4"; string copperInner5 = "i5"; string copperInner6 = "i6"; string copperInner7 = "i7"; string copperInner8 = "i8"; string copperBottom = "bot"; string SolderMaskBottom = "mbo"; string PastMaskBottom = "pbo"; string SilkScreenBottom = "ssb"; string drillPlated = "dpl"; string drillUnPlated = "dup"; int position = 1; foreach (string layerName in Step.GetAllLayerNames()) { if (layerName.ToLower().EndsWith(SilkScreenTop)) { Matrix.SetMatrixLayerParameter(layerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Silk_screen, 0, 0); Matrix.SetMatrixLayerIndex(layerName, position); position++; } } foreach (string layerName in Step.GetAllLayerNames()) { if (layerName.ToLower().EndsWith(PastMaskTop)) { Matrix.SetMatrixLayerParameter(layerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Solder_paste, 0, 0); Matrix.SetMatrixLayerIndex(layerName, position); position++; } } foreach (string layerName in Step.GetAllLayerNames()) { if (layerName.ToLower().EndsWith(SolderMaskTop)) { Matrix.SetMatrixLayerParameter(layerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Solder_mask, 0, 0); Matrix.SetMatrixLayerIndex(layerName, position); position++; } } foreach (string layerName in Step.GetAllLayerNames()) { if (layerName.ToLower().EndsWith(copperTop)) { Matrix.SetMatrixLayerParameter(layerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Signal, 0, 0); Matrix.SetMatrixLayerIndex(layerName, position); position++; } } foreach (string layerName in Step.GetAllLayerNames()) { if (layerName.ToLower().EndsWith(copperInner1)) { Matrix.SetMatrixLayerParameter(layerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Signal, 0, 0); Matrix.SetMatrixLayerIndex(layerName, position); position++; } } foreach (string layerName in Step.GetAllLayerNames()) { if (layerName.ToLower().EndsWith(copperInner2)) { Matrix.SetMatrixLayerParameter(layerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Signal, 0, 0); Matrix.SetMatrixLayerIndex(layerName, position); position++; } } foreach (string layerName in Step.GetAllLayerNames()) { if (layerName.ToLower().EndsWith(copperInner3)) { Matrix.SetMatrixLayerParameter(layerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Signal, 0, 0); Matrix.SetMatrixLayerIndex(layerName, position); position++; } } foreach (string layerName in Step.GetAllLayerNames()) { if (layerName.ToLower().EndsWith(copperInner4)) { Matrix.SetMatrixLayerParameter(layerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Signal, 0, 0); Matrix.SetMatrixLayerIndex(layerName, position); position++; } } foreach (string layerName in Step.GetAllLayerNames()) { if (layerName.ToLower().EndsWith(copperInner5)) { Matrix.SetMatrixLayerParameter(layerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Signal, 0, 0); Matrix.SetMatrixLayerIndex(layerName, position); position++; } } foreach (string layerName in Step.GetAllLayerNames()) { if (layerName.ToLower().EndsWith(copperInner6)) { Matrix.SetMatrixLayerParameter(layerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Signal, 0, 0); Matrix.SetMatrixLayerIndex(layerName, position); position++; } } foreach (string layerName in Step.GetAllLayerNames()) { if (layerName.ToLower().EndsWith(copperInner7)) { Matrix.SetMatrixLayerParameter(layerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Signal, 0, 0); Matrix.SetMatrixLayerIndex(layerName, position); position++; } } foreach (string layerName in Step.GetAllLayerNames()) { if (layerName.ToLower().EndsWith(copperInner8)) { Matrix.SetMatrixLayerParameter(layerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Signal, 0, 0); Matrix.SetMatrixLayerIndex(layerName, position); position++; } } foreach (string layerName in Step.GetAllLayerNames()) { if (layerName.ToLower().EndsWith(copperBottom)) { Matrix.SetMatrixLayerParameter(layerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Signal, 0, 0); Matrix.SetMatrixLayerIndex(layerName, position); position++; } } foreach (string layerName in Step.GetAllLayerNames()) { if (layerName.ToLower().EndsWith(SolderMaskBottom)) { Matrix.SetMatrixLayerParameter(layerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Solder_mask, 0, 0); Matrix.SetMatrixLayerIndex(layerName, position); position++; } } foreach (string layerName in Step.GetAllLayerNames()) { if (layerName.ToLower().EndsWith(PastMaskBottom)) { Matrix.SetMatrixLayerParameter(layerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Solder_paste, 0, 0); Matrix.SetMatrixLayerIndex(layerName, position); position++; } } foreach (string layerName in Step.GetAllLayerNames()) { if (layerName.ToLower().EndsWith(SilkScreenBottom)) { Matrix.SetMatrixLayerParameter(layerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Silk_screen, 0, 0); Matrix.SetMatrixLayerIndex(layerName, position); position++; } } foreach (string layerName in Step.GetAllLayerNames()) { if (layerName.ToLower().EndsWith(drillPlated)) { Matrix.SetMatrixLayerParameter(layerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Drill, 0, 0); Matrix.SetMatrixLayerIndex(layerName, position); position++; } } foreach (string layerName in Step.GetAllLayerNames()) { if (layerName.ToLower().EndsWith(drillUnPlated)) { Matrix.SetMatrixLayerParameter(layerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Drill, 0, 0); Matrix.SetMatrixLayerIndex(layerName, position); position++; } } }