Пример #1
0
    public void GetRules()
    {
        IPCB_Board         Board;
        IPCB_Rule          Rule;
        IPCB_BoardIterator BoardIterator;
        ArrayList          Report = new ArrayList();

        Board = Util.GetCurrentPCB();
        if (Board == null)
        {
            return;
        }

        //Iterate through all rules
        BoardIterator = Board.BoardIterator_Create();
        PCB.TObjectSet FilterSet = new PCB.TObjectSet();
        FilterSet.Add(PCB.TObjectId.eRuleObject); //Filter for rules only
        BoardIterator.AddFilter_ObjectSet(FilterSet);
        BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet);
        BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);
        Rule = (IPCB_Rule)BoardIterator.FirstPCBObject();
        //Step through all rules to find one matching RuleName.
        while (Rule != null)
        {
            Report.Add("Rule : " + Rule.GetState_Name() + ", Desc : " + Rule.GetState_DescriptorString() + ", Detail : " + Rule.GetState_DetailString());
            Rule = (IPCB_Rule)BoardIterator.NextPCBObject();
        }

        Board.BoardIterator_Destroy(ref BoardIterator); //Iterator clean-up
        File.WriteAllLines("C:\\Rules.txt", (string[])Report.ToArray(typeof(string)));
        return;                                         //No match found.
    }
Пример #2
0
    void Loadrules()
    {
        IPCB_Board         Board;
        IPCB_BoardIterator BoardIterator;

        Board = Util.GetCurrentPCB();
        if (Board == null)
        {
            return;
        }
        BoardIterator = Board.BoardIterator_Create();
        try
        {
            IPCB_Rule Rule;
            IClient   Client = DXP.GlobalVars.Client;
            IPCB_PowerPlaneConnectStyleRule ConnStyleRule;
            //Iterate through all rules
            PCB.TObjectSet FilterSet = new PCB.TObjectSet();
            FilterSet.Add(PCB.TObjectId.eRuleObject); //Filter for rules only
            BoardIterator.AddFilter_ObjectSet(FilterSet);
            BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet);
            BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);
            Rule = (IPCB_Rule)BoardIterator.FirstPCBObject();
            //Step through all rules.
            while (Rule != null)
            {
                if (Rule.GetState_RuleKind() == TRuleKind.eRule_PowerPlaneConnectStyle)
                {
                    ConnStyleRule = (IPCB_PowerPlaneConnectStyleRule)Rule;
                    if (Rules.ContainsKey(ConnStyleRule.GetState_Name()))
                    {
                        DXP.Utils.ShowError("Multiple rules of the same name.", "Rule Error");
                    }
                    else
                    {
                        Rules.Add(ConnStyleRule.GetState_Name(), new RuleValues(EDP.Utils.CoordToMils(ConnStyleRule.GetState_ReliefConductorWidth()), ConnStyleRule.GetState_ReliefEntries()));
                        cboRules.Items.Add(ConnStyleRule.GetState_Name());
                    }

                    cboRules.Items.Add(ConnStyleRule.GetState_Name());
                }
                Rule = (IPCB_Rule)BoardIterator.NextPCBObject();
            }


            //Generate report.
            //File.WriteAllLines(Util.ProjPath() + Path.GetFileNameWithoutExtension(Board.GetState_FileName()) + "-Rules.do", (string[])Report.ToArray(typeof(string)));
            //Client.ShowDocument(Client.OpenDocument("Text", Util.ProjPath() + "\\" + Path.GetFileNameWithoutExtension(Board.GetState_FileName()) + "-Rules.do"));
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
        }
        finally
        {
            Board.BoardIterator_Destroy(ref BoardIterator); //Iterator clean-up
        }
    }
Пример #3
0
 /// <summary>
 /// Creates PCB object set
 /// </summary>
 /// <param name="ObjectArgs">Array of PCB Object Ids</param>
 /// <returns>PCB TObjectSet</returns>
 public static PCB.TObjectSet MKset(params PCB.TObjectId[] ObjectArgs)
 {
     PCB.TObjectSet ReturnSet = new PCB.TObjectSet();
     foreach (PCB.TObjectId tmpObject in ObjectArgs)
     {
         ReturnSet.Add(tmpObject);
     }
     return(ReturnSet);
 }
Пример #4
0
    private void btnSelect_Click(object sender, EventArgs e)
    {
        if (PCBServer == null)
        {
            return;
        }

        IPCB_BoardIterator BoardIterator;
        IPCB_Via           Via;

        Board = Util.GetCurrentPCB();

        if (Board == null)
        {
            return;
        }

        BoardIterator = Board.BoardIterator_Create();

        //Iterate theough all components on the board.
        PCB.TObjectSet FilterSet = new PCB.TObjectSet();
        //Filter for components only.
        FilterSet.Add(PCB.TObjectId.eViaObject);
        BoardIterator.AddFilter_ObjectSet(FilterSet);
        BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet); //Filter all layers.
        BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);

        IPCB_DrillLayerPair        OldPair = null, DrillPair = null;
        List <IPCB_DrillLayerPair> NewPairs = new List <IPCB_DrillLayerPair>();

        for (int i = 0; i < Board.GetState_DrillLayerPairsCount(); i++)
        {
            DrillPair = Board.GetState_LayerPair(i);
            if (lstBefore.SelectedItem.ToString() == DrillPair.GetState_Description())
            {
                OldPair = DrillPair;
            }
        }

        Via = BoardIterator.FirstPCBObject() as IPCB_Via;

        Board.BeginModify();

        while (Via != null)
        {
            if (Via.GetState_StartLayer() == OldPair.GetState_StartLayer() && Via.GetState_StopLayer() == OldPair.GetState_StopLayer())
            {
                Via.SetState_Selected(true);
            }
            Via = BoardIterator.NextPCBObject() as IPCB_Via;
        }

        Board.EndModify();

        Board.BoardIterator_Destroy(ref BoardIterator);
    }
Пример #5
0
    /// <summary>
    /// Will show or hide reference designators based on NameOn parameter.
    /// </summary>
    /// <param name="NameOn">true = show refdes', false = hide refdes'</param>
    public void ShowHide(IPCB_Board Board, bool NameOn, bool Discretes = false)
    {
        try
        {
            IPCB_BoardIterator BoardIterator;
            IPCB_Component     Component;

            if (Board == null)
            {
                return;
            }
            //Iterate theough all components on the board.
            BoardIterator = Board.BoardIterator_Create();
            PCB.TObjectSet FilterSet = new PCB.TObjectSet();
            //Filter for components only.
            FilterSet.Add(PCB.TObjectId.eComponentObject);
            BoardIterator.AddFilter_ObjectSet(FilterSet);
            BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet); //Filter all layers.
            BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);

            Component = (IPCB_Component)BoardIterator.FirstPCBObject();
            while (Component != null)
            {
                if (!Discretes)
                {
                    Component.BeginModify();
                    Component.SetState_NameOn(NameOn); //Show or hide refdes.
                    Component.EndModify();
                }
                else
                {
                    if (Component.GetState_Name().GetState_Text().StartsWith("R") || Component.GetState_Name().GetState_Text().StartsWith("C"))
                    {
                        Component.BeginModify();
                        Component.SetState_NameOn(NameOn); //Show or hide refdes.
                        Component.EndModify();
                    }
                }
                Component = (IPCB_Component)BoardIterator.NextPCBObject();
            }
            //Iterator clean-up
            Board.BoardIterator_Destroy(ref BoardIterator);
            Board.GraphicalView_ZoomRedraw();
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
        }
    }
Пример #6
0
    public void GetCompData()
    {
        try
        {
            IPCB_Board           Board;
            IPCB_BoardIterator   BoardIterator;
            IPCB_ServerInterface PCBServer = PCB.GlobalVars.PCBServer;
            IPCB_Net             Net;
            Board = Util.GetCurrentPCB();
            if (Board == null)
            {
                return;
            }

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

            //Component.GetState_ObjectID().ToString()
            //Component.GetState_ObjectIDString()
            int l = 0;
            Net = (IPCB_Net)BoardIterator.FirstPCBObject();
            //Component = (IPCB_Component)BoardIterator.FirstPCBObject();
            while (Net != null)
            {
                LogFile[l] = Net.GetState_ObjectIDString() + " " + Net.GetState_ObjectID().ToString();
                l++;
                //Component.BeginModify();
                //Component.SetState_NameOn(NameOn); //Show or hide refdes.
                //Component.EndModify();

                Net = (IPCB_Net)BoardIterator.NextPCBObject();
                //Component = (IPCB_Component)BoardIterator.NextPCBObject();
            }
            //Iterator clean-up
            Board.BoardIterator_Destroy(ref BoardIterator);
            //Board.GraphicalView_ZoomRedraw();
            log(LogFile);
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
        }
    }
Пример #7
0
    /// <summary>
    /// Compiles a list of selected components.
    /// </summary>
    void GetSelectedComponents()
    {
        IPCB_BoardIterator BoardIterator;
        IPCB_Component     Component;

        string RefDes;

        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();
        //Filter for components only.
        FilterSet.Add(PCB.TObjectId.eComponentObject);
        BoardIterator.AddFilter_ObjectSet(FilterSet);
        BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet); //Filter all layers.
        BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);

        Component = (IPCB_Component)BoardIterator.FirstPCBObject();

        while (Component != null)
        {
            RefDes = Component.GetState_Name().GetState_Text();
            if (Component.GetState_SourceUniqueId() != null)
            {
                if (Component.GetState_SourceUniqueId().Contains("@") || RefDes.Contains("EM") || RefDes.Contains("FM")) //Verify selected component is a variant.
                {
                    RefDes = Component.GetState_Name().GetState_Text();
                    if (Component.GetState_Selected())
                    { //Add to lists.
                        SelectedRef.Add(RefDes);
                        SelectedComp.Add(Component);
                    }
                }
            }

            Component = (IPCB_Component)BoardIterator.NextPCBObject();
        }
        //Iterator clean-up
        Board.BoardIterator_Destroy(ref BoardIterator);
    }
Пример #8
0
    public void BoundingBoxTest()
    {
        IPCB_BoardIterator BoardIterator;
        IPCB_Component     Component;
        string             RefDes;//, Varriant, Footprint, CompID;
        IPCB_Board         Board = Util.GetCurrentPCB();

        if (Board == null)
        {
            return;
        }

        double OriginX = EDP.Utils.CoordToMils(Board.GetState_XOrigin());
        double OriginY = EDP.Utils.CoordToMils(Board.GetState_YOrigin());

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


        Component = (IPCB_Component)BoardIterator.FirstPCBObject();

        while (Component != null)
        {
            RefDes = Component.GetState_Name().GetState_Text();
            //Determines if component is a variant.
            if (RefDes == "U7")
            {
                while (true)
                {
                    MessageBox.Show("X: " + Math.Abs((EDP.Utils.CoordToMils(Component.BoundingRectangleNoNameCommentForSignals().Right) - OriginX) - (EDP.Utils.CoordToMils(Component.BoundingRectangleNoNameCommentForSignals().Left) - OriginX)) + " Y: " + Math.Abs((EDP.Utils.CoordToMils(Component.BoundingRectangleNoNameCommentForSignals().Top) - OriginX) - (EDP.Utils.CoordToMils(Component.BoundingRectangleNoNameCommentForSignals().Bottom) - OriginX)));

                    //MessageBox.Show("X: " + (EDP.Utils.CoordToMils(Component.BoundingRectangle().Lx) - OriginX) + " Y: " + (EDP.Utils.CoordToMils(Component.BoundingRectangle().Ly) - OriginY));
                    //MessageBox.Show("X: " + (EDP.Utils.CoordToMils(Component.BoundingRectangleNoNameCommentForSignals().Lx) - OriginX) + " Y: " + (EDP.Utils.CoordToMils(Component.BoundingRectangleNoNameCommentForSignals().Ly) - OriginY));
                }
            }
            Component = (IPCB_Component)BoardIterator.NextPCBObject();
        }
        //Iterator clean-up
        Board.BoardIterator_Destroy(ref BoardIterator);
    }
Пример #9
0
    /// <summary>
    /// Get the body heights of all the footprints on the PCB.
    /// </summary>
    /// <param name="argHeights">Reference to the dict storing report info.</param>
    void GetBodyHeights(ref Dictionary <string, Heights> argHeights)
    {
        try
        {
            IPCB_Component     Component; // component object
            IPCB_BoardIterator BoardIterator;
            IPCB_Board         Board;     // document board object

            Board = Util.GetCurrentPCB();
            if (Board == null)
            {
                return;
            }
            BoardIterator = Board.BoardIterator_Create();
            PCB.TObjectSet FilterSet = new PCB.TObjectSet();
            //Filter for components only
            FilterSet.Add(PCB.TObjectId.eComponentObject);
            BoardIterator.AddFilter_ObjectSet(FilterSet);
            BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet);
            BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);

            //Iterate through all components looking for components.
            Component = (IPCB_Component)BoardIterator.FirstPCBObject();
            while (Component != null)
            {
                if (Component.GetState_SourceDesignator() == "U18")
                {
                    System.Diagnostics.Debug.WriteLine(Component.GetState_SourceDesignator());
                }
                ObtainBodyHeight(ref argHeights, Component);
                if (argHeights == null)
                {
                    return;
                }
                Component = (IPCB_Component)BoardIterator.NextPCBObject();
            }
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
Пример #10
0
    /// <summary>
    /// Get rule based on name.
    /// </summary>
    /// <param name="RuleName">Name of the rule</param>
    /// <returns>Returns rule object matching RuleName or null.</returns>
    private IPCB_Rule GetRule(string RuleName)
    {
        try
        {
            IPCB_Board         Board;
            IPCB_Rule          Rule;
            IPCB_BoardIterator BoardIterator;

            Board = Util.GetCurrentPCB();
            if (Board == null)
            {
                return(null);
            }

            //Iterate through all rules
            BoardIterator = Board.BoardIterator_Create();
            PCB.TObjectSet FilterSet = new PCB.TObjectSet();
            FilterSet.Add(PCB.TObjectId.eRuleObject); //Filter for rules only
            BoardIterator.AddFilter_ObjectSet(FilterSet);
            BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet);
            BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);
            Rule = (IPCB_Rule)BoardIterator.FirstPCBObject();
            //Step through all rules to find one matching RuleName.
            while (Rule != null)
            {
                if (Rule.GetState_Name() == RuleName)
                {
                    Board.BoardIterator_Destroy(ref BoardIterator); //Iterator clean-up
                    return(Rule);                                   //Return matching rule.
                }
                Rule = (IPCB_Rule)BoardIterator.NextPCBObject();
            }

            return(null); //No match found.
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return(null);
        }
    }
Пример #11
0
    public void SwapResistors()
    {
        //IPCB_Component Component; // component object
        IPCB_BoardIterator Iterator;
        IPCB_Primitive     Item;
        IPCB_Board         Board; // document board object
        IPCB_Net           Net;

        Board = Util.GetCurrentPCB();
        if (Board == null)
        {
            return;
        }
        //Create board iterator
        Iterator = Board.BoardIterator_Create();
        PCB.TObjectSet FilterSet = new PCB.TObjectSet();
        //Filter for components only.
        FilterSet.Add(PCB.TObjectId.eConnectionObject);
        Iterator.AddFilter_ObjectSet(FilterSet);
        Iterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet); //Filter all layers.
        Iterator.AddFilter_Method(TIterationMethod.eProcessAll);


        Item = Iterator.FirstPCBObject();
        while (Item != null)
        {
            if (Item.GetState_Selected())
            {
                Net = Item.GetState_Net();
            }
            //Net.GetPrimitiveCount(new PCB.TObjectSet(new PCB.TObjectId[] { PCB.TObjectId.ePadObject }))
            //?Net.GetPrimitiveAt(1, TObjectId.ePadObject).GetState_DescriptorString()
            //"Pad U11-40(1557.72mil,2321.85mil) on Top Layer"
            //? Net.GetPrimitiveAt(2, TObjectId.ePadObject).GetState_DescriptorString()
            //"Pad R161-2(3000.004mil,2675mil) on Bottom Layer"
            Item = Iterator.NextPCBObject();
        }
    }
Пример #12
0
    public void GetNets()
    {
        IPCB_BoardIterator BoardIterator;
        IPCB_Net           Net;

        BoardNets = new Dictionary <string, IPCB_Net>();

        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();
        FilterSet.Add(TObjectId.eNetObject);
        BoardIterator.AddFilter_ObjectSet(FilterSet);
        BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet); //Filter all layers.
        BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);

        Net = BoardIterator.FirstPCBObject() as IPCB_Net;

        while (Net != null)
        {
            if (!BoardNets.ContainsKey(Net.GetState_Name()))
            {
                BoardNets.Add(Net.GetState_Name(), Net);
            }

            Net = BoardIterator.NextPCBObject() as IPCB_Net;
        }

        Board.BoardIterator_Destroy(ref BoardIterator);
    }
Пример #13
0
    /// <summary>
    /// Will adjust refdes orientation to match component orientation.
    /// </summary>
    public void FixRefDesOrientation()
    {
        try
        {
            IPCB_BoardIterator BoardIterator;
            IPCB_Component     Component;
            IPCB_Text          RefDes;

            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();
            //Filter for components only.
            FilterSet.Add(PCB.TObjectId.eComponentObject);
            BoardIterator.AddFilter_ObjectSet(FilterSet);
            BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet); //Filter all layers.
            BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);
            //int cnt = 0;
            //Component = (IPCB_Component)BoardIterator.FirstPCBObject();

            //while (Component != null)
            //{
            //    cnt++;
            //    Component = (IPCB_Component)BoardIterator.NextPCBObject();
            //}

            Component = (IPCB_Component)BoardIterator.FirstPCBObject();
            //DXP.Utils.PercentInit("Updating RefDes", cnt);//Progressbar init.
            while (Component != null)
            {
                RefDes = Component.GetState_Name();
                if (Component.GetState_NameAutoPos() == TTextAutoposition.eAutoPos_CenterCenter)
                {
                    Component.SetState_NameAutoPos(TTextAutoposition.eAutoPos_Manual);
                    Component.BeginModify();
                    RefDes.BeginModify();
                    switch (Convert.ToInt32(Component.GetState_Rotation()))
                    {
                    case 0:    //for bottom: 90=270
                        RefDes.SetState_Rotation(0);
                        break;

                    case 90:
                        if (RefDes.GetState_Layer() == TV6_Layer.eV6_BottomOverlay)
                        {
                            RefDes.SetState_Rotation(270);
                        }
                        else
                        {
                            RefDes.SetState_Rotation(90);
                        }
                        break;

                    case 180:
                        RefDes.SetState_Rotation(0);
                        break;

                    case 270:
                        if (RefDes.GetState_Layer() == TV6_Layer.eV6_BottomOverlay)
                        {
                            RefDes.SetState_Rotation(270);
                        }
                        else
                        {
                            RefDes.SetState_Rotation(90);
                        }
                        break;
                    }



                    //Component.SetState_NameAutoPos(TTextAutoposition.eAutoPos_CenterCenter);
                    Component.ChangeNameAutoposition(TTextAutoposition.eAutoPos_CenterCenter);
                    RefDes.EndModify();
                    RefDes.GraphicallyInvalidate();
                    Component.EndModify();
                    Component.GraphicallyInvalidate();
                }
                //DXP.Utils.PercentUpdate();
                Component = (IPCB_Component)BoardIterator.NextPCBObject();
            }
            //Iterator clean-up
            Board.BoardIterator_Destroy(ref BoardIterator);
            Board.GraphicalView_ZoomRedraw();
            //Board.GraphicallyInvalidate();
            //DXP.Utils.PercentFinish();
            System.Windows.Forms.MessageBox.Show("Process Complete");
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
        }
    }
Пример #14
0
    /// <summary>
    /// Checks mechanical layers 20 thru 24 for any objects. FixEmbededResistors Will move content to these layers which may interfere with current content or layer mapping.
    /// </summary>
    /// <returns>True: Layers are clear, False:Objects on one of the layers.</returns>
    public Boolean MechanicalClear()
    {
        try
        {
            //Checking Mechanical Layers

            //IPCB_Component Component; // component object
            IPCB_BoardIterator Iterator;
            IPCB_Primitive     Item;
            IPCB_Board         Board; // document board object

            Board = Util.GetCurrentPCB();
            if (Board == null)
            {
                return(false);
            }
            //Create board iterator
            Iterator = Board.BoardIterator_Create();
            //Create filter set for all availible primitives.
            PCB.TObjectSet FilterSet = new PCB.TObjectSet(new PCB.TObjectId[] { PCB.TObjectId.eArcObject, PCB.TObjectId.eViaObject, PCB.TObjectId.eTrackObject, PCB.TObjectId.eTextObject, PCB.TObjectId.eFillObject, PCB.TObjectId.ePadObject, PCB.TObjectId.eComponentObject, PCB.TObjectId.eNetObject, PCB.TObjectId.ePolyObject, PCB.TObjectId.eDimensionObject, PCB.TObjectId.eCoordinateObject, PCB.TObjectId.eEmbeddedObject, PCB.TObjectId.eEmbeddedBoardObject, PCB.TObjectId.eFromToObject, PCB.TObjectId.eConnectionObject, PCB.TObjectId.eComponentBodyObject });
            Iterator.AddFilter_ObjectSet(FilterSet);
            //Filter for mechanical layers only.
            Iterator.AddFilter_LayerSet_2(PCBConstant.V7MechanicalLayersSet); //BoardIterator.AddFilter_LayerSet(PCBConstant.MechanicalLayersSet);
            Iterator.AddFilter_Method(TIterationMethod.eProcessAll);

            int x = 0;
            Item = Iterator.FirstPCBObject();
            while (Item != null)
            {
                x++; Item = Iterator.NextPCBObject();
            }
            DXP.Utils.PercentInit("Checking Mechanical Layers", x);

            ///Step through all objects on mechanical layers
            ///to see if they are on layer 20 through 24.
            Item = Iterator.FirstPCBObject();
            while (Item != null)
            {
                for (ulong i = (ulong)ToolsPreferences.FirstResistorLayer + 1; i <= (ulong)(ToolsPreferences.FirstResistorLayer + ToolsPreferences.LayerCount); i++)
                {
                    if (Item.GetState_V7Layer().ID == V7_Layer.MechanicalLayer(i).ID) //Compare item layer to MechanicalLayer i.
                    {
                        return(false);
                    }
                }
                Item = Iterator.NextPCBObject();
                DXP.Utils.PercentUpdate();
            }

            DXP.Utils.PercentFinish();
            //Iterator clean-up
            Board.BoardIterator_Destroy(ref Iterator);
            return(true);
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            error = true;
            return(false);
        }
    }
Пример #15
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;
        }
    }
Пример #16
0
    public void PrimPrimTest()
    {
        IPCB_BoardIterator BoardIterator;
        IPCB_Pad           Pad, Selected1 = null, Selected2 = null;
        IPCB_Board         Board = Util.GetCurrentPCB();

        if (Board == null)
        {
            return;
        }

        double OriginX = EDP.Utils.CoordToMils(Board.GetState_XOrigin());
        double OriginY = EDP.Utils.CoordToMils(Board.GetState_YOrigin());

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


        Pad = (IPCB_Pad)BoardIterator.FirstPCBObject();

        while (Pad != null)
        {
            //RefDes = Component.GetState_Name().GetState_Text();
            //Determines if component is a variant.
            if (Selected1 == null && Pad.GetState_Selected() == true)
            {
                Selected1 = Pad;
            }
            else if (Pad.GetState_Selected() == true)
            {
                Selected2 = Pad;
            }
            if (Selected1 != null && Selected2 != null)
            {
                break;
            }


            Pad = (IPCB_Pad)BoardIterator.NextPCBObject();
        }
        if (Selected1 == null || Selected2 == null)
        {
            return;
        }

        bool bot = false, top = false;

        if (Selected1.GetState_Layer() == TV6_Layer.eV6_BottomLayer)
        {
            Selected1.SetState_Layer(TV6_Layer.eV6_TopLayer);
            top = true;
        }

        if (Selected2.GetState_Layer() == TV6_Layer.eV6_BottomLayer)
        {
            Selected2.SetState_Layer(TV6_Layer.eV6_TopLayer);
            bot = true;
        }

        MessageBox.Show(EDP.Utils.CoordToMMs(Board.PrimPrimDistance(Selected1, Selected2)).ToString());

        if (top)
        {
            Selected1.SetState_Layer(TV6_Layer.eV6_BottomLayer);
        }

        if (bot)
        {
            Selected2.SetState_Layer(TV6_Layer.eV6_BottomLayer);
        }

        //Iterator clean-up
        Board.BoardIterator_Destroy(ref BoardIterator);
    }
Пример #17
0
    private bool MultiBeforeViaReplace()
    {
        //if (PCBServer == null)
        //    return false;

        IPCB_BoardIterator BoardIterator;
        List <IPCB_Via>    BoardVias = new List <IPCB_Via>();
        IPCB_Via           Via;

        Board = Util.GetCurrentPCB();

        if (Board == null)
        {
            return(false);
        }

        BoardIterator = Board.BoardIterator_Create();

        //Iterate theough all components on the board.
        PCB.TObjectSet FilterSet = new PCB.TObjectSet();
        //Filter for components only.
        FilterSet.Add(PCB.TObjectId.eViaObject);
        BoardIterator.AddFilter_ObjectSet(FilterSet);
        BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet); //Filter all layers.
        BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);

        IPCB_DrillLayerPair        DrillPair = null;
        List <IPCB_DrillLayerPair> OldPairs  = new List <IPCB_DrillLayerPair>();
        List <IPCB_DrillLayerPair> NewPairs  = new List <IPCB_DrillLayerPair>();

        for (int i = 0; i < Board.GetState_DrillLayerPairsCount(); i++)
        {
            DrillPair = Board.GetState_LayerPair(i);
            if (lstBefore.SelectedItems.Contains(DrillPair.GetState_Description()))
            {
                OldPairs.Add(DrillPair);
            }
            if (lstAfter.SelectedItems.Contains(DrillPair.GetState_Description()))
            {
                NewPairs.Add(DrillPair);
            }
        }

        //Collect board vias that meet requirements
        Via = BoardIterator.FirstPCBObject() as IPCB_Via;
        while (Via != null)
        {
            foreach (IPCB_DrillLayerPair OldPair in OldPairs)
            {
                if (Via.GetState_StartLayer() == OldPair.GetState_StartLayer() && Via.GetState_StopLayer() == OldPair.GetState_StopLayer())
                {
                    if (SelectedOnly)
                    {
                        if (Via.GetState_Selected())
                        {
                            BoardVias.Add(Via);
                            break;
                        }
                    }
                    else
                    {
                        BoardVias.Add(Via);
                        break;
                    }
                }
            }
            Via = BoardIterator.NextPCBObject() as IPCB_Via;
        }

        Board.BoardIterator_Destroy(ref BoardIterator);

        DXP.Utils.PercentInit("Replacing Vias", BoardVias.Count);//Progressbar init.
        //Replace vias

        Board.BeginModify();

        IPCB_Net        Net = null;
        int             X, Y;
        List <IPCB_Via> Replaced = new List <IPCB_Via>();

        while (BoardVias.Count > 0)
        {
            X   = BoardVias[0].GetState_XLocation();
            Y   = BoardVias[0].GetState_YLocation();
            Net = BoardVias[0].GetState_Net();
            Replaced.Add(BoardVias[0]);

            for (int i = 1; i < BoardVias.Count; i++)
            {
                foreach (IPCB_DrillLayerPair OldPair in OldPairs)
                {
                    if (BoardVias[i].GetState_Net() == Net)
                    {
                        if (BoardVias[i].GetState_XLocation() == X)
                        {
                            if (BoardVias[i].GetState_YLocation() == Y)
                            {
                                if (BoardVias[i].GetState_StartLayer() == OldPair.GetState_StartLayer())
                                {
                                    if (BoardVias[i].GetState_StopLayer() == OldPair.GetState_StopLayer())
                                    {
                                        if (SelectedOnly)
                                        {
                                            if (BoardVias[i].GetState_Selected())
                                            {
                                                Replaced.Add(BoardVias[i]);
                                            }
                                        }
                                        else
                                        {
                                            Replaced.Add(BoardVias[i]);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (Replaced.Count == lstBefore.SelectedItems.Count)
            {
                ReplaceVia(Replaced[0], NewPairs, false);
            }

            //Remove replaced vias from BoardVias (clean up)
            foreach (IPCB_Via OldVia in Replaced)
            {
                DXP.Utils.PercentUpdate();
                BoardVias.Remove(OldVia);
                if (Replaced.Count == lstBefore.SelectedItems.Count)
                {
                    Board.RemovePCBObject(OldVia);
                }
            }
            Replaced.Clear();
        }

        Board.EndModify();

        DXP.Utils.PercentFinish();
        return(true);
    }
Пример #18
0
    /// <summary>
    /// Aligns variant component to base component.
    /// </summary>
    void AlignSelected()
    {
        IPCB_BoardIterator BoardIterator;
        IPCB_Component     Component;

        string RefDes;

        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();
        //Filter for components only.
        FilterSet.Add(PCB.TObjectId.eComponentObject);
        BoardIterator.AddFilter_ObjectSet(FilterSet);
        BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet); //Filter all layers.
        BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);

        Component = (IPCB_Component)BoardIterator.FirstPCBObject();
        Board.BeginModify();

        while (Component != null)
        {
            RefDes = Component.GetState_Name().GetState_Text();
            if (Component.GetState_SourceUniqueId() != null)
            {
                if (!Component.GetState_SourceUniqueId().Contains("@") || RefDes.Contains("EM") || RefDes.Contains("FM")) //Verify component is not a variant.
                {
                    if (RefDes.Contains("EM"))
                    {
                        RefDes = RefDes.Replace("EM", "FM");
                    }
                    else if (RefDes.Contains("FM"))
                    {
                        RefDes = RefDes.Replace("FM", "EM");
                    }

                    if (SelectedRef.Contains(RefDes))
                    {
                        foreach (IPCB_Component item in SelectedComp)
                        {
                            if (item.GetState_Name().GetState_Text() == RefDes) //Match component
                            {
                                //Copy position, laye and rotation settings from base to variant.
                                item.SetState_Layer(Component.GetState_Layer());
                                item.SetState_XLocation(Component.GetState_XLocation());
                                item.SetState_YLocation(Component.GetState_YLocation());
                                item.SetState_Rotation(Component.GetState_Rotation());

                                Board.SetState_DocumentHasChanged();
                                break;
                            }
                        }
                    }
                }
            }


            Component = (IPCB_Component)BoardIterator.NextPCBObject();
        }
        Board.EndModify();

        Board.GraphicalView_ZoomRedraw();
        Board.GraphicallyInvalidate();
        //Iterator clean-up
        Board.BoardIterator_Destroy(ref BoardIterator);
        MessageBox.Show("Process Complete");
    }
Пример #19
0
    /// <summary>
    /// Moves the mechanical objects of a component on a midlayer to its respective layer.
    /// </summary>
    public void FixEmbededResistors()
    {
        try
        {
            List <IPCB_Component>          EmbededResistors = new List <IPCB_Component>();
            List <TV6_Layer>               UsedLayers       = new List <TV6_Layer>();
            IPCB_Component                 Component; // component object
            IPCB_BoardIterator             BoardIterator;
            IPCB_Board                     Board;     // document board object
            SortedDictionary <string, int> LayerCounts = new SortedDictionary <string, int>();

            DXP.Utils.StatusBarSetState(2, "Checking Mechanical Layers");
            //Check to see if the mechanical layers we will be using are clear.
            DXP.Utils.StatusBarSetStateDefault();
            if (!MechanicalClear())
            {
                if (error)
                {
                    return;
                }
                if (MessageBox.Show("There is information on Layers " + (ToolsPreferences.FirstResistorLayer + 1) + " to " + (ToolsPreferences.FirstResistorLayer + ToolsPreferences.LayerCount - 1) + ". New information may be added to these layers." + "\n" + "Do you wish to continue?", "Mechanical Layers Not Empyt", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }
            }
            if (error)
            {
                return;
            }

            Board = Util.GetCurrentPCB();
            if (Board == null)
            {
                return;
            }
            //Filter by components on mid signal layers
            BoardIterator = Board.BoardIterator_Create();
            PCB.TObjectSet FilterSet = new PCB.TObjectSet();
            //Filter for components only
            FilterSet.Add(PCB.TObjectId.eComponentObject);
            BoardIterator.AddFilter_ObjectSet(FilterSet);
            BoardIterator.AddFilter_LayerSet(PCBConstant.V6cMidLayersSet);
            BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);

            //Iterate through all components looking for components on mid layers.
            Component = (IPCB_Component)BoardIterator.FirstPCBObject();
            while (Component != null)
            {
                if (UsedLayers.IndexOf(Component.GetState_Layer()) == -1)
                {
                    UsedLayers.Add(Component.GetState_Layer()); //Collect a non-duplicate list of mid layers with components
                    LayerCounts.Add(EDP.Utils.LayerToString(new V7_Layer(Component.GetState_Layer())), 1);
                }
                else
                {
                    LayerCounts[EDP.Utils.LayerToString(new V7_Layer(Component.GetState_Layer()))]++;
                }

                EmbededResistors.Add(Component); //Colect a list of all components on mid layers.
                Component = (IPCB_Component)BoardIterator.NextPCBObject();
            }
            Board.BoardIterator_Destroy(ref BoardIterator);

            //No embeded resistors on this board.
            if (EmbededResistors.Count <= 0)
            {
                LayerReport(LayerCounts);
                return;
            }

            ///Sort the list of layers
            ///First comp layer in list will be assigned to mech layer 19.
            ///Second comp layer will be assigned to mech layer 20 and so forth.
            UsedLayers.Sort();

            LayerCounts = LayerReport(LayerCounts);

            if (LayerCounts != null)
            {
                List <TV6_Layer> tmpUsedLayers = new List <TV6_Layer>(UsedLayers.Count);
                //Build a temp list of used layers.
                UsedLayers.ForEach((item) =>
                {
                    tmpUsedLayers.Add(item);
                });

                //Remove layers from the list that the user turned off.
                foreach (TV6_Layer item in tmpUsedLayers)
                {
                    if (!LayerCounts.ContainsKey(EDP.Utils.LayerToString(new V7_Layer(item))))
                    {
                        UsedLayers.Remove(item);
                    }
                }

                DXP.Utils.StatusBarSetState(2, "Updating Embeded Components");

                MoveMechLayers(EmbededResistors, UsedLayers, LayerCounts);

                DXP.Utils.StatusBarSetStateDefault();

                //Redraw board to refresh changes.
                Board.GraphicalView_ZoomRedraw();
                DXP.Utils.ShowInfo("Process complete.");
            }
            else
            {
                DXP.Utils.ShowInfo("Process canceled.");
            }
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
        }
    }
Пример #20
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="argHeights">Reference to the dict storing report info.</param>
    /// <param name="tmpList"></param>
    private void SetBodyHeight(Dictionary <string, Heights> argHeights, List <string> tmpList)
    {
        //?Body.GetState_DescriptorString()
        //"3D Extruded  (Mechanical 2, Bot Assy)  Standoff=0mil  Overall=163mil  (26522.112mil, 20350.482mil)"
        //? Body.GetState_DescriptorString()
        //"3D STEP SW3dPS-74VHC32 - 14lead IC SOIC (Mechanical 2, Bot Assy)  Standoff=-0.5mil  Overall=68.5mil  (26522.107mil, 20347.985mil)"
        //argComponent.GetState_Name().GetState_ConvertedString() "U18EM" string
        //Body.GetModel().GetFileName()   "SW3dPS-74VHC32 - 14lead IC SOIC.STEP"  string

        IPCB_Component     Component; // component object
        IPCB_BoardIterator BoardIterator;
        IPCB_Board         Board;     // document board object
        IPCB_GroupIterator CompIterator;
        IPCB_Primitive     CompItem;
        bool FoundBody = false;

        Board = Util.GetCurrentPCB(true);
        if (Board == null)
        {
            return;
        }

        BoardIterator = Board.BoardIterator_Create();
        PCB.TObjectSet FilterSet = new PCB.TObjectSet();
        //Filter for components only
        FilterSet.Add(PCB.TObjectId.eComponentObject);
        BoardIterator.AddFilter_ObjectSet(FilterSet);
        BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet);
        BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);

        //Iterate through all components looking for components.
        Component = (IPCB_Component)BoardIterator.FirstPCBObject();
        while (Component != null)
        {
            if (tmpList.Contains(Component.GetState_SourceDesignator()))
            {
                if (Component.GetState_SourceDesignator() == "JA1" || Component.GetState_SourceDesignator() == "JB6" || Component.GetState_SourceDesignator() == "U2EM")
                {
                    MessageBox.Show("temp");
                }
                //argComponent.GetState_SourceDesignator()
                CompIterator = Component.GroupIterator_Create();
                CompIterator.AddFilter_LayerSet_2(PCBConstant.V7AllLayersSet);
                CompItem = CompIterator.FirstPCBObject();

                IPCB_ComponentBody Body, temp;
                FoundBody = false;
                Body      = null;
                while (CompItem != null)
                {
                    if (CompItem.GetState_ObjectIDString() == "ComponentBody")
                    {
                        temp = CompItem as IPCB_ComponentBody;
                        if (!FoundBody)
                        {
                            FoundBody = true;
                            Body      = temp;
                        }
                        else
                        {
                            if (GetCompHeight(Body) < GetCompHeight(temp))
                            {
                                Body = temp;
                            }
                        }
                    }
                    CompItem = CompIterator.NextPCBObject();
                }

                Component.BeginModify();
                SetCompHeight(Body, EDP.Utils.MilsToCoord(argHeights[Component.GetState_SourceDesignator()].ParameterHeight));
                Component.EndModify();

                Body = null;
            }
            Component = (IPCB_Component)BoardIterator.NextPCBObject();
        }


        try
        {
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
Пример #21
0
    public void GetDestinationParts()
    {
        SelectedDestRef            = new List <string>();
        selectedDestinationObjects = new clsSelectedObjects();
        Destination = new clsOutput();

        string parameterName, parameterValue;

        IPCB_BoardIterator BoardIterator;
        IPCB_Parameter     parameter;
        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.eComponentObject:
                    IPCB_Component componentObject = Primitive as IPCB_Component;
                    selectedDestinationObjects.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);

                    IPCB_PrimitiveParameters componentParameters = componentObject as IPCB_PrimitiveParameters;
                    newComp.Parameters = new SerializableDictionary <string, string>();
                    for (int i = 0; i < componentParameters.Count(); i++)
                    {
                        parameter     = componentParameters.GetParameterByIndex(i);
                        parameterName = parameter.GetName();
                        if (parameter.GetValue() == null)
                        {
                            parameterValue = "null";
                        }
                        else
                        {
                            parameterValue = parameter.GetValue();
                        }


                        newComp.Parameters.Add(parameterName, parameterValue);
                    }

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

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

                    SelectedDestRef.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;

                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"
    }
    public void NetConnect()
    {
#if DEBUG
        Stopwatch stopwatch;
        stopwatch = new Stopwatch();
        stopwatch.Start();
#endif

        IPCB_BoardIterator BoardIterator;

        IPCB_GroupIterator CompIterator;
        IPCB_Primitive     CompItem;
        IPCB_Board         Board = Util.GetCurrentPCB();

        IPCB_Component Comp;

        if (Board == null)
        {
            return;
        }


        //Iterate theough all components on the board.
        BoardIterator = Board.BoardIterator_Create();
        PCB.TObjectSet FilterSet = new PCB.TObjectSet();

        //Filter for components only.
        FilterSet.Add(PCB.TObjectId.eComponentObject);
        FilterSet.Add(PCB.TObjectId.ePadObject);
        FilterSet.Add(PCB.TObjectId.eTrackObject);
        BoardIterator.AddFilter_ObjectSet(FilterSet);
        BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet); //Filter all layers.
        BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);
        CompItem = BoardIterator.FirstPCBObject();
        //Comp = (IPCB_Component)BoardIterator.FirstPCBObject();

        while (CompItem != null)
        {
            if (CompItem.GetState_Selected())
            {
                if (CompItem.GetState_ObjectIDString() == "Pad" || CompItem.GetState_ObjectIDString() == "Track")
                {
                    if (CompItem.GetState_InNet())
                    {
                        CompItem.GetState_Net().ShowNetConnects();
                    }
                }
                else
                {
                    Comp         = (IPCB_Component)CompItem;
                    CompIterator = Comp.GroupIterator_Create();
                    CompIterator.AddFilter_LayerSet_2(PCBConstant.V7AllLayersSet);
                    CompItem = CompIterator.FirstPCBObject();

                    while (CompItem != null)
                    {
                        if (CompItem.GetState_InNet())
                        {
                            CompItem.GetState_Net().ShowNetConnects();
                        }
                        CompItem = CompIterator.NextPCBObject();
                    }
                }
            }
            CompItem = BoardIterator.NextPCBObject();
        }


#if DEBUG
        stopwatch.Stop();
        Debug.WriteLine(stopwatch.ElapsedMilliseconds);
#endif
    }
Пример #23
0
    private void btnRemoveDupe_Click(object sender, EventArgs e)
    {
        DXP.Utils.StatusBarSetState(2, "Removing Vias");

        //if (PCBServer == null)
        //    return false;

        IPCB_BoardIterator BoardIterator;
        List <IPCB_Via>    BoardVias    = new List <IPCB_Via>();
        List <IPCB_Via>    clnBoardVias = new List <IPCB_Via>();
        IPCB_Via           Via;

        Board = Util.GetCurrentPCB();

        if (Board == null)
        {
            MessageBox.Show("Unable to complete. Error occured.");
            return;
        }

        BoardIterator = Board.BoardIterator_Create();

        //Iterate theough all components on the board.
        PCB.TObjectSet FilterSet = new PCB.TObjectSet();
        //Filter for components only.
        FilterSet.Add(PCB.TObjectId.eViaObject);
        BoardIterator.AddFilter_ObjectSet(FilterSet);
        BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet); //Filter all layers.
        BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);

        IPCB_DrillLayerPair        DrillPair = null;
        List <IPCB_DrillLayerPair> OldPairs  = new List <IPCB_DrillLayerPair>();

        for (int i = 0; i < Board.GetState_DrillLayerPairsCount(); i++)
        {
            DrillPair = Board.GetState_LayerPair(i);
            if (lstBefore.SelectedItems.Contains(DrillPair.GetState_Description()))
            {
                OldPairs.Add(DrillPair);
            }
        }

        //Collect board vias that meet requirements
        Via = BoardIterator.FirstPCBObject() as IPCB_Via;
        while (Via != null)
        {
            foreach (IPCB_DrillLayerPair OldPair in OldPairs)
            {
                if (Via.GetState_StartLayer() == OldPair.GetState_StartLayer() && Via.GetState_StopLayer() == OldPair.GetState_StopLayer())
                {
                    BoardVias.Add(Via);
                    break;
                }
            }
            Via = BoardIterator.NextPCBObject() as IPCB_Via;
        }

        Board.BoardIterator_Destroy(ref BoardIterator);

        DXP.Utils.PercentInit("Removing Vias", BoardVias.Count * OldPairs.Count);//Progressbar init.
        //Replace vias

        Board.BeginModify();

        IPCB_Net        Net = null;
        int             X, Y;
        List <IPCB_Via> Replaced = new List <IPCB_Via>();

        foreach (IPCB_DrillLayerPair OldPair in OldPairs)
        {
            clnBoardVias.AddRange(BoardVias);

            while (clnBoardVias.Count > 0)
            {
                X   = clnBoardVias[0].GetState_XLocation();
                Y   = clnBoardVias[0].GetState_YLocation();
                Net = clnBoardVias[0].GetState_Net();
                Replaced.Add(clnBoardVias[0]);

                for (int i = 1; i < clnBoardVias.Count; i++)
                {
                    if (clnBoardVias[i].GetState_Net() == Net)
                    {
                        if (clnBoardVias[i].GetState_XLocation() == X)
                        {
                            if (clnBoardVias[i].GetState_YLocation() == Y)
                            {
                                if (clnBoardVias[i].GetState_StartLayer() == OldPair.GetState_StartLayer())
                                {
                                    if (clnBoardVias[i].GetState_StopLayer() == OldPair.GetState_StopLayer())
                                    {
                                        Replaced.Add(clnBoardVias[i]);
                                    }
                                }
                            }
                        }
                    }
                }


                if (Replaced.Count > 1)
                {
                    //Remove replaced vias from BoardVias (clean up)
                    for (int i = 1; i < Replaced.Count; i++)
                    {
                        clnBoardVias.Remove(Replaced[i]);
                        Board.RemovePCBObject(Replaced[i]);
                        DXP.Utils.PercentUpdate();
                    }
                }
                clnBoardVias.Remove(Replaced[0]);
                DXP.Utils.PercentUpdate();
                Replaced.Clear();
            }
        }

        Board.EndModify();

        DXP.Utils.PercentFinish();
        MessageBox.Show("Process Complete");
    }