public void Execute(IPCBIWindow parent) { IMatrix m = parent.GetMatrix(); IStep step = parent.GetCurrentStep(); foreach (ICMPObject comp in step.GetAllCMPObjects()) { IPackageSpecificsD pack = comp.GetPackageSpecificsD(); RectangleD rectBody = pack.GetBodyBounds(); RectangleD rect = pack.GetBounds(); comp.AddComponentAttribute("Body_Width", rectBody.Width.ToString()); comp.AddComponentAttribute("Body_Height", rectBody.Height.ToString()); // rect = GetPinBounds(comp); comp.AddComponentAttribute("Pin_Width", rect.Width.ToString()); comp.AddComponentAttribute("Pin_Height", rect.Height.ToString()); comp.AddComponentAttribute("Pin_Area", (rect.Height * rect.Width).ToString()); // if(comp.GetPinList().Count == 2) // { // string shouldBe = GetGeometrieName(rect.Height * rect.Width); // comp.AddComponentAttribute("Geometry_Calculated", shouldBe ); // } } parent.UpdateView(); }
private void nodFile(IPCBIWindow parent, string fileName, IStep step, IMatrix matrix, ref List <string> errorLogFile) { List <string> lstStrNetNames = step.GetAllNetNames(); List <ICMPObject> lstAllCMPList = step.GetAllCMPObjects(); List <IODBObject> lstListOfAllDrillObjects = creatingDrillList(matrix, step); if (lstListOfAllDrillObjects == null) { errorLogFile.Add("Method: nodFile + lstListOfAllDrillObjects is null"); return; } List <ThtPin> topTHTPinList, botTHTPinList = new List <ThtPin>(); List <INet> lstINetINetList = new List <INet>(); List <string> dataList; fileName = Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName) + ".nod"); foreach (string netName in lstStrNetNames) { lstINetINetList.Add(step.GetNet(netName)); } checkPinLaysOverHole(step, lstListOfAllDrillObjects, out topTHTPinList, out botTHTPinList, matrix); fillNODDataList(parent, step, matrix, lstAllCMPList, topTHTPinList, botTHTPinList, out dataList, lstINetINetList, lstListOfAllDrillObjects, ref errorLogFile); if (dataList != null && !string.IsNullOrEmpty(fileName)) { writeToFile(fileName, dataList); } }
public void Execute(IPCBIWindow parent) { this.parent = parent; IStep step = parent.GetCurrentStep(); if (step == null) { return; } List <string> columsStrings = new List <string>(); columsStrings.Add("Analyse Resource"); columsStrings.Add("Reference"); columsStrings.Add("Distance"); columsStrings.Add("Rule"); columsStrings.Add("Start"); columsStrings.Add("End"); PCB_Investigator.PCBIWindows.PCBIResultDialog resultDLG = new PCB_Investigator.PCBIWindows.PCBIResultDialog(columsStrings); double unit = 1; double distance = PCBI.MathUtils.IMath.MM2Mils(1.0f); if (parent.GetUnit()) { unit = 25.4; //MessageBox.Show("Component to Outline distance: " + PCBI.MathUtils.IMath.Mils2MM(distance).ToString("N3") + " micron", "DRC Component to Board Outline"); } else { //MessageBox.Show("Component to Outline distance: " + distance.ToString("N3") + " mils", "DRC Component to Board Outline"); unit = 1; } foreach (ICMPObject cmp in step.GetAllCMPObjects()) { PCBI.MathUtils.IPolyClass CMP_Poly = cmp.GetPolygonOutline(false); IODBObject boardOutline = parent.GetCurrentStep().GetPCBOutlineAsODBObject(); IPolyClass polyOutline = boardOutline.GetPolygonOutline(); PointD start = new PointD(0, 0); PointD end = new PointD(0, 0); double measuredDistance = cmp.GetPolygonOutline().DistanceTo(polyOutline, ref start, ref end); if (measuredDistance < distance) { ListViewItem lvi = new ListViewItem("Cpmp2Outline"); lvi.SubItems.Add(cmp.Ref); lvi.SubItems.Add((measuredDistance * unit).ToString()); lvi.SubItems.Add((distance * unit).ToString()); lvi.SubItems.Add((start * unit).ToString()); lvi.SubItems.Add((end * unit).ToString()); lvi.Tag = cmp; resultDLG.AddListViewItem(lvi); } } resultDLG.ItemSelectionChanged += ResultDLG_ItemSelectionChanged1;; resultDLG.Size = new Size(500, 350); resultDLG.Show(); }
public void Execute(IPCBIWindow parent) { IStep step = parent.GetCurrentStep(); IFilter filter = new IFilter(parent); List <String> GroundNames = new List <string>(); GroundNames.Add("gnd"); GroundNames.Add("ground"); GroundNames.Add("/gnd"); List <String> VCCNames = new List <string>(); VCCNames.Add("3v"); VCCNames.Add("vcc"); VCCNames.Add("vtt"); VCCNames.Add("/1v"); foreach (ICMPObject cmp in step.GetAllCMPObjects()) { if (cmp.GetPinList().Count == 2) { List <IPin> plist = cmp.GetPinList(); bool gndfound = false; bool vccFound = false; foreach (IPin pin in plist) { if (StartsWithStringOfList(GroundNames, pin.GetNetNameOnIPin(cmp).ToLower())) { gndfound = true; } if (StartsWithStringOfList(VCCNames, pin.GetNetNameOnIPin(cmp).ToLower())) { vccFound = true; } } if (gndfound && vccFound) { cmp.ObjectColor = Color.ForestGreen; foreach (IPin pin in plist) { if (StartsWithStringOfList(GroundNames, pin.GetNetNameOnIPin(cmp).ToLower())) { pin.SetPinColor(Color.BlueViolet, cmp); } if (StartsWithStringOfList(VCCNames, pin.GetNetNameOnIPin(cmp).ToLower())) { pin.SetPinColor(Color.Red, cmp); } } } } } parent.UpdateView(); }
public void Execute(IPCBIWindow parent) { IStep step = parent.GetCurrentStep(); if (step == null) { return; } IFilter filter = new IFilter(parent); StringBuilder sb = new StringBuilder(); var excelType = Type.GetTypeFromProgID("Excel.Application"); dynamic excel = Activator.CreateInstance(excelType); excel.Visible = true; excel.Workbooks.Add(); int i = 1; //excel.Cells(i, 1).Value = "Reference \t Partname \t Package \t Value"; //excel.Cells(i, 1).Font.Size = "14"; //i = i + 1; sb.Append("Reference;Partname;Package;Value" + Environment.NewLine); foreach (ICMPObject cmp in step.GetAllCMPObjects()) { string SValue = cmp.Value; if (String.IsNullOrEmpty(SValue)) { SValue = "0"; } sb.Append(cmp.Ref + ";" + cmp.PartName + ";" + cmp.UsedPackageName + ";" + SValue + Environment.NewLine); //excel.Cells(i, 1).Value = cmp.Ref +";" + cmp.PartName + ";"+ cmp.UsedPackageName +";" + cmp.Value; //excel.Cells(i, 1).Font.Size = "14"; i = i + 1; } string LVText = "Reference\tPartname\tPackage\tValue" + Environment.NewLine + sb.ToString(); string LVCsv = sb.ToString(); DataObject LVDataObject = new DataObject(); LVDataObject.SetData(DataFormats.Text, true, LVText); LVDataObject.SetData(DataFormats.CommaSeparatedValue, true, LVCsv); Clipboard.SetDataObject(LVDataObject, true); excel.ActiveSheet.Paste(); //release the object System.Runtime.InteropServices.Marshal.ReleaseComObject(excel); }
public void Execute(IPCBIWindow parent) { string Attrib = ""; ShowInputDialog(ref Attrib); IMatrix m = parent.GetMatrix(); IStep step = parent.GetCurrentStep(); foreach (ICMPObject comp in step.GetAllCMPObjects()) { comp.RemoveAttribute(Attrib); } parent.UpdateView(); }
public void Execute(IPCBIWindow parent) { IStep step = parent.GetCurrentStep(); IFilter filter = new IFilter(parent); foreach (ICMPObject cmp in step.GetAllCMPObjects()) { List <IPin> plist = cmp.GetPinList(); foreach (IPin pin in plist) { pin.ResetPinColor(cmp); } } parent.UpdateView(); }
public void Execute(IPCBIWindow parent) { if (parent.GetCurrentStep() == null) { return; } IStep step = parent.GetCurrentStep(); IFilter filter = new IFilter(parent); if (parent.GetCurrentStep() == null) { return; } if (step.GetCMPLayer(true) != null) { step.GetCMPLayer(true).EnableLayer(true); } if (step.GetCMPLayer(false) != null) { step.GetCMPLayer(false).EnableLayer(true); } double distance = PCBI.MathUtils.IMath.MM2Mils(0.5f); if (parent.GetUnit()) { MessageBox.Show("Component to Outline distance: " + PCBI.MathUtils.IMath.Mils2MM(distance).ToString("N3") + " micron", "DRC Component to Board Outline"); } else { MessageBox.Show("Component to Outline distance: " + distance.ToString("N3") + " mils", "DRC Component to Board Outline"); } foreach (ICMPObject cmp in step.GetAllCMPObjects()) { PCBI.MathUtils.IPolyClass CMP_Poly = cmp.GetPolygonOutline(false); IODBObject boardOutline = parent.GetCurrentStep().GetPCBOutlineAsODBObject(); IPolyClass polyOutline = boardOutline.GetPolygonOutline(); PointD start = new PointD(0, 0); PointD end = new PointD(0, 0); if (cmp.GetPolygonOutline().DistanceTo(polyOutline, ref start, ref end) < distance) { cmp.Select(true); } } parent.UpdateView(); }
public void Execute(IPCBIWindow parent) { IStep step = parent.GetCurrentStep(); if (step == null) { return; } IFilter filter = new IFilter(parent); StringBuilder sb = new StringBuilder(); dynamic wordApp = Activator.CreateInstance(Type.GetTypeFromProgID("Word.Application")); wordApp.Visible = true; dynamic wordDoc = wordApp.Documents.Add(); foreach (ICMPObject cmp in step.GetAllCMPObjects()) { string SValue = cmp.Value; if (String.IsNullOrEmpty(SValue)) { SValue = "0"; } sb.Append(cmp.Ref + ";" + cmp.PartName + ";" + cmp.UsedPackageName + ";" + SValue + Environment.NewLine); } string LVText = "Reference\tPartname\tPackage\tValue" + Environment.NewLine + sb.ToString(); dynamic rng = wordApp.ActiveDocument.Range(0, 0); rng.Text = LVText; System.Runtime.InteropServices.Marshal.ReleaseComObject(wordApp); }
public void Execute(IPCBIWindow parent) { IStep step = parent.GetCurrentStep(); IFilter filter = new IFilter(parent); foreach (ICMPObject cmp in step.GetAllCMPObjects()) { List <IPin> plist = cmp.GetPinList(); foreach (IPin pin in plist) { if (pin.GetNetNameOnIPin(cmp).ToLower().Contains("gnd")) { pin.SetPinColor(Color.Blue, cmp); } } } ICMPLayer layer = step.GetCMPLayer(true); if (layer != null) { layer.EnableLayer(true); } parent.UpdateView(); }
public void Execute(IPCBIWindow parent) { IStep step = parent.GetCurrentStep(); IODBLayer layer = (IODBLayer)step.GetLayer("top"); IFilter filter = new IFilter(parent); // Pins foreach (ICMPObject cmp in step.GetAllCMPObjects()) { foreach (IPin pin in cmp.GetPinList()) { IODBObject outlinePolygon = filter.CreatePolygon(layer); ISurfaceSpecifics specOutline = (ISurfaceSpecifics)outlinePolygon.GetSpecifics(); bool polyStart = true; PointF StartPoint = new PointF(0, 0); PointF EndPoint = new PointF(0, 0); foreach (IEdge edge in pin.GetPolygonOutline(cmp).GetEdges()) { if (polyStart) { polyStart = false; StartPoint = new PointF((float)edge.Begin.X, (float)edge.Begin.Y); specOutline.StartPolygon(false, StartPoint); if (edge is IArcEdge) { IArcEdge aEdge = (IArcEdge)edge; PointF start = new PointF((float)aEdge.Begin.X, (float)aEdge.Begin.Y); PointF end = new PointF((float)aEdge.End.X, (float)aEdge.End.Y); PointF center = new PointF((float)aEdge.Center.X, (float)aEdge.Center.Y); specOutline.AddArc(start, end, center, aEdge.ClockWise); if (aEdge.ClockWise) { EndPoint = end; } else { EndPoint = start; } } else if (edge is ILineEdge) { ILineEdge aEdge = (ILineEdge)edge; PointF start = new PointF((float)aEdge.Begin.X, (float)aEdge.Begin.Y); PointF end = new PointF((float)aEdge.End.X, (float)aEdge.End.Y); specOutline.AddLine(start, end); EndPoint = end; } } else if (edge is IArcEdge) { IArcEdge aEdge = (IArcEdge)edge; PointF start = new PointF((float)aEdge.Begin.X, (float)aEdge.Begin.Y); PointF end = new PointF((float)aEdge.End.X, (float)aEdge.End.Y); PointF center = new PointF((float)aEdge.Center.X, (float)aEdge.Center.Y); specOutline.AddArc(start, end, center, aEdge.ClockWise); if (aEdge.ClockWise) { EndPoint = end; } else { EndPoint = start; } } else if (edge is ILineEdge) { ILineEdge aEdge = (ILineEdge)edge; PointF start = new PointF((float)aEdge.Begin.X, (float)aEdge.Begin.Y); PointF end = new PointF((float)aEdge.End.X, (float)aEdge.End.Y); specOutline.AddLine(start, end); EndPoint = end; } } //specOutline.AddLine(EndPoint, StartPoint); specOutline.EndPolygon(); //close the new contour outlinePolygon.SetSpecifics(specOutline); } } parent.UpdateView(); }
public void Execute(IPCBIWindow parent) { if (parent.GetCurrentStep() == null) { return; } bool clearLayer = false; IStep step = parent.GetCurrentStep(); IFilter filter = new IFilter(parent); if (parent.GetCurrentStep() == null) { return; } IODBLayer layerTopPins = null; IODBLayer layerbotPins = null; if (layerTopPins == null) { layerTopPins = filter.CreateEmptyODBLayer("component_top_shapes", step.Name); if (clearLayer) { foreach (IODBObject o in layerTopPins.GetAllLayerObjects()) { layerTopPins.RemoveObject(o); } } } if (layerbotPins == null) { layerbotPins = filter.CreateEmptyODBLayer("component_bot_shapes", step.Name); if (clearLayer) { foreach (IODBObject o in layerbotPins.GetAllLayerObjects()) { layerbotPins.RemoveObject(o); } } } foreach (ICMPObject cmp in step.GetAllCMPObjects()) { PCBI.MathUtils.IPolyClass CMP_Poly = cmp.GetPolygonOutline(false); IODBObject outlinePolygon; if (cmp.PlacedTop) { outlinePolygon = filter.CreatePolygon(layerTopPins); } else { outlinePolygon = filter.CreatePolygon(layerbotPins); } ISurfaceSpecifics CMP_Body_Polygon = (ISurfaceSpecifics)outlinePolygon.GetSpecifics(); bool polyStart = true; foreach (IEdge edge in CMP_Poly.GetEdges()) { if (polyStart) { polyStart = false; CMP_Body_Polygon.StartPolygon(false, new PointF((float)edge.Begin.X, (float)edge.Begin.Y)); } else if (edge is IArcEdge) { IArcEdge aEdge = (IArcEdge)edge; PointF start = new PointF((float)aEdge.Begin.X, (float)aEdge.Begin.Y); PointF end = new PointF((float)aEdge.End.X, (float)aEdge.End.Y); PointF center = new PointF((float)aEdge.Center.X, (float)aEdge.Center.Y); CMP_Body_Polygon.AddArc(start, end, center, aEdge.ClockWise); } else if (edge is ILineEdge) { ILineEdge aEdge = (ILineEdge)edge; PointF start = new PointF((float)aEdge.Begin.X, (float)aEdge.Begin.Y); PointF end = new PointF((float)aEdge.End.X, (float)aEdge.End.Y); CMP_Body_Polygon.AddLine(start, end); } } CMP_Body_Polygon.EndPolygon(); //close the new contour outlinePolygon.SetSpecifics(CMP_Body_Polygon); } layerbotPins.EnableLayer(true); layerTopPins.EnableLayer(true); parent.UpdateView(); parent.UpdateControlsAndResetView(); }
public void Execute(IPCBIWindow parent) { if (parent.GetCurrentStep() == null) { return; } bool clearLayer = false; IStep step = parent.GetCurrentStep(); IODBLayer layerTopPins = null; IODBLayer layerbotPins = null; IFilter filter = new IFilter(parent); if (layerTopPins == null) { layerTopPins = filter.CreateEmptyODBLayer("component_top_shapes", step.Name); if (clearLayer) { foreach (IODBObject o in layerTopPins.GetAllLayerObjects()) { layerTopPins.RemoveObject(o); } } } if (layerbotPins == null) { layerbotPins = filter.CreateEmptyODBLayer("component_bot_shapes", step.Name); if (clearLayer) { foreach (IODBObject o in layerbotPins.GetAllLayerObjects()) { layerbotPins.RemoveObject(o); } } } // Pins foreach (ICMPObject cmp in step.GetAllCMPObjects()) { foreach (IPin pin in cmp.GetPinList()) { IODBObject outlinePolygon = null; if (cmp.PlacedTop) { outlinePolygon = filter.CreatePolygon(layerTopPins); } else { outlinePolygon = filter.CreatePolygon(layerbotPins); } ISurfaceSpecifics specOutline = (ISurfaceSpecifics)outlinePolygon.GetSpecifics(); bool polyStart = true; PointF StartPoint = new PointF(0, 0); PointF EndPoint = new PointF(0, 0); foreach (IEdge edge in pin.GetPolygonOutline(cmp).GetEdges()) { if (polyStart) { polyStart = false; StartPoint = new PointF((float)edge.Begin.X, (float)edge.Begin.Y); specOutline.StartPolygon(false, StartPoint); if (edge is IArcEdge) { IArcEdge aEdge = (IArcEdge)edge; PointF start = new PointF((float)aEdge.Begin.X, (float)aEdge.Begin.Y); PointF end = new PointF((float)aEdge.End.X, (float)aEdge.End.Y); PointF center = new PointF((float)aEdge.Center.X, (float)aEdge.Center.Y); specOutline.AddArc(start, end, center, aEdge.ClockWise); if (aEdge.ClockWise) { EndPoint = end; } else { EndPoint = start; } } else if (edge is ILineEdge) { ILineEdge aEdge = (ILineEdge)edge; PointF start = new PointF((float)aEdge.Begin.X, (float)aEdge.Begin.Y); PointF end = new PointF((float)aEdge.End.X, (float)aEdge.End.Y); specOutline.AddLine(start, end); EndPoint = end; } } else if (edge is IArcEdge) { IArcEdge aEdge = (IArcEdge)edge; PointF start = new PointF((float)aEdge.Begin.X, (float)aEdge.Begin.Y); PointF end = new PointF((float)aEdge.End.X, (float)aEdge.End.Y); PointF center = new PointF((float)aEdge.Center.X, (float)aEdge.Center.Y); specOutline.AddArc(start, end, center, aEdge.ClockWise); if (aEdge.ClockWise) { EndPoint = end; } else { EndPoint = start; } } else if (edge is ILineEdge) { ILineEdge aEdge = (ILineEdge)edge; PointF start = new PointF((float)aEdge.Begin.X, (float)aEdge.Begin.Y); PointF end = new PointF((float)aEdge.End.X, (float)aEdge.End.Y); specOutline.AddLine(start, end); EndPoint = end; } } specOutline.EndPolygon(); //close the new contour outlinePolygon.SetSpecifics(specOutline); outlinePolygon.ObjectColor = Color.Blue; } } layerbotPins.EnableLayer(true); layerTopPins.EnableLayer(true); parent.UpdateView(); parent.UpdateControlsAndResetView(); }
internal bool checkPinLaysOverHole(IStep step, List <IODBObject> listOfAllDrillObjects, out List <ThtPin> topTHTPinList, out List <ThtPin> botTHTPinList, IMatrix matrix) { // this method tries to find THT components and return a list with these components topTHTPinList = new List <ThtPin>(); botTHTPinList = new List <ThtPin>(); List <ThtPin> topTemporaryTHTPinList = new List <ThtPin>(); // thats a list of the ThtPin class of the Top component pins that are relevant to be checked List <ThtPin> botTemporaryTHTPinList = new List <ThtPin>(); // thats a list of the ThtPin class of the Bot component pins that are relevant to be checked if (step == null) { MessageBox.Show("No job loaded!"); return(false); } else { List <ICMPObject> allComponents = step.GetAllCMPObjects(); // thats how you get all components and filling a list with it try { foreach (ICMPObject cmpObj in allComponents) // now iterating through the list with all components { List <IPin> pinList = cmpObj.GetPinList(); // now creating a list with all of pins of the currently checked component of the foreach loop which is iterating components if (pinList.Count == 1) { continue; } //TODO Sollte wegen Fiducials geändert werden wenn benötigt foreach (IPin pin in pinList) { int counterTop = 0; int counterBot = 0; IPolyClass pinPoly = pin.GetPolygonOutline(cmpObj); // this method is creating a new polygon of the polygon outline of the checked component RectangleD pinRect = pin.GetBoundsD(cmpObj); // creating a new rectangle by getting the bounds of the current checked component foreach (IODBObject holeObj in listOfAllDrillObjects) // finally the list with all relevant holes is going be checked { if (!pinRect.IntersectsWith(holeObj.GetBoundsD())) { continue; // first the pins rectangle is checked if it is intersecting with a hole. If this condition is true this pin can not be a THT component pin } IPolyClass holePoly = holeObj.GetPolygonOutline(); if (holePoly.DoesIntersect(pinPoly) || holePoly.IsPointOfSecondObjectIncluded(pinPoly) || pinPoly.IsPointOfSecondObjectIncluded(holePoly)) // this condition is a further check if this pin could be a THT component pin { RectangleD holeRect = holePoly.GetBounds(); //additional checks can be implemented here double pinRectArea = pinRect.GetArea(); double holeRectArea = holeRect.GetArea(); if (holeRectArea <= pinRectArea) // if the hole area is to small this loop iteration will be skipped { continue; } else { if (cmpObj.PlacedTop == true) // placed on the top component layer { counterTop++; // this variable is counting how many holes are below the current checked pin topTemporaryTHTPinList.Add(new ThtPin(cmpObj, pin, holeObj, holePoly)); // add the current component to a temporary list. } else { counterBot++; // this variable is counting how many holes are below the current checked pin botTemporaryTHTPinList.Add(new ThtPin(cmpObj, pin, holeObj, holePoly)); // add the current component to a temporary list. } } } else { continue; } } if (counterTop == 1 && pinList.Count == 1) // for the top THT components { // if the component, which has been added to the temporary list before, do has only one hole (counterTop == 1) below one pin // do not add to list // and the component do only posses one pin, this component can't be a THT component. } else { topTHTPinList.AddRange(topTemporaryTHTPinList); // else the temporary list can be added to the permanent list topTemporaryTHTPinList.Clear(); } if (counterBot == 1 && pinList.Count == 1) { } // for the bot THT components else { botTHTPinList.AddRange(botTemporaryTHTPinList); botTemporaryTHTPinList.Clear(); } } } return(true); } catch (Exception ex) // if something goes wrong and a exception have to be catched { PCB_Investigator.Localization.PCBILocalization.ShowMsgBox(ex.Message, "Error in checkPinLaysOverHole method", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } }
private void parFile(IPCBIWindow parent, ref string strFileName, IStep step, ref List <string> errorLogFile) { List <ICMPObject> lstAllCMPList = step.GetAllCMPObjects(); Dictionary <string, string> dictMacros = new Dictionary <string, string>(); // you can add and remove dictMacros.Add entries, these entries are used for naming a CMP-Macro correctly List <string> dataList = new List <string>(); dictMacros.Add("c", "$CAPACITOR"); // the first part of the entry, here "c", is the starting character of the reference string on which it is compared dictMacros.Add("c_", "$CAPACITOR"); // the second part of the entry, here "$CAPACITATOR", is the new macroentry dictMacros.Add("d", "$DIODE"); dictMacros.Add("fd", "$FIDUCIAL"); dictMacros.Add("jp", "$JUMPER"); dictMacros.Add("l", "$INDUCTANCE"); dictMacros.Add("l_", "$INDUCTANCE"); dictMacros.Add("ofix", "$OPENFIX"); dictMacros.Add("pos", "$MOVEPROBE"); dictMacros.Add("probe", "$IMPCHECK"); dictMacros.Add("r", "$RESISTOR"); // some Macros are missing: //$CONNECTOR, $FUSE, $CAPACITOR, $LED, $TRANSISTOR, //$MOSFET, $TRANSFORMER, $RELAIS, $ZENER, $DIGITAL, $CLOCK, $OPTOISOLATOR, $VOLTAGEREGULATOR // please add more or remove some if necessary on your own. char chrTabSpace = '\t'; // There must be a tab between the columns to ensure that the columns are also separated for the machine. strFileName = FileSaveDialog(parent); int iMaxCMPName, iMaxPackName; iMaxCMPName = 0; iMaxPackName = 0; // to get the maximum name length if (lstAllCMPList.Count > 0) { foreach (ICMPObject cmp in lstAllCMPList) { if (iMaxCMPName < cmp.PartName.Length) { iMaxCMPName = cmp.PartName.Length; } if (iMaxPackName < cmp.UsedPackageName.Length) { iMaxPackName = cmp.UsedPackageName.Length; } } } else { MessageBox.Show("No componentens could be found"); return; } iMaxCMPName = iMaxCMPName + 5; iMaxPackName = iMaxPackName + 5; if (string.IsNullOrEmpty(strFileName)) { MessageBox.Show("Files could not be exported because of an error. Please try it again.", "Error occured", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } dataList.Add("* COMPONENT".PadRight(iMaxCMPName, chrTabSpace) + " DEVICE".PadRight(iMaxPackName, chrTabSpace) + "VALUE".PadRight(15, chrTabSpace) + "UNIT".PadRight(15, chrTabSpace) + "TOL+".PadRight(15, chrTabSpace) + "TOL-".PadRight(15, chrTabSpace) + "NRPIN".PadRight(15, chrTabSpace) + "MACRO"); dataList.Add("* "); string makroName = string.Empty; string cmpRefName = string.Empty; string cmpUsedPckName = string.Empty; foreach (ICMPObject cmp in lstAllCMPList) { if (dictMacros != null) { makroName = string.Empty; foreach (var item in dictMacros) { if (cmp.Ref.ToLowerInvariant().StartsWith(item.Key)) { makroName = item.Value; break; } } } if (string.IsNullOrEmpty(makroName)) { makroName = ""; } cmpRefName = '"' + cmp.Ref + '"'; cmpUsedPckName = '"' + cmp.UsedPackageName + '"'; dataList.Add(cmpRefName.PadRight(iMaxCMPName, chrTabSpace) + cmpUsedPckName.PadRight(iMaxPackName, chrTabSpace) + "0".PadRight(15, chrTabSpace) + "0".PadRight(15, chrTabSpace) + "0".PadRight(15, chrTabSpace) + "0".PadRight(15, chrTabSpace) + "0".PadRight(15, chrTabSpace) + makroName); } writeToFile(strFileName, dataList); }
public void Execute(IPCBIWindow parent) { //set options here: bool onlySelectedComponent = true; bool CalculateTopSide = true; bool CalculateBotSide = true; double TopArea = 0; double BotArea = 0; IStep step = parent.GetCurrentStep(); if (step == null) { return; //no project loaded } List <ICMPObject> allCMPs = step.GetAllCMPObjects(); foreach (ICMPObject cmp in allCMPs) { if (onlySelectedComponent && !cmp.IsSelected) { continue; } PCBI.MathUtils.IPolyClass polygonOfCMP = cmp.GetPolygonOutline(); foreach (PCBI.MathUtils.IEdge edge in polygonOfCMP.GetEdges()) { if (!CalculateTopSide && cmp.PlacedTop) { continue; } if (!CalculateBotSide && !cmp.PlacedTop) { continue; } //work with integrals to calculate the area double extent = 0; if (edge.Type == IEdgeType.Line) { extent = PCBI.MathUtils.IMath.DistancePointToPoint(edge.Begin, edge.End); } else { // Pi * R * winkel /180 double angle = PCBI.MathUtils.IMath.GetAngle(edge.Begin, edge.End, ((PCBI.MathUtils.IArcEdge)edge).Center, ((PCBI.MathUtils.IArcEdge)edge).ClockWise); double radius = PCBI.MathUtils.IMath.DistancePointToPoint(edge.Begin, ((PCBI.MathUtils.IArcEdge)edge).Center); extent = Math.PI * radius * angle / 180; } if (cmp.PlacedTop) { TopArea += extent * cmp.CompHEIGHT; } else { BotArea += extent * cmp.CompHEIGHT; } } } double areaPCB = step.CalculateBoardArea(); if (parent.GetUnit()) //change mils? to cm? { areaPCB = areaPCB / 155000.31; //(1/2.54*2.54) TopArea = TopArea / 155000.31; BotArea = BotArea / 155000.31; } System.Windows.Forms.MessageBox.Show((onlySelectedComponent ? "Selected Component side walls:" : "All side walls of Components:") + Environment.NewLine + (CalculateTopSide ? "Top Side Components: " + TopArea + Environment.NewLine : "") + (CalculateBotSide ? "Bot Side Components: " + BotArea + Environment.NewLine : "") + ((!CalculateBotSide && !CalculateTopSide) ? "No Elements allowed, please run check with other parameters!" : "") + Environment.NewLine + "Board Area " + areaPCB + (parent.GetUnit() ? " cm?":" mils?") , "Result", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); }