Exemple #1
0
    public void AssignNet()
    {
        IClient        tmpClient = DXP.GlobalVars.Client;
        IPCB_Primitive FirstObj = null;
        IPCB_Primitive SecondObj = null;
        IPCB_Board     board = Util.GetCurrentPCB();
        int            NewX = 0, NewY = 0;

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

            if (FirstObj == null)
            {
                return;
            }

            board.ChooseLocation(ref NewX, ref NewY, "Select desired net.");
            if (NewX > 0 & NewY > 0)
            {
                SecondObj = (IPCB_Primitive)board.GetObjectAtXYAskUserIfAmbiguous(NewX, NewY, Util.PCBAllObject, PCBConstant.V6AllLayersSet, TEditingAction.eEditAction_Select);
            }

            if (SecondObj == null)
            {
                return;
            }

            if (SecondObj.GetState_Net() != null)
            {
#if DEBUG
                MessageBox.Show(SecondObj.GetState_Net().GetState_Name());
#endif
                FirstObj.BeginModify();
                FirstObj.SetState_Net(SecondObj.GetState_Net());
                FirstObj.EndModify();
            }

            if (FirstObj.GetState_ObjectID() == TObjectId.eSplitPlaneObject)
            {
                DXP.Utils.RunCommand("PCB:EditInternalPlanes", "RebuildPlane=All");
            }
            //PCB:EditInternalPlanes
            //RebuildPlane=All
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
        }
    }
Exemple #2
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);
        }
    }