Ejemplo n.º 1
0
    /// <summary>
    /// Moves the all mechanical objects in embeded components to their new layers.
    /// </summary>
    /// <param name="EmbededResistors">List of components to be processed.</param>
    /// <param name="UsedLayers">List of used layers</param>
    /// <param name="LayerCounts">
    /// List of layers used that has been updated by the user.
    /// Allows for the user to disable specific layers to be modified.
    /// </param>
    void MoveMechLayers(List <IPCB_Component> EmbededResistors, List <TV6_Layer> UsedLayers, SortedDictionary <string, int> LayerCounts)
    {
        DXP.Utils.PercentInit("Updating Embeded Components", EmbededResistors.Count);

        IPCB_GroupIterator CompIterator;
        IPCB_Primitive     CompItem;
        IPCB_Component     Component;

        //Step through each embeded component
        for (int i = 0; i <= EmbededResistors.Count - 1; i++)
        {
            Component = EmbededResistors[i];
            //Iterate through all objects of the current component.
            CompIterator = Component.GroupIterator_Create();
            CompIterator.AddFilter_LayerSet_2(PCBConstant.V7MechanicalLayersSet);
            CompItem = CompIterator.FirstPCBObject();

            while (CompItem != null)
            {
                //Check if object is on mech layer.
                if (new V7_Layer(CompItem.GetState_V7Layer()).IsMechanicalLayer() && LayerCounts.ContainsKey(EDP.Utils.LayerToString(new V7_Layer(Component.GetState_Layer()))))
                {
                    //Move object to its new respective mech layer.
                    CompItem.BeginModify();
                    CompItem.SetState_V7Layer(V7_Layer.MechanicalLayer((ulong)UsedLayers.IndexOf(Component.GetState_Layer()) + 19));
                    CompItem.EndModify();
                }
                CompItem = CompIterator.NextPCBObject();
            }
            DXP.Utils.PercentUpdate();
        }
        DXP.Utils.PercentFinish();
    }
    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
    }
Ejemplo n.º 3
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;
        }
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Gets body height of specified footprint.
    /// </summary>
    /// <param name="argHeights">Reference to the dict storing report info.</param>
    /// <param name="argComponent">Footprint to get height from.</param>
    private void ObtainBodyHeight(ref Dictionary <string, Heights> argHeights, IPCB_Component argComponent)
    {
        try
        {
            IPCB_GroupIterator CompIterator;
            IPCB_Primitive     CompItem;
            IPCB_ComponentBody Body;
            bool FoundBody = false;

            CompIterator = argComponent.GroupIterator_Create();
            CompIterator.AddFilter_LayerSet_2(PCBConstant.V7AllLayersSet);
            CompItem = CompIterator.FirstPCBObject();
            if (argComponent.GetState_SourceDesignator() == null)
            {
                DialogResult result = MessageBox.Show("Footprint " + argComponent.GetState_Name().GetState_ConvertedString() + " has no source designator. This is cause by a footprint not linked to a schematic symbol.\nDo you wish to continue?", "Unlinked Footprint", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                if (result == DialogResult.Yes)
                {
                    argHeights.Add(argComponent.GetState_Name().GetState_ConvertedString(), new Heights()
                    {
                        BodyHeight = 0
                    });
                }
                else
                {
                    argHeights = null;
                    return;
                }
            }
            argHeights[argComponent.GetState_Name().GetState_ConvertedString()].Footprint = argComponent.GetState_Pattern();
            while (CompItem != null)
            {
                if (CompItem.GetState_ObjectIDString() == "ComponentBody")
                {
                    Body = CompItem as IPCB_ComponentBody;
                    if (FoundBody)
                    {
                        //DXP.Utils.ShowError("Multiple bodies.\nDo Something.");
                        if (argHeights[argComponent.GetState_Name().GetState_ConvertedString()].BodyHeight < EDP.Utils.CoordToMils(GetCompHeight(Body)))
                        {
                            argHeights[argComponent.GetState_Name().GetState_ConvertedString()].BodyHeight = EDP.Utils.CoordToMils(GetCompHeight(Body));
                        }
                    }
                    else
                    {
                        if (argComponent.GetState_SourceDesignator() == "JA1" || argComponent.GetState_SourceDesignator() == "JB6" || argComponent.GetState_SourceDesignator() == "U2EM")
                        {
                            MessageBox.Show("temp");
                        }
                        FoundBody = true;
                        argHeights[argComponent.GetState_Name().GetState_ConvertedString()].BodyHeight = EDP.Utils.CoordToMils(GetCompHeight(Body));
                    }
                }
                CompItem = CompIterator.NextPCBObject();
            }
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }