private void btnSelect_Click(object sender, EventArgs e) { if (PCBServer == null) { return; } IPCB_BoardIterator BoardIterator; IPCB_Via Via; Board = Util.GetCurrentPCB(); if (Board == null) { return; } BoardIterator = Board.BoardIterator_Create(); //Iterate theough all components on the board. PCB.TObjectSet FilterSet = new PCB.TObjectSet(); //Filter for components only. FilterSet.Add(PCB.TObjectId.eViaObject); BoardIterator.AddFilter_ObjectSet(FilterSet); BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet); //Filter all layers. BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll); IPCB_DrillLayerPair OldPair = null, DrillPair = null; List <IPCB_DrillLayerPair> NewPairs = new List <IPCB_DrillLayerPair>(); for (int i = 0; i < Board.GetState_DrillLayerPairsCount(); i++) { DrillPair = Board.GetState_LayerPair(i); if (lstBefore.SelectedItem.ToString() == DrillPair.GetState_Description()) { OldPair = DrillPair; } } Via = BoardIterator.FirstPCBObject() as IPCB_Via; Board.BeginModify(); while (Via != null) { if (Via.GetState_StartLayer() == OldPair.GetState_StartLayer() && Via.GetState_StopLayer() == OldPair.GetState_StopLayer()) { Via.SetState_Selected(true); } Via = BoardIterator.NextPCBObject() as IPCB_Via; } Board.EndModify(); Board.BoardIterator_Destroy(ref BoardIterator); }