示例#1
0
    private PrimitiveArea CalArcArea(IPCB_Arc PcbArc)
    {
        PrimitiveArea ArcArea = new PrimitiveArea();


        return(ArcArea);
    }
示例#2
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);
    }
示例#3
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;
        }
    }