Exemple #1
0
    private void CountPrimitivesOfFootprint()
    {
        OpenFileDialog openDialog = InitFileOpenDialog("PCBLIB");

        if (openDialog == null)
        {
            return;
        }

        string[] FootprintFiles = openDialog.FileNames;
        foreach (string FootprintFile in FootprintFiles)
        {
            System.Threading.Thread.Sleep(5000);

            IServerDocument PcbDocuemnt = OpenDocuemnt(FootprintFile, "PCBLIB");
            if (PcbDocuemnt == null)
            {
                DXP.Utils.ShowMessage("Failed to open " + FootprintFile);
                return;
            }

            IPCB_ServerInterface PcbServer = PCB.GlobalVars.PCBServer;
            IPCB_Library         PcbLib    = PcbServer.GetCurrentPCBLibrary();

            IPCB_Board currentBoard = PcbServer.GetCurrentPCBBoard();
            currentBoard.GraphicalView_ZoomRedraw();

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

            while (PcbCmp != null)
            {
                string FootprintDescription = PcbCmp.GetState_Description();
                string FootprintName        = PcbCmp.GetState_Pattern();

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

                while (PcbObj != null)
                {
                    count++;
                    PcbObj = PcbObjItera.NextPCBObject();
                }

                PcbCmp.GroupIterator_Destroy(ref PcbObjItera);

                System.IO.File.AppendAllText(@"G:\report.txt", FootprintName + "|" + FootprintDescription + "|" + count.ToString() + "\r\n");

                PcbCmp = LibIteartor.NextPCBObject() as IPCB_LibComponent;
            }

            PcbLib.LibraryIterator_Destroy(ref LibIteartor);

            CloseDocument(PcbDocuemnt);
        }
    }
Exemple #2
0
    private void AddCenterMark()
    {
        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;

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

            int      Origin_X       = currentBoard.GetState_XOrigin();
            int      Origin_Y       = currentBoard.GetState_YOrigin();
            int      LineWidth      = EDP.Utils.MMsToCoord((double)0.1);
            int      HalfLineLegnth = EDP.Utils.MMsToCoord((double)0.5);
            V7_Layer MechLayer15    = new V7_Layer().Mechanical15();

            PcbServer.PreProcess();

            IPCB_Track vLine = PcbServer.PCBObjectFactory(PCB.TObjectId.eTrackObject, TDimensionKind.eNoDimension, PCB.TObjectCreationMode.eCreate_Default) as IPCB_Track;
            SetTrackLocaton(vLine, Origin_X - HalfLineLegnth, Origin_Y, Origin_X + HalfLineLegnth, Origin_Y);
            vLine.SetState_Layer((int)MechLayer15.ID);
            vLine.SetState_Width(LineWidth);

            IPCB_Track hLine = PcbServer.PCBObjectFactory(PCB.TObjectId.eTrackObject, TDimensionKind.eNoDimension, PCB.TObjectCreationMode.eCreate_Default) as IPCB_Track;
            SetTrackLocaton(hLine, Origin_X, Origin_Y + HalfLineLegnth, Origin_X, Origin_Y - HalfLineLegnth);
            hLine.SetState_Layer((int)MechLayer15.ID);
            hLine.SetState_Width(LineWidth);

            currentBoard.AddPCBObject(vLine);
            currentBoard.AddPCBObject(hLine);

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

            PcbCmp = LibIteartor.NextPCBObject() as IPCB_LibComponent;
        }

        PcbLib.LibraryIterator_Destroy(ref LibIteartor);
    }
Exemple #3
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);
    }
Exemple #4
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);
    }