Exemple #1
0
    //Autogenerated code. End of implementation [GetState_SetActiveLayer]

    //Autogenerated code. Begin of implementation [Command_SetActiveLayer]
    public void Command_SetActiveLayer(IServerDocumentView view, ref string parameters)
    {
        IPCB_Primitive obj   = null;
        IPCB_Board     board = Util.GetCurrentPCB();

        try
        {
            //If a object is already selected, Use it. If not, then get the object under the cursor.
            if (board.GetState_SelectecObjectCount() != 1)
            {
                obj = (IPCB_Primitive)board.GetObjectAtXYAskUserIfAmbiguous(board.GetState_XCursor(), board.GetState_YCursor(), Util.PCBAllObject, PCBConstant.V6AllLayersSet, TEditingAction.eEditAction_Focus);
            }
            if (obj == null)
            {
                obj = (IPCB_Primitive)board.GetLastClickedObject(Util.PCBAllObject, TEditingAction.eEditAction_Select);
            }
            else
            {
                obj = (IPCB_Primitive)board.GetState_SelectecObject(0);
            }

            if (obj == null)
            {
                return;
            }
            //Set the active layer to that of the selected object layer. Doesnt update the selected layer tab.
            board.SetState_CurrentLayerV7(obj.GetState_V7Layer());

            //Switch to the next layer and back so that the propper layer tab is selected.
            DXP.Utils.RunCommand("PCB:SetCurrentLayer", "LayerName = Next");
            DXP.Utils.RunCommand("PCB:SetCurrentLayer", "LayerName = Previous");

            //Switch to single layer mode.
            //DXP.Utils.RunCommand("PCB:SetupPreferences", "SingleLayerMode=ON");
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
        }
    }