Beispiel #1
0
    private void CleanUpSamtecFootprints()
    {
        IPCB_ServerInterface PcbServer = PCB.GlobalVars.PCBServer;

        if (PcbServer == null)
        {
            return;
        }

        IPCB_Library PcbLib = PcbServer.GetCurrentPCBLibrary();

        if (PcbLib == null)
        {
            return;
        }

        IPCB_LibraryIterator LibIteartor = PcbLib.LibraryIterator_Create();

        LibIteartor.AddFilter_ObjectSet(new PCB.TObjectSet(PCB.TObjectId.eComponentObject));
        IPCB_LibComponent PcbCmp = LibIteartor.FirstPCBObject() as IPCB_LibComponent;

        PcbServer.PreProcess();

        while (PcbCmp != null)
        {
            IPCB_Board currentBoard = PcbServer.GetCurrentPCBBoard();      // heads up, PCB Ojbect can be added only by IPCB_Board, not IPCB_Component

            IPCB_GroupIterator PcbObjItera = PcbCmp.GroupIterator_Create();
            IPCB_Primitive     PcbObj      = PcbObjItera.FirstPCBObject();

            while (PcbObj != null)
            {
                switch (PcbObj.GetState_ObjectID())
                {
                case PCB.TObjectId.eTrackObject:
                    if ((int)PcbObj.GetState_V7Layer().ID != (int)new V7_Layer().Mechanical1().ID)
                    {
                        PcbObj = PcbObjItera.NextPCBObject();
                        continue;
                    }

                    IPCB_Track TrackObj = PcbObj as IPCB_Track;
                    TrackObj.SetState_Width(EDP.Utils.MMsToCoord((double)0.1));
                    TrackObj.SetState_Layer((int)new V7_Layer().Mechanical13().ID);
                    break;

                case PCB.TObjectId.eArcObject:
                    if ((int)PcbObj.GetState_V7Layer().ID != (int)new V7_Layer().Mechanical1().ID)
                    {
                        PcbObj = PcbObjItera.NextPCBObject();
                        continue;
                    }

                    IPCB_Arc ArcObj = PcbObj as IPCB_Arc;
                    ArcObj.SetState_LineWidth(EDP.Utils.MMsToCoord((double)0.1));
                    ArcObj.SetState_Layer((int)new V7_Layer().Mechanical13().ID);
                    break;

                case PCB.TObjectId.eComponentBodyObject:
                    IPCB_ComponentBody BodyObj = PcbObj as IPCB_ComponentBody;
                    BodyObj.SetState_Layer((int)new V7_Layer().Mechanical13().ID);
                    break;

                case PCB.TObjectId.eTextObject:
                    PcbCmp.RemovePCBObject(PcbObj);
                    break;
                }

                PcbObj = PcbObjItera.NextPCBObject();
            }

            PcbServer.PostProcess();
            DXP.Utils.RunCommand("PCB:Zoom", "Action=Redraw");

            PcbCmp.GroupIterator_Destroy(ref PcbObjItera);

            PcbCmp = LibIteartor.NextPCBObject() as IPCB_LibComponent;
        }

        PcbLib.LibraryIterator_Destroy(ref LibIteartor);
    }
Beispiel #2
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);
        }
    }
Beispiel #3
0
    private void AddCourtyard()
    {
        IPCB_ServerInterface PcbServer = PCB.GlobalVars.PCBServer;

        if (PcbServer == null)
        {
            return;
        }

        IPCB_Library PcbLib = PcbServer.GetCurrentPCBLibrary();

        if (PcbLib == null)
        {
            return;
        }

        IPCB_LibraryIterator LibIteartor = PcbLib.LibraryIterator_Create();

        LibIteartor.AddFilter_ObjectSet(new PCB.TObjectSet(PCB.TObjectId.eComponentObject));
        IPCB_Component PcbCmp = LibIteartor.FirstPCBObject() as IPCB_Component;

        while (PcbCmp != null)
        {
            IPCB_Board currentBoard = PcbServer.GetCurrentPCBBoard();

            IPCB_GroupIterator PcbObjItera = PcbCmp.GroupIterator_Create();
            TV6_LayerSet       layers      = new TV6_LayerSet(TV6_Layer.eV6_BottomLayer, TV6_Layer.eV6_BottomOverlay, TV6_Layer.eV6_Mechanical13,
                                                              TV6_Layer.eV6_TopLayer, TV6_Layer.eV6_TopOverlay);
            PcbObjItera.AddFilter_LayerSet(layers);

            IPCB_Primitive PcbObj = PcbObjItera.FirstPCBObject();

            List <PrimitiveArea> Areas = new List <PrimitiveArea>();
            while (PcbObj != null)
            {
                PrimitiveArea ObjArea = new PrimitiveArea();

                switch (PcbObj.GetState_ObjectID())
                {
                case PCB.TObjectId.ePadObject:
                    ObjArea = CalPadArea(PcbObj as IPCB_Pad);
                    Areas.Add(ObjArea);
                    break;

                case PCB.TObjectId.eTrackObject:
                    ObjArea = CalTrackArea(PcbObj as IPCB_Track);
                    Areas.Add(ObjArea);
                    break;

                case PCB.TObjectId.eArcObject:
                    break;
                }

                PcbObj = PcbObjItera.NextPCBObject();
            }

            PrimitiveArea ComponentArea = CalComponentArea(Areas);
            DrawAreaAsCourtyard(ComponentArea, PcbServer, currentBoard);

            PcbCmp.GroupIterator_Destroy(ref PcbObjItera);

            PcbCmp = LibIteartor.NextPCBObject() as IPCB_Component;
        }

        PcbLib.LibraryIterator_Destroy(ref LibIteartor);
    }