private void SetToGrid(float grid, IPCBIWindow parent) { IStep step = parent.GetCurrentStep(); foreach (IODBObject obj in step.GetSelectedElements()) { IObjectSpecifics obs = obj.GetSpecifics(); if (obs.GetType() == typeof(ILineSpecifics)) { ILineSpecifics lines = (ILineSpecifics)obs; lines.Start.X = correction(lines.Start.X, grid); lines.Start.Y = correction(lines.Start.Y, grid); lines.End.X = correction(lines.End.X, grid); lines.End.Y = correction(lines.End.Y, grid); obj.SetSpecifics(lines); } else if (obs.GetType() == typeof(IPadSpecifics)) { IPadSpecifics pads = (IPadSpecifics)obs; pads.Location.X = correction(pads.Location.X, grid); pads.Location.Y = correction(pads.Location.Y, grid); obj.SetSpecifics(pads); } } }
public void Execute(IPCBIWindow parent) { //your code here int count = 0; IStep step = parent.GetCurrentStep(); IODBLayer outsideToplayer = step.GetOutsideODBLayer(true); IODBLayer outsideBotlayer = step.GetOutsideODBLayer(false); if (step.GetCMPLayer(true) != null) { step.GetCMPLayer(true).EnableLayer(true); foreach (ICMPObject cmp in step.GetCMPLayer(true).GetAllLayerObjects()) { foreach (IPin pin in cmp.GetPinList()) { IODBObject po = pin.GetIPinPad(outsideToplayer, cmp); if (po != null) { IPadSpecifics os = (IPadSpecifics)po.GetSpecifics(); if (os.Type == PCBI.Symbol_Type.r) { cmp.ObjectColor = Color.Red; cmp.AddComponentAttribute("techno", "thr"); count++; break; } } } } } if (step.GetCMPLayer(false) != null) { step.GetCMPLayer(false).EnableLayer(true); foreach (ICMPObject cmp in step.GetCMPLayer(false).GetAllLayerObjects()) { foreach (IPin pin in cmp.GetPinList()) { IODBObject po = pin.GetIPinPad(outsideBotlayer, cmp); if (po != null) { IPadSpecifics os = (IPadSpecifics)po.GetSpecifics(); if (os.Type == PCBI.Symbol_Type.r) { cmp.ObjectColor = Color.Blue; cmp.AddComponentAttribute("techno", "thr"); count++; break; } } } } } parent.UpdateView(); }
private static void AddDrillObjects(IFilter filter, ILayer drill_layer, MatrixLayerType type, IODBLayer odb_sig_layer) { Dictionary <int, int> symbolUsed = new Dictionary <int, int>(); foreach (IODBObject obj in drill_layer.GetAllLayerObjects()) { #region one drill layer obj.Select(true); if (obj.Type == IObjectType.Pad) { IPadSpecifics ops = (IPadSpecifics)obj.GetSpecifics(); if (type != MatrixLayerType.Dielectric) { ops.Positive = false; } else { ops.Positive = true; } if (!symbolUsed.ContainsKey(ops.ShapeIndex)) { int index = IFilter.AddToolFromODBString(odb_sig_layer, ops.ODBSymbol_String); symbolUsed.Add(ops.ShapeIndex, index); } ops.ShapeIndex = symbolUsed[ops.ShapeIndex]; IODBObject pad = filter.CreatePad(odb_sig_layer); pad.SetSpecifics(ops); } else if (obj.Type == IObjectType.Line) { ILineSpecifics ops = (ILineSpecifics)obj.GetSpecifics(); if (type != MatrixLayerType.Dielectric) { ops.Positive = false; } else { ops.Positive = true; } if (!symbolUsed.ContainsKey(ops.ShapeIndex)) { int index = IFilter.AddToolFromODBString(odb_sig_layer, ops.ODBSymbol_String); symbolUsed.Add(ops.ShapeIndex, index); } ops.ShapeIndex = symbolUsed[ops.ShapeIndex]; IODBObject line = filter.CreateLine(odb_sig_layer); line.SetSpecifics(ops); } #endregion } }
void MarkAllSMDPadsOnLayer(IODBLayer layer, List <string> allRelevantDrills, IStep step) { if (layer == null || allRelevantDrills.Count == 0) { return; } Dictionary <string, IODBLayer> drills = new Dictionary <string, IODBLayer>(); //look for all pads if there is a drill inside? foreach (IODBObject maybePad in layer.GetAllLayerObjects()) { if (maybePad.Type != IObjectType.Pad || maybePad.ObjectColor == MarkerColor) { continue; } Dictionary <PCBI.FeatureAttributeEnum, string> attribs = maybePad.GetAttributesDictionary(); if (attribs.ContainsKey(PCBI.FeatureAttributeEnum.smd)) //check for smd attribute { //check for drills IPadSpecifics pad = (IPadSpecifics)maybePad.GetSpecifics(); if (pad.Type == PCBI.Symbol_Type.r) { continue; //no round pads } foreach (string drillname in allRelevantDrills) { if (!drills.ContainsKey(drillname)) { drills.Add(drillname, (IODBLayer)step.GetLayer(drillname)); } List <IObject> relevantDrills = drills[drillname].GetAllObjectInRectangle(maybePad.GetBounds()); foreach (IODBObject drill in relevantDrills) { if (maybePad.Bounds.Contains(drill.Bounds)) //simple check with bounds inside { maybePad.ObjectColor = MarkerColor; break; } } if (!maybePad.ObjectColor.IsEmpty) //if color -> found and break { break; } } } } }
public void Report_Via_Pad() { dynamic wordApp = Activator.CreateInstance(Type.GetTypeFromProgID("Word.Application")); wordApp.Visible = true; dynamic wordDoc = wordApp.Documents.Add(); ////// StringBuilder sb = new StringBuilder(); IStep step = Parent.GetCurrentStep(); IMatrix m = Parent.GetMatrix(); foreach (INet NetList in step.GetNets()) { foreach (IODBObject obj in NetList.GetAllNetObjects(Parent)) { if (m.GetMatrixLayerType(obj.GetParentLayerName()) == MatrixLayerType.Drill) { if (obj.Type == IObjectType.Pad) { IPadSpecifics ps = (IPadSpecifics)obj.GetSpecifics(); float x = ps.Location.X; float Y = ps.Location.Y; sb.Append("Via;" + obj.NetName + ";" + x.ToString("N3") + ";" + Y.ToString("N3") + Environment.NewLine); } } } } ////// string LVText = "Type\tNetName\tposx\tposy" + 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) { if (parent == null) { return; } TextType tt = TextType.angle; ShowInputDialog(ref tt); // MessageBox.Show( tt.ToString()); IMatrix m = parent.GetMatrix(); IStep step = parent.GetCurrentStep(); if (tt == TextType.angle) { foreach (string layerName in m.GetAllSignalLayerNames()) { IODBLayer layer = (IODBLayer)step.GetLayer(layerName); foreach (IODBObject obj in layer.GetAllLayerObjects()) { IObjectSpecifics os = obj.GetSpecifics(); if (os.GetType() == typeof(ILineSpecifics)) { ILineSpecifics lineEdges = (ILineSpecifics)os; double angle = PCBI.MathUtils.IMath.GetAngle(PCBI.MathUtils.PointD.FromPointF(lineEdges.Start), PCBI.MathUtils.PointD.FromPointF(lineEdges.End)); obj.FreeText = "? " + angle.ToString(); } if (os.GetType() == typeof(IPadSpecifics)) { IPadSpecifics PAD = (IPadSpecifics)os; double angle = PAD.Rotation; obj.FreeText = "? " + angle.ToString(); } } } } if (tt == TextType.lenght) { foreach (string layerName in m.GetAllSignalLayerNames()) { IODBLayer layer = (IODBLayer)step.GetLayer(layerName); foreach (IODBObject obj in layer.GetAllLayerObjects()) { IObjectSpecifics os = obj.GetSpecifics(); if (os.GetType() == typeof(ILineSpecifics)) { ILineSpecifics lineEdges = (ILineSpecifics)os; double length = PCBI.MathUtils.IMath.DistancePointToPoint(PCBI.MathUtils.PointD.FromPointF(lineEdges.Start), PCBI.MathUtils.PointD.FromPointF(lineEdges.End)) / 100; if (parent.GetUnit()) { length *= 2.54f; } length = Math.Round(length, 2); obj.FreeText = "L: " + length.ToString(); } if (os.GetType() == typeof(IPadSpecifics)) { IPadSpecifics PAD = (IPadSpecifics)os; RectangleF bounds = obj.GetBounds(); double w = bounds.Width / 100; double h = bounds.Height / 100; if (parent.GetUnit()) { w *= 2.54f; h *= 2.54f; } w = Math.Round(w, 2); h = Math.Round(h, 2); obj.FreeText = "w: " + w.ToString() + " h: " + h.ToString(); } } } } if (tt == TextType.ViaCount) { foreach (INet NetList in step.GetNets()) { int drillCount = 0; foreach (IODBObject obj in NetList.GetAllNetObjects(parent)) { if (m.GetMatrixLayerType(obj.GetParentLayerName()) == MatrixLayerType.Drill) { drillCount++; } } foreach (IODBObject obj in NetList.GetAllNetObjects(parent)) { obj.FreeText = "DrillCount: " + drillCount.ToString(); } } } if (tt == TextType.NetOnLayer) { foreach (INet NetList in step.GetNets()) { string LNames = ""; foreach (string LayerNames in NetList.GetAllUsedLayers(step)) { if (m.GetMatrixLayerType(LayerNames) == MatrixLayerType.Signal) { LNames += LayerNames + "; "; } } foreach (IODBObject obj in NetList.GetAllNetObjects(parent)) { obj.FreeText = "layer: " + LNames; } } } if (tt == TextType.NetLength) { foreach (INet NetList in step.GetNets()) { double length = CalculateNetLenth(NetList.GetAllNetObjects(parent)) / 100; if (parent.GetUnit()) { length *= 2.54f; } foreach (IODBObject obj in NetList.GetAllNetObjects(parent)) { obj.FreeText = "Netlength: " + Math.Round(length, 2); } } } parent.ShowFreeTextInfoOnAllLayer = true; parent.UpdateView(); }
public void Report_Via_Pad() { var excelType = Type.GetTypeFromProgID("Excel.Application"); dynamic excel = Activator.CreateInstance(excelType); excel.Visible = true; excel.Workbooks.Add(); ////// StringBuilder sb = new StringBuilder(); IStep step = Parent.GetCurrentStep(); IMatrix m = Parent.GetMatrix(); foreach (INet NetList in step.GetNets()) { foreach (IODBObject obj in NetList.GetAllNetObjects(Parent)) { if (m.GetMatrixLayerType(obj.GetParentLayerName()) == MatrixLayerType.Drill) { if (obj.Type == IObjectType.Pad) { IPadSpecifics ps = (IPadSpecifics)obj.GetSpecifics(); float x = ps.Location.X; float Y = ps.Location.Y; if (Parent.GetUnit()) { float unit = 25.4f / 1000; x = x * unit; Y = Y * unit; } sb.Append("Via;" + obj.NetName + ";" + x.ToString("N3") + ";" + Y.ToString("N3") + Environment.NewLine); } } else if (obj.GetParentLayerName().ToLower() == m.GetTopSignalLayer().ToLower()) { if (obj.Type == IObjectType.Pad) { IPadSpecifics ps = (IPadSpecifics)obj.GetSpecifics(); if (ps.Type != PCBI.Symbol_Type.r) { float x = ps.Location.X; float Y = ps.Location.Y; if (Parent.GetUnit()) { float unit = 25.4f / 1000; x = x * unit; Y = Y * unit; } sb.Append("PAD_top;" + obj.NetName + ";" + x.ToString("N3") + ";" + Y.ToString("N3") + Environment.NewLine); } } } else if (obj.GetParentLayerName().ToLower() == m.GetBotSignalLayer().ToLower()) { if (obj.Type == IObjectType.Pad) { IPadSpecifics ps = (IPadSpecifics)obj.GetSpecifics(); if (ps.Type != PCBI.Symbol_Type.r) { float x = ps.Location.X; float Y = ps.Location.Y; if (Parent.GetUnit()) { float unit = 25.4f / 1000; x = x * unit; Y = Y * unit; } sb.Append("PAD_bot;" + obj.NetName + ";" + x.ToString("N3") + ";" + Y.ToString("N3") + Environment.NewLine); } } } } } ////// //string LVText = "Type\tNetName\tposx\tposy" + Environment.NewLine + sb.ToString(); string LVText = "Type;NetName;posx;posy" + Environment.NewLine + sb.ToString(); string LVCsv = sb.ToString(); DataObject LVDataObject = new DataObject(); LVDataObject.SetData(DataFormats.Text, false, LVText); LVDataObject.SetData(DataFormats.CommaSeparatedValue, false, LVCsv); Clipboard.SetDataObject(LVDataObject, true); excel.ActiveSheet.Paste(); //release the object System.Runtime.InteropServices.Marshal.ReleaseComObject(excel); }
public void Execute(IPCBIWindow parent) { //your code here if (parent == null) { return; } System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo(); nfi.NumberDecimalSeparator = "."; nfi.NumberGroupSeparator = ""; IStep step = parent.GetCurrentStep(); IFilter filter = new IFilter(parent); StringBuilder sb = new StringBuilder(); IMatrix m = parent.GetMatrix(); List <int> netnumbers = step.GetAllNetNrs(); Dictionary <int, List <PCBIObject> > allNetNrsWithItems = PCBI.Automation.NetCreation.NetCreator.CreateGlobalNet(step, m, true); foreach (int netlist in allNetNrsWithItems.Keys) { foreach (PCBIObject oObject in allNetNrsWithItems[netlist]) { oObject.iObj.PcbNetNumber = oObject.NetNrGlobal; } } List <string> names = step.GetAllLayerNames(); foreach (string layername in names) { if (step.GetLayer(layername).GetType() == typeof(IODBLayer)) { IODBLayer layer = (IODBLayer)step.GetLayer(layername); if (m.GetMatrixLayerType(layername) == MatrixLayerType.Signal || m.GetMatrixLayerType(layername) == MatrixLayerType.Rout || m.GetMatrixLayerType(layername) == MatrixLayerType.Drill || m.GetMatrixLayerType(layername) == MatrixLayerType.Mask) { foreach (IODBObject obj in layer.GetAllLayerObjects()) { int PCB_NetNum = obj.PcbNetNumber; int LayerNetNum = obj.LayerNetNumber; obj.FreeText = PCB_NetNum.ToString(); //sb.Append("P: " + PCB_NetNum.ToString() + "L: " + LayerNetNum.ToString() + Environment.NewLine); } } } } sb.Append("P VER IPC D 356" + Environment.NewLine); sb.Append("P IMAGE PRIMARY" + Environment.NewLine); sb.Append("C Created with PCB-Investigator" + Environment.NewLine); sb.Append("P Creation date:" + DateTime.Now.ToShortDateString() + Environment.NewLine); sb.Append("C " + step.Name + " " + parent.GetJobName() + Environment.NewLine); sb.Append("C" + Environment.NewLine); sb.Append("P CUST 0" + Environment.NewLine); #region descriptions // Units of measurement : //SI Metric //CUST 0 or CUST Inches and degrees //CUST 1 Millimeters and degrees //CUST 2 Inches and radians //ALLOWED OPERATION CODES (columns 1-3) //317 Through hole. Alternatively it can represent a feature and through hole at a point. //017 Continuation record that defines a through hole associated with the previous record //367 Non-plated tooling hole //327 Surface mount feature //027 Continuation record that defines a through hole associated with the previous record //099 Test point location of the feature described in the previous record //088 Solder mask clearance of the feature described in the previous record //307 Blind or buried via //309 Image 2 through NNNN offset data //370 In-board resistor, capacitor or inductor //070 Continuation of In-board resistor, capacitor or inductor //378 Conductor segment data //078 Continuation record of conductor segment data //379 Adjacency data record //079 Continuation of adjacency data record //380 On-board resistor, capacitor or inductor //080 Continuation of on-board resistor, capacitor or inductor //389 Board, panel or sub-panel , scoring or other fabrication outline data //089 Continuation of outline data //390 Non-test feature such as fiducials , targets , test status marking location , etc … //090 Reference for high-voltage isolation , impedance and other specified tests //999 End of Job data file #endregion List <string> drillNames = m.GetAllDrillLayerNames(); foreach (string drilName in drillNames) { IODBLayer layer = (IODBLayer)step.GetLayer(drilName); string LayerNumber = m.GetRawIndexByName(layer.LayerName).ToString(); foreach (IODBObject via in layer.GetAllLayerObjects()) { string NetName = via.PcbNetNumber.ToString();; IObjectSpecifics viaSpec = via.GetSpecifics(); if (viaSpec.GetType() == typeof(IPadSpecifics)) { float x = ((IPadSpecifics)viaSpec).Location.X; float y = ((IPadSpecifics)viaSpec).Location.Y; double diameter = ((IPadSpecifics)viaSpec).Diameter; string currentLine = new string(' ', 255); currentLine = currentLine.Insert(0, "317"); currentLine = currentLine.Insert(4, NetName); currentLine = currentLine.Insert(21, "VIA"); currentLine = currentLine.Insert(27, "-"); //currentLine = currentLine.Insert(28, LayerNumber); currentLine = currentLine.Insert(33, "D"); currentLine = currentLine.Insert(34, diameter.ToString("N2", nfi)); currentLine = currentLine.Insert(38, "P "); currentLine = currentLine.Insert(42, "X"); if (Math.Sign(x) == 1) { currentLine = currentLine.Insert(43, "+"); } else { currentLine = currentLine.Insert(43, "-"); } currentLine = currentLine.Insert(44, x.ToString("N2", nfi)); currentLine = currentLine.Insert(50, "Y"); if (Math.Sign(y) == 1) { currentLine = currentLine.Insert(51, "+"); } else { currentLine = currentLine.Insert(51, "-"); } currentLine = currentLine.Insert(52, y.ToString("N2", nfi)); currentLine = currentLine.Insert(58, "X"); currentLine = currentLine.Insert(59, diameter.ToString("N2", nfi)); currentLine = currentLine.Insert(63, "Y"); currentLine = currentLine.Insert(64, diameter.ToString("N2", nfi)); currentLine = currentLine.Insert(73, "S"); currentLine = currentLine.Insert(74, "3"); sb.Append(currentLine + Environment.NewLine); } } } IODBLayer LayerPTop = (IODBLayer)step.GetLayer(m.GetTopSignalLayer()); if (LayerPTop != null) { string LayerNumber = m.GetRawIndexByName(LayerPTop.LayerName).ToString(); foreach (IODBObject padTop in LayerPTop.GetAllLayerObjects()) { string NetName = padTop.PcbNetNumber.ToString();; IObjectSpecifics os = padTop.GetSpecifics(); if (os.GetType() == typeof(IPadSpecifics)) { IPadSpecifics oPad = (IPadSpecifics)os; PointF PadMidPoint = new PointF(padTop.GetBounds().X + padTop.GetBounds().Width / 2, padTop.GetBounds().Y + padTop.GetBounds().Height / 2); string currentLine = new string(' ', 255); currentLine = currentLine.Insert(0, "327"); currentLine = currentLine.Insert(4, NetName); currentLine = currentLine.Insert(21, "PAD"); currentLine = currentLine.Insert(27, " "); currentLine = currentLine.Insert(28, LayerNumber); currentLine = currentLine.Insert(33, "D"); currentLine = currentLine.Insert(34, padTop.GetBounds().Width.ToString("N2", nfi)); currentLine = currentLine.Insert(38, "P "); currentLine = currentLine.Insert(42, "X"); if (Math.Sign(PadMidPoint.X) == 1) { currentLine = currentLine.Insert(43, "+"); } else { currentLine = currentLine.Insert(43, "-"); } currentLine = currentLine.Insert(44, PadMidPoint.X.ToString("N2", nfi)); currentLine = currentLine.Insert(50, "Y"); if (Math.Sign(PadMidPoint.Y) == 1) { currentLine = currentLine.Insert(51, "+"); } else { currentLine = currentLine.Insert(51, "-"); } currentLine = currentLine.Insert(52, PadMidPoint.Y.ToString("N2", nfi)); currentLine = currentLine.Insert(58, "W"); currentLine = currentLine.Insert(59, padTop.GetBounds().Width.ToString("N2", nfi)); currentLine = currentLine.Insert(63, "H"); currentLine = currentLine.Insert(64, padTop.GetBounds().Height.ToString("N2", nfi)); currentLine = currentLine.Insert(73, "S"); currentLine = currentLine.Insert(74, "1"); sb.Append(currentLine + Environment.NewLine); } } } IODBLayer LayerPBot = (IODBLayer)step.GetLayer(m.GetBotSignalLayer()); if (LayerPBot != null) { string LayerNumber = m.GetRawIndexByName(LayerPBot.LayerName).ToString(); foreach (IODBObject padBot in LayerPBot.GetAllLayerObjects()) { string NetName = padBot.PcbNetNumber.ToString();; IObjectSpecifics os = padBot.GetSpecifics(); if (os.GetType() == typeof(IPadSpecifics)) { IPadSpecifics oPad = (IPadSpecifics)os; PointF PadMidPoint = new PointF(padBot.GetBounds().X + padBot.GetBounds().Width / 2, padBot.GetBounds().Y + padBot.GetBounds().Height / 2); string currentLine = new string(' ', 255); currentLine = currentLine.Insert(0, "327"); currentLine = currentLine.Insert(4, NetName); currentLine = currentLine.Insert(21, "PAD"); currentLine = currentLine.Insert(27, " "); currentLine = currentLine.Insert(28, LayerNumber); currentLine = currentLine.Insert(33, "D"); currentLine = currentLine.Insert(34, padBot.GetBounds().Width.ToString("N2", nfi)); currentLine = currentLine.Insert(38, "P "); currentLine = currentLine.Insert(42, "X"); if (Math.Sign(PadMidPoint.X) == 1) { currentLine = currentLine.Insert(43, "+"); } else { currentLine = currentLine.Insert(43, "-"); } currentLine = currentLine.Insert(44, PadMidPoint.X.ToString("N2", nfi)); currentLine = currentLine.Insert(50, "Y"); if (Math.Sign(PadMidPoint.Y) == 1) { currentLine = currentLine.Insert(51, "+"); } else { currentLine = currentLine.Insert(51, "-"); } currentLine = currentLine.Insert(52, PadMidPoint.Y.ToString("N2", nfi)); currentLine = currentLine.Insert(58, "W"); currentLine = currentLine.Insert(59, padBot.GetBounds().Width.ToString("N2", nfi)); currentLine = currentLine.Insert(63, "H"); currentLine = currentLine.Insert(64, padBot.GetBounds().Height.ToString("N2", nfi)); currentLine = currentLine.Insert(73, "S"); currentLine = currentLine.Insert(74, "1"); sb.Append(currentLine + Environment.NewLine); } } } sb.Append("999" + Environment.NewLine); // End of File string text = sb.ToString(); Directory.CreateDirectory(parent.GetODBJobDirectory() + "\\user\\"); FileStream fs = new FileStream(parent.GetODBJobDirectory() + "\\user\\IPC356.txt", FileMode.OpenOrCreate); StreamWriter sr = new StreamWriter(fs, Encoding.UTF8); fs.SetLength(0); sr.WriteLine(text); sr.Close(); fs.Close(); parent.UpdateView(); }