/// <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; } }
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 }
/// <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; } }