示例#1
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);
    }
示例#2
0
    private void SetTrackLocaton(IPCB_Track PcbTrack, int ArgX1, int ArgY1, int ArgX2, int ArgY2)
    {
        if (PcbTrack == null)
        {
            return;
        }

        PcbTrack.SetState_X1(ArgX1);
        PcbTrack.SetState_Y1(ArgY1);
        PcbTrack.SetState_X2(ArgX2);
        PcbTrack.SetState_Y2(ArgY2);
    }
示例#3
0
    IPCB_Primitive CreateTrack(double x1, double y1, double x2, double y2, TV6_Layer Layer)
    {
        IPCB_Primitive tmpPrim = PCBServer.PCBObjectFactory(TObjectId.eTrackObject, TDimensionKind.eNoDimension, TObjectCreationMode.eCreate_Default);
        IPCB_Track     track   = tmpPrim as IPCB_Track;

        track.SetState_X1(OffsetX + EDP.Utils.MilsToCoord(x1 - 4285));
        track.SetState_Y1(OffsetY + EDP.Utils.MilsToCoord(y1));
        track.SetState_X2(OffsetX + EDP.Utils.MilsToCoord(x2 - 4285));
        track.SetState_Y2(OffsetY + EDP.Utils.MilsToCoord(y2));

        track.SetState_Layer(Layer);
        track.SetState_Width(EDP.Utils.MilsToCoord(20));

        return(tmpPrim);
    }
示例#4
0
    private PrimitiveArea CalTrackArea(IPCB_Track PcbTrack)
    {
        PrimitiveArea TrackArea = new PrimitiveArea();
        int           x1        = Math.Min(PcbTrack.GetState_X1(), PcbTrack.GetState_X2());
        int           x2        = Math.Max(PcbTrack.GetState_X1(), PcbTrack.GetState_X2());
        int           y1        = Math.Min(PcbTrack.GetState_Y1(), PcbTrack.GetState_Y2());
        int           y2        = Math.Max(PcbTrack.GetState_Y1(), PcbTrack.GetState_Y2());

        TrackArea.BottomLeft.X  = x1;
        TrackArea.BottomLeft.Y  = y1;
        TrackArea.BottomRight.X = x2;
        TrackArea.BottomRight.Y = y1;
        TrackArea.TopLeft.X     = x1;
        TrackArea.TopLeft.Y     = y2;
        TrackArea.TopRight.X    = x2;
        TrackArea.TopRight.Y    = y2;

        return(TrackArea);
    }
示例#5
0
    private void DrawAreaAsCourtyard(PrimitiveArea Area, IPCB_ServerInterface ArgPcbServer, IPCB_Board ArgPcbBoard)
    {
        int      CourtyardClearnce_IPC_L = EDP.Utils.MMsToCoord((double)0.1);
        int      lineWidth   = EDP.Utils.MMsToCoord((double)0.05);
        V7_Layer MechLayer15 = new V7_Layer().Mechanical15();

        ArgPcbServer.PreProcess();

        IPCB_Track trackLeft = ArgPcbServer.PCBObjectFactory(PCB.TObjectId.eTrackObject, TDimensionKind.eNoDimension, PCB.TObjectCreationMode.eCreate_GlobalCopy) as IPCB_Track;

        SetTrackLocaton(trackLeft, Area.BottomLeft.X - CourtyardClearnce_IPC_L, Area.BottomLeft.Y - CourtyardClearnce_IPC_L, Area.TopLeft.X - CourtyardClearnce_IPC_L, Area.TopLeft.Y + CourtyardClearnce_IPC_L);
        trackLeft.SetState_Width(lineWidth);
        trackLeft.SetState_Layer((int)MechLayer15.ID);

        IPCB_Track trackRight = ArgPcbServer.PCBObjectFactory(PCB.TObjectId.eTrackObject, TDimensionKind.eNoDimension, PCB.TObjectCreationMode.eCreate_GlobalCopy) as IPCB_Track;

        SetTrackLocaton(trackRight, Area.BottomRight.X + CourtyardClearnce_IPC_L, Area.BottomRight.Y - CourtyardClearnce_IPC_L, Area.TopRight.X + CourtyardClearnce_IPC_L, Area.TopRight.Y + CourtyardClearnce_IPC_L);
        trackRight.SetState_Width(lineWidth);
        trackRight.SetState_Layer((int)MechLayer15.ID);

        IPCB_Track trackTop = ArgPcbServer.PCBObjectFactory(PCB.TObjectId.eTrackObject, TDimensionKind.eNoDimension, PCB.TObjectCreationMode.eCreate_GlobalCopy) as IPCB_Track;

        SetTrackLocaton(trackTop, Area.TopLeft.X - CourtyardClearnce_IPC_L, Area.TopLeft.Y + CourtyardClearnce_IPC_L, Area.TopRight.X + CourtyardClearnce_IPC_L, Area.TopRight.Y + CourtyardClearnce_IPC_L);
        trackTop.SetState_Width(lineWidth);
        trackTop.SetState_Layer((int)MechLayer15.ID);

        IPCB_Track trackBottom = ArgPcbServer.PCBObjectFactory(PCB.TObjectId.eTrackObject, TDimensionKind.eNoDimension, PCB.TObjectCreationMode.eCreate_GlobalCopy) as IPCB_Track;

        SetTrackLocaton(trackBottom, Area.BottomLeft.X - CourtyardClearnce_IPC_L, Area.BottomLeft.Y - CourtyardClearnce_IPC_L, Area.BottomRight.X + CourtyardClearnce_IPC_L, Area.BottomRight.Y - CourtyardClearnce_IPC_L);
        trackBottom.SetState_Width(lineWidth);
        trackBottom.SetState_Layer((int)MechLayer15.ID);

        ArgPcbBoard.AddPCBObject(trackBottom);
        ArgPcbBoard.AddPCBObject(trackLeft);
        ArgPcbBoard.AddPCBObject(trackRight);
        ArgPcbBoard.AddPCBObject(trackTop);

        ArgPcbServer.PostProcess();
        DXP.Utils.RunCommand("PCB:Zoom", "Action=Redraw");
    }
示例#6
0
    /// <summary>
    /// Adds a new track to the PCB
    /// </summary>
    /// <param name="Offset"></param>
    /// <param name="argWidth"></param>
    private void AddTrack(structPos Offset, int argWidth)//, V7_Layer argLayer)
    {
        PCBServer = PCB.GlobalVars.PCBServer;
        if (Offset.x == null)
        {
            Offset.x = 0;
        }
        if (Offset.y == null)
        {
            Offset.y = 0;
        }

        int        xL, yL, xO, yO;
        IPCB_Board pcbBoard = Util.GetCurrentPCB();

        if (pcbBoard == null)
        {
            return;
        }

        System.Diagnostics.Debug.WriteLine(pcbBoard.GetState_DisplayUnit().ToString());



        TV6_Layer ActiveLayer = pcbBoard.GetState_CurrentLayer();

        int OriginX = pcbBoard.GetState_XOrigin();
        int OriginY = pcbBoard.GetState_YOrigin();

        PCBServer.PreProcess();

        // Set the value of J to point to the "next" vertex; this is normally
        // I + 1, but needs to be set to 0 instead for the very last vertex
        // that is processed by this loop.
        IPCB_Primitive primitive = PCBServer.PCBObjectFactory(TObjectId.eTrackObject, TDimensionKind.eNoDimension, TObjectCreationMode.eCreate_Default);

        if (primitive == null)
        {
            return;
        }
        IPCB_Track track = primitive as IPCB_Track;

        if (pcbBoard.GetState_DisplayUnit() == TUnit.eImperial)
        {
            xL       = EDP.Utils.MilsToCoord((double)LastPos.x);
            yL       = EDP.Utils.MilsToCoord((double)LastPos.y);
            xO       = EDP.Utils.MilsToCoord((double)Offset.x);
            yO       = EDP.Utils.MilsToCoord((double)Offset.y);
            argWidth = EDP.Utils.MilsToCoord((double)argWidth);
        }
        else
        {
            xL       = EDP.Utils.MMsToCoord((double)LastPos.x);
            yL       = EDP.Utils.MMsToCoord((double)LastPos.y);
            xO       = EDP.Utils.MMsToCoord((double)Offset.x);
            yO       = EDP.Utils.MMsToCoord((double)Offset.y);
            argWidth = EDP.Utils.MMsToCoord((double)argWidth);
        }

        if (Offset.absolute)
        {
            track.SetState_X1(OriginX + xL);
            track.SetState_Y1(OriginY + yL);
            track.SetState_X2(OriginX + xO);
            track.SetState_Y2(OriginY + yO);

            LastPos = Offset;
        }
        else
        {
            track.SetState_X1(OriginX + xL);
            track.SetState_Y1(OriginY + yL);
            track.SetState_X2(OriginX + (xL + xO));
            track.SetState_Y2(OriginY + (yL + yO));

            LastPos.x = LastPos.x + Offset.x;
            LastPos.y = LastPos.y + Offset.y;
        }

        track.SetState_Layer(ActiveLayer);
        track.SetState_Width(argWidth);
        pcbBoard.AddPCBObject(primitive);

        PCBServer.PostProcess();


        // Refresh PCB workspace.
        //DXP.Utils.RunCommand("PCB:Zoom", "Action=Redraw");
    }
示例#7
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);
    }
示例#8
0
    public void GetInitialParts()
    {
        try
        {
            SelectedSourceRef     = new List <string>();
            selectedSourceObjects = new clsSelectedObjects();
            Source = new clsOutput();

            IPCB_BoardIterator BoardIterator;

            IPCB_Primitive Primitive;

            IPCB_Board Board = Util.GetCurrentPCB();

            if (Board == null)
            {
                return;
            }

            //Iterate theough all components on the board.
            BoardIterator = Board.BoardIterator_Create();
            PCB.TObjectSet FilterSet = new PCB.TObjectSet();
            BoardIterator.AddFilter_ObjectSet(Util.PCBAllObject);
            BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet); //Filter all layers.
            BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);

            Primitive = BoardIterator.FirstPCBObject();

            while (Primitive != null)
            {
                if (Primitive.GetState_Selected())
                {
                    switch (Primitive.GetState_ObjectID())
                    {
                    case TObjectId.eArcObject:
                        IPCB_Arc arcObject = Primitive as IPCB_Arc;
                        selectedSourceObjects.arcObjects.Add(arcObject);
                        clsOutput.st_IPCB_Arc newArc = new clsOutput.st_IPCB_Arc();

                        newArc.StartX     = arcObject.GetState_StartX();
                        newArc.StartY     = arcObject.GetState_StartY();
                        newArc.EndX       = arcObject.GetState_EndX();
                        newArc.EndY       = arcObject.GetState_EndY();
                        newArc.StartAngle = arcObject.GetState_StartAngle();
                        newArc.EndAngle   = arcObject.GetState_EndAngle();
                        newArc.CenterX    = arcObject.GetState_CenterX();
                        newArc.CenterY    = arcObject.GetState_CenterY();

                        newArc.KeepOut = arcObject.GetState_IsKeepout();

                        newArc.LineWidth = arcObject.GetState_LineWidth();

                        if (arcObject.GetState_Net() != null)
                        {
                            newArc.Net = arcObject.GetState_Net().GetState_Name();
                        }
                        else
                        {
                            newArc.Net = null;
                        }

                        newArc.PasteMaskExpansion  = arcObject.GetState_PasteMaskExpansion();
                        newArc.Radius              = arcObject.GetState_Radius();
                        newArc.SolderMaskExpansion = arcObject.GetState_SolderMaskExpansion();
                        newArc.Layer = Util.GetLayerName(arcObject.GetState_Board(), arcObject.GetState_V7Layer());

                        Source.Arcs.Add(newArc);

                        System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                        break;

                    case TObjectId.ePadObject:
                        IPCB_Pad padObject = Primitive as IPCB_Pad;
                        selectedSourceObjects.padObjects.Add(padObject);
                        System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                        break;

                    case TObjectId.eViaObject:
                        System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                        IPCB_Via ViaObject = Primitive as IPCB_Via;

                        clsOutput.st_IPCB_Via newVia = new clsOutput.st_IPCB_Via();
                        string test = "";
                        ViaObject.Export_ToParameters(ref test);

                        newVia.HoleSize           = ViaObject.GetState_HoleSize();
                        newVia.IsTestPoint_Bottom = ViaObject.GetState_IsTestPoint_Bottom();
                        newVia.IsTestPoint_Top    = ViaObject.GetState_IsTestPoint_Top();
                        newVia.IsTenting          = ViaObject.GetState_IsTenting();
                        newVia.IsTenting_Bottom   = ViaObject.GetState_IsTenting_Bottom();
                        newVia.IsTenting_Top      = ViaObject.GetState_IsTenting_Top();
                        //ViaObject.GetState_Layer(); ViaObject.GetState_V7Layer();
                        newVia.Net  = ViaObject.GetState_Net().GetState_Name();
                        newVia.Size = ViaObject.GetState_Size();
                        newVia.SolderMaskExpansion = ViaObject.GetState_SolderMaskExpansion();
                        newVia.HighLayer           = Util.GetLayerName(ViaObject.GetState_Board(), ViaObject.GetState_HighLayer());
                        newVia.LowLayer            = Util.GetLayerName(ViaObject.GetState_Board(), ViaObject.GetState_LowLayer());
                        newVia.TearDrop            = ViaObject.GetState_TearDrop();
                        newVia.XLocation           = ViaObject.GetState_XLocation();
                        newVia.YLocation           = ViaObject.GetState_YLocation();

                        Source.Vias.Add(newVia);

                        selectedSourceObjects.ViaObjects.Add(ViaObject);
                        break;

                    case TObjectId.eTrackObject:
                        IPCB_Track trackObject = Primitive as IPCB_Track;
                        System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                        selectedSourceObjects.trackObjects.Add(trackObject);

                        clsOutput.st_IPCB_Track newTrack = new clsOutput.st_IPCB_Track();

                        newTrack.X1    = trackObject.GetState_X1();
                        newTrack.X2    = trackObject.GetState_X2();
                        newTrack.Y1    = trackObject.GetState_Y1();
                        newTrack.Y2    = trackObject.GetState_Y2();
                        newTrack.Width = trackObject.GetState_Width();
                        newTrack.Layer = Util.GetLayerName(trackObject.GetState_Board(), trackObject.GetState_V7Layer());

                        if (trackObject.GetState_Net() == null)
                        {
                            newTrack.Net = null;
                        }
                        else
                        {
                            newTrack.Net = trackObject.GetState_Net().GetState_Name();
                        }

                        newTrack.Keepout = trackObject.GetState_IsKeepout();

                        Source.Tracks.Add(newTrack);

                        break;

                    case TObjectId.eTextObject:
                        IPCB_Text textObject = Primitive as IPCB_Text;
                        selectedSourceObjects.textObjects.Add(textObject);
                        System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                        break;

                    case TObjectId.eFillObject:
                        IPCB_Fill fillObject = Primitive as IPCB_Fill;
                        selectedSourceObjects.fillObjects.Add(fillObject);

                        clsOutput.st_IPCB_Fill newFill = new clsOutput.st_IPCB_Fill();

                        newFill.Length    = fillObject.GetState_Length();
                        newFill.LocationX = fillObject.GetState_LocationX();
                        newFill.LocationY = fillObject.GetState_LocationY();
                        if (fillObject.GetState_Net() != null)
                        {
                            newFill.Net = fillObject.GetState_Net().GetState_Name();
                        }
                        newFill.PasteMaskExpansion = fillObject.GetState_PasteMaskExpansion();
                        if (fillObject.GetState_Polygon() != null)
                        {
                            MessageBox.Show("Polygon error. Please fix.");
                        }
                        //fillObject.GetState_Polygon(); //convert to something
                        newFill.Rotation            = fillObject.GetState_Rotation();
                        newFill.SolderMaskExpansion = fillObject.GetState_SolderMaskExpansion();
                        newFill.Layer      = Util.GetLayerName(fillObject.GetState_Board(), fillObject.GetState_V7Layer());
                        newFill.Width      = fillObject.GetState_Width();
                        newFill.X1Location = fillObject.GetState_X1Location();
                        newFill.X2Location = fillObject.GetState_X2Location();
                        newFill.XLocation  = fillObject.GetState_XLocation();
                        newFill.Y1Location = fillObject.GetState_Y1Location();
                        newFill.Y2Location = fillObject.GetState_Y2Location();
                        newFill.YLocation  = fillObject.GetState_YLocation();
                        newFill.Keepout    = fillObject.GetState_IsKeepout();

                        Source.Fills.Add(newFill);

                        System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                        break;

                    //case TObjectId.eConnectionObject:
                    //    System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                    //    break;
                    //case TObjectId.eNetObject:
                    //    System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                    //    break;
                    case TObjectId.eComponentObject:
                        IPCB_Component componentObject = Primitive as IPCB_Component;
                        selectedSourceObjects.componentObjects.Add(componentObject);

                        clsOutput.st_IPCB_Component newComp = new clsOutput.st_IPCB_Component();

                        IPCB_GroupIterator compIterator = componentObject.GroupIterator_Create();

                        PCB.TObjectSet compFilterset = new PCB.TObjectSet();
                        compFilterset.Add(TObjectId.ePadObject);
                        compIterator.AddFilter_ObjectSet(compFilterset);
                        compIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet);     //Filter all layers.

                        IPCB_Pad pad      = compIterator.FirstPCBObject() as IPCB_Pad;
                        int      pinCount = 0;
                        newComp.Nets = new SerializableDictionary <string, string>();
                        while (pad != null)
                        {
                            if (pad.GetState_Net() != null)
                            {
                                if (!newComp.Nets.ContainsKey(pad.GetState_Name()))
                                {
                                    newComp.Nets.Add(pad.GetState_Name(), pad.GetState_Net().GetState_Name());
                                }
                            }

                            pinCount++;
                            pad = compIterator.NextPCBObject() as IPCB_Pad;
                        }

                        componentObject.GroupIterator_Destroy(ref compIterator);


                        newComp.Parameters = new SerializableDictionary <string, string>();

                        IPCB_PrimitiveParameters componentParameters = componentObject as IPCB_PrimitiveParameters;
                        for (int i = 0; i < componentParameters.Count(); i++)
                        {
                            IPCB_Parameter parameter = componentParameters.GetParameterByIndex(i);
                            newComp.Parameters.Add(parameter.GetName(), parameter.GetValue());
                        }


                        newComp.RefDes    = componentObject.GetState_Name().GetState_Text();
                        newComp.Footprint = componentObject.GetState_Pattern();
                        newComp.PinCount  = pinCount;

                        Source.Components.Add(newComp.RefDes, newComp);

                        SelectedSourceRef.Add(newComp.RefDes);

                        //?componentObject.GetState_DescriptorString()
                        //"SOIC Component U5FM-QT#94L9#-20.000MHz (5528.098mil,6358.425mil) on Top Layer"
                        //? componentObject.GetState_DetailString()
                        //"Component U5FM Comment:QT#94L9#-20.000MHz Footprint: QT194"
                        //?componentObject.GetState_Layer()
                        //componentObject.GetState_Pattern() Footprint
                        //componentObject.GetState_SourceDesignator() Refdes
                        //componentObject.GetState_SourceFootprintLibrary() library
                        //componentObject.GetState_SourceLibReference() corp number
                        //componentObject.GetState_XLocation()
                        //componentObject.GetState_YLocation()
                        System.Diagnostics.Debug.WriteLine(componentObject.GetState_DescriptorString());
                        break;

                    case TObjectId.ePolyObject:
                        IPCB_Polygon polygonObject = Primitive as IPCB_Polygon;
                        selectedSourceObjects.polygonObjects.Add(polygonObject);

                        clsOutput.st_IPCB_Polygon newPoly = new clsOutput.st_IPCB_Polygon();

                        //polygonObject.GetState_BorderWidth();
                        //polygonObject.GetState_Coordinate();
                        newPoly.Keepout      = polygonObject.GetState_IsKeepout();
                        newPoly.Layer        = Util.GetLayerName(polygonObject.GetState_Board(), polygonObject.GetState_V7Layer());
                        newPoly.MitreCorners = polygonObject.GetState_MitreCorners();

                        if (polygonObject.GetState_Net() != null)
                        {
                            newPoly.Net = polygonObject.GetState_Net().GetState_Name();
                        }

                        newPoly.PasteMaskExpansion = polygonObject.GetState_PasteMaskExpansion();

                        if (polygonObject.GetState_Polygon() != null)
                        {
                            MessageBox.Show("Polygon error. Please fix.");
                        }

                        newPoly.PolySegments = new List <SPolySegment>();
                        for (int i = 0; i < polygonObject.GetState_PointCount(); i++)
                        {
                            newPoly.PolySegments.Add(polygonObject.GetState_Segments(i).Data);
                        }

                        newPoly.SolderMaskExpansion = polygonObject.GetState_SolderMaskExpansion();
                        newPoly.TrackSize           = polygonObject.GetState_TrackSize();//???
                        newPoly.XLocation           = polygonObject.GetState_XLocation();
                        newPoly.YLocation           = polygonObject.GetState_YLocation();
                        newPoly.PolyType            = polygonObject.GetState_PolygonType();

                        Source.Polygons.Add(newPoly);
                        System.Diagnostics.Debug.WriteLine(polygonObject.GetState_DescriptorString());
                        break;

                    case TObjectId.eRegionObject:

                        IPCB_Region regionObject = Primitive as IPCB_Region;
                        selectedSourceObjects.regionObjects.Add(regionObject);

                        clsOutput.st_IPCB_Region newRegion = new clsOutput.st_IPCB_Region();

                        if (regionObject.GetHoleCount() > 0)
                        {
                            MessageBox.Show("Region issue");
                        }


                        newRegion.Keepout    = regionObject.GetState_IsKeepout();
                        newRegion.RegionKind = regionObject.GetState_Kind();
                        newRegion.Layer      = Util.GetLayerName(regionObject.GetState_Board(), regionObject.GetState_V7Layer());
                        if (regionObject.GetState_Net() != null)
                        {
                            newRegion.Net = regionObject.GetState_Net().GetState_Name();
                        }
                        newRegion.PasteMaskExpansion  = regionObject.GetState_PasteMaskExpansion();
                        newRegion.SolderMaskExpansion = regionObject.GetState_SolderMaskExpansion();

                        List <clsOutput.st_Contour> Contours;

                        newRegion.GeometricPolygons = new List <List <clsOutput.st_Contour> >();

                        for (int i = 0; i < regionObject.GetGeometricPolygon().GetState_Count(); i++)
                        {
                            Contours = new List <clsOutput.st_Contour>();
                            for (int j = 0; j < regionObject.GetGeometricPolygon().GetState_Contour(i).GetState_Count(); j++)
                            {
                                Contours.Add(new clsOutput.st_Contour()
                                {
                                    X = regionObject.GetGeometricPolygon().GetState_Contour(i).GetState_PointX(j),
                                    Y = regionObject.GetGeometricPolygon().GetState_Contour(i).GetState_PointY(j)
                                });
                            }
                            newRegion.GeometricPolygons.Add(Contours);
                        }

                        //?regionObject.GetGeometricPolygon().GetState_Count()
                        //?regionObject.GetGeometricPolygon().GetState_Contour(0)

                        //?regionObject.GetGeometricPolygon().GetState_Contour(0).GetState_Count()
                        //?regionObject.GetGeometricPolygon().GetState_Contour(0).GetState_PointY(0)
                        //?regionObject.GetGeometricPolygon().GetState_Contour(0).GetState_PointX(0)

                        Source.Regions.Add(newRegion);

                        System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());

                        break;

                    //case TObjectId.eComponentBodyObject:
                    //    System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                    //    break;
                    //case TObjectId.eDimensionObject:
                    //    System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                    //    break;
                    //case TObjectId.eCoordinateObject:
                    //    System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                    //    break;
                    //case TObjectId.eClassObject:
                    //    System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                    //    break;
                    //case TObjectId.eRuleObject:
                    //    System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                    //    break;
                    //case TObjectId.eFromToObject:
                    //    System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                    //    break;
                    //case TObjectId.eDifferentialPairObject:
                    //    System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                    //    break;
                    //case TObjectId.eViolationObject:
                    //    System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                    //    break;
                    //case TObjectId.eEmbeddedObject:
                    //    System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                    //    break;
                    //case TObjectId.eEmbeddedBoardObject:
                    //    System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                    //    break;
                    //case TObjectId.eSplitPlaneObject:
                    //    System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                    //    break;
                    //case TObjectId.eTraceObject:
                    //    System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                    //    break;
                    //case TObjectId.eSpareViaObject:
                    //    System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                    //    break;
                    //case TObjectId.eBoardObject:
                    //    System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                    //    break;
                    //case TObjectId.eBoardOutlineObject:
                    //    System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                    //    break;
                    default:
                        selectedSourceObjects.primitiveObjects.Add(Primitive);
                        System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString());
                        break;
                    }


                    //Primitive.Export_ToParameters(ref RefDes);
                }
                Primitive = BoardIterator.NextPCBObject();
            }
            //Iterator clean-up
            Board.BoardIterator_Destroy(ref BoardIterator);

            //clsOutput outputb;
            //outputb = new clsOutput();
            //XmlSerialization.WriteToXmlFile<clsOutput>(@"S:\Dropbox\Altium Extensions\test.xml", Output);

            //outputb = XmlSerialization.ReadFromXmlFile<clsOutput>(@"S:\Dropbox\Altium Extensions\test.xml");
            //@"S:\Dropbox\Altium Extensions\test.xml"
            //"C:\\Users\\rlyne\\Dropbox\\Altium Extensions\\SwRI_Tools\\bin\\test.xml"
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }