/// <summary>
    /// Aligns variant component to base component.
    /// </summary>
    void AlignSelected()
    {
        IPCB_BoardIterator BoardIterator;
        IPCB_Component     Component;

        string RefDes;

        IPCB_Board Board = Util.GetCurrentPCB();

        if (Board == null)
        {
            return;
        }

        //Iterate theough all components on the board.
        BoardIterator = Board.BoardIterator_Create();
        PCB.TObjectSet FilterSet = new PCB.TObjectSet();
        //Filter for components only.
        FilterSet.Add(PCB.TObjectId.eComponentObject);
        BoardIterator.AddFilter_ObjectSet(FilterSet);
        BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet); //Filter all layers.
        BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);

        Component = (IPCB_Component)BoardIterator.FirstPCBObject();
        Board.BeginModify();

        while (Component != null)
        {
            RefDes = Component.GetState_Name().GetState_Text();
            if (Component.GetState_SourceUniqueId() != null)
            {
                if (!Component.GetState_SourceUniqueId().Contains("@") || RefDes.Contains("EM") || RefDes.Contains("FM")) //Verify component is not a variant.
                {
                    if (RefDes.Contains("EM"))
                    {
                        RefDes = RefDes.Replace("EM", "FM");
                    }
                    else if (RefDes.Contains("FM"))
                    {
                        RefDes = RefDes.Replace("FM", "EM");
                    }

                    if (SelectedRef.Contains(RefDes))
                    {
                        foreach (IPCB_Component item in SelectedComp)
                        {
                            if (item.GetState_Name().GetState_Text() == RefDes) //Match component
                            {
                                //Copy position, laye and rotation settings from base to variant.
                                item.SetState_Layer(Component.GetState_Layer());
                                item.SetState_XLocation(Component.GetState_XLocation());
                                item.SetState_YLocation(Component.GetState_YLocation());
                                item.SetState_Rotation(Component.GetState_Rotation());

                                Board.SetState_DocumentHasChanged();
                                break;
                            }
                        }
                    }
                }
            }


            Component = (IPCB_Component)BoardIterator.NextPCBObject();
        }
        Board.EndModify();

        Board.GraphicalView_ZoomRedraw();
        Board.GraphicallyInvalidate();
        //Iterator clean-up
        Board.BoardIterator_Destroy(ref BoardIterator);
        MessageBox.Show("Process Complete");
    }