Ejemplo n.º 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);
    }