internal List <IODBObject> creatingDrillList(IMatrix matrix, IStep step) // that method is used for finding all drillobjects which are plated and not SBU-drills { if (step == null) // A job has to be loaded first { PCB_Investigator.Localization.PCBILocalization.ShowMsgBox("No job loaded.", "Info", MessageBoxButtons.YesNo, MessageBoxIcon.Information); return(null); } List <IODBObject> listOfAllDrillObjects = new List <IODBObject>(); foreach (string drillLayerName in matrix.GetAllDrillLayerNames(true)) // iterates through all drill layers { if (!matrix.IsSBUDrill(drillLayerName)) // if drill layer not a sbu drill layer(sequentiell build up layer), that means only layer with drills that are drilled through the whole board are accepted { ILayer drillLayer = step.GetLayer(drillLayerName); if (drillLayer != null) { foreach (IODBObject drill in drillLayer.GetAllLayerObjects()) { Dictionary <PCBI.FeatureAttributeEnum, string> attribs = drill.GetAttributesDictionary(); if (attribs.ContainsKey(PCBI.FeatureAttributeEnum.drill) && attribs[PCBI.FeatureAttributeEnum.drill] == "non_plated") // if the dictionary of all drill attributes contains that it is a drill and has to be non plated { // then this foreach loopstep can be skipped continue; } listOfAllDrillObjects.Add(drill); // else that drill has to be added to the relevant drills } } } } return(listOfAllDrillObjects); // return the list with all important drills }
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 } }
private void CopyAllViasToNewLayer(IPCBIWindow parent, string layerName, string newLayerName) { IStep curStep = parent.GetCurrentStep(); if (curStep == null) { MessageBox.Show("No Job loaded, please load a job before start this script!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } ILayer relevantLayer = curStep.GetLayer(layerName); ILayer NewLayer = curStep.GetLayer(newLayerName); if (NewLayer == null || relevantLayer == null || !(NewLayer is IODBLayer)) { MessageBox.Show("Check Layers, something is wrong!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } List <IODBObject> ViaList = new List <IODBObject>(); //check all elements for via attribute foreach (IObject obj in relevantLayer.GetAllLayerObjects()) { if (obj is IODBObject) { if (((IODBObject)obj).Type == IObjectType.Pad) { Dictionary <PCBI.FeatureAttributeEnum, string> attributesOfPad = ((IODBObject)obj).GetAttributesDictionary(); if (attributesOfPad.ContainsKey(PCBI.FeatureAttributeEnum.pad_usage)) { if (attributesOfPad[PCBI.FeatureAttributeEnum.pad_usage] == "via") { ViaList.Add((IODBObject)obj); } } } } } IFilter filter = new IFilter(parent); //to create copies on new layer //add vias to new layer foreach (IODBObject viaPad in ViaList) { IPadSpecificsD padInfo = (IPadSpecificsD)viaPad.GetSpecificsD(); int toolNr = IFilter.AddToolDefinitionRound((IODBLayer)NewLayer, (float)padInfo.Diameter, -1); IODBObject newViaPad = filter.CreatePad((IODBLayer)NewLayer); newViaPad.SetSpecifics(padInfo, toolNr); newViaPad.SetAttribute("pad_usage=via"); } }
public void Execute(IPCBIWindow parent) { //this script replace mini arcs by lines try { IStep step = parent.GetCurrentStep(); if (step == null) { return; } double minLenghtArcToReplaceByLine = IMath.MM2Mils(0.02); //20?m maximum for arcs IFilter objectCreator = new IFilter(parent); foreach (string layerName in step.GetAllLayerNames()) //check all layer { ILayer gerberLayer = step.GetLayer(layerName); if (gerberLayer == null) { continue; } if (gerberLayer is ICMPLayer) { continue; //should not be for gerberlayers } if (gerberLayer is IPictureLayer) { continue; //should not be for gerberlayers } //gerber layers always contain IODBObjects foreach (IODBObject obj in gerberLayer.GetAllLayerObjects()) { if (obj.Type == IObjectType.Arc) { #region one arc IArcSpecificsD arc = (IArcSpecificsD)obj.GetSpecificsD(); double radius = IMath.DistancePointToPoint(arc.Start, arc.Center); double angle = IMath.GetAngle(arc.Start, arc.End, arc.Center, arc.ClockWise); //always >=0 if (angle > 0) //ODB++ spec define arcs with Start == End as full circles (angle = 0 in this calculation) { double bogen = 2 * Math.PI * radius * angle / 360; if (bogen < minLenghtArcToReplaceByLine && arc.PenWidth > bogen)//simple condition to identify mini arcs { //replace by line IODBObject lineObj = objectCreator.CreateLine((IODBLayer)gerberLayer); //we know it's a gerber layer -> it must be a IODBLayer lineObj.SetSpecifics(new ILineSpecificsD() { Start = arc.Start, End = arc.End, ShapeIndex = arc.ShapeIndex, Positive = arc.Positive }); if (!obj.ReplaceItemBy(lineObj)) //replace it { Console.WriteLine("Could not replace item!"); } } } #endregion } } } } catch (Exception ex) { Console.WriteLine("Error! " + ex.ToString()); } parent.UpdateView(); //to show the replaced elements }
internal void doWork(IPCBIWindow parent, bool splitRoutItem, bool activateNewLayer) { IStep step = parent.GetCurrentStep(); IMatrix matrix = parent.GetMatrix(); IFilter filter = new IFilter(parent); //if true the new layer need to be activated activateNewCreatedLayer = activateNewLayer; //sets the bool if rout should be used withRout = splitRoutItem; foreach (string currLayerName in matrix.GetAllDrillLayerNames()) { Dictionary <string, List <IODBObject> > allNewLayerDict = new Dictionary <string, List <IODBObject> >(); drill_ = new List <IODBObject>(); drillPlatedNormal = new List <IODBObject>(); drillNonPlatedNormal = new List <IODBObject>(); drillViaNormal = new List <IODBObject>(); drillRout = new List <IODBObject>(); drillPlatedRout = new List <IODBObject>(); drillNonPlatedRout = new List <IODBObject>(); drillViaRout = new List <IODBObject>(); noAttributesPadsLayerNameCreated = false; noAttributesNotPadsLayerNameCreated = false; platedLayerNameCreatedRout = false; nonPlatedLayerNameCreatedRout = false; viaLayerNameCreatedRout = false; platedLayerNameCreatedNormal = false; nonPlatedLayerNameCreatedNormal = false; viaLayerNameCreatedNormal = false; //only activate layer can be splitted if (activateNewCreatedLayer) { if (!step.GetActiveLayerList().Contains(step.GetLayer(currLayerName))) { continue; } } //checks if the layer is a splitted layer if ((currLayerName.Length > 7 && currLayerName.Substring(currLayerName.Length - 7, 7).Equals("_plated")) || (currLayerName.Length > 4 && currLayerName.Substring(currLayerName.Length - 4, 4).Equals("_via"))) { continue; } //checks if the new layer wasn't already splitted last time foreach (string allOtherLayerName in matrix.GetAllDrillLayerNames()) { if (activateNewCreatedLayer) { string searchedLayerName = currLayerName.ToLower() + "_plated"; if (allOtherLayerName.ToLower().Equals(searchedLayerName)) { step.GetLayer(searchedLayerName).EnableLayer(true); } searchedLayerName = currLayerName.ToLower() + "_non_plated"; if (allOtherLayerName.ToLower().Equals(searchedLayerName)) { step.GetLayer(searchedLayerName).EnableLayer(true); } searchedLayerName = currLayerName.ToLower() + "_via"; if (allOtherLayerName.ToLower().Equals(searchedLayerName)) { step.GetLayer(searchedLayerName).EnableLayer(true); } } if (allOtherLayerName.ToLower().Equals(currLayerName.ToLower() + "_plated") || allOtherLayerName.ToLower().Equals(currLayerName.ToLower() + "_non_plated") || allOtherLayerName.ToLower().Equals(currLayerName.ToLower() + "_via")) { skipLayerWasAlreadySplitted = true; continue; } } //if it was already splitted then skip it if (skipLayerWasAlreadySplitted) { skipLayerWasAlreadySplitted = false; continue; } //checks if layer is a drilllayer if (matrix.GetMatrixLayerType(currLayerName) == MatrixLayerType.Drill) { ILayer lay = step.GetLayer(currLayerName); List <IObject> objects = lay.GetAllLayerObjects(); foreach (IODBObject currObj in objects) { Dictionary <PCBI.FeatureAttributeEnum, string> objDict = currObj.GetAttributesDictionary(); if (objDict.Count != 0) { if (objDict.ContainsKey(PCBI.FeatureAttributeEnum.drill)) { if (currObj.Type == IObjectType.Pad) { #region Rout if (withRout) { if (objDict[PCBI.FeatureAttributeEnum.drill] == "non_plated") { drillNonPlatedNormal.Add(currObj); if (!nonPlatedLayerNameCreatedNormal) { allNewLayerDict.Add(currLayerName + "_non_plated", drillNonPlatedNormal); nonPlatedLayerNameCreatedNormal = true; } } else if (objDict[PCBI.FeatureAttributeEnum.drill] == "plated") { drillPlatedNormal.Add(currObj); if (!platedLayerNameCreatedNormal) { allNewLayerDict.Add(currLayerName + "_plated", drillPlatedNormal); platedLayerNameCreatedNormal = true; } } else if (objDict[PCBI.FeatureAttributeEnum.drill] == "via") { drillViaNormal.Add(currObj); if (!viaLayerNameCreatedNormal) { allNewLayerDict.Add(currLayerName + "_via", drillViaNormal); viaLayerNameCreatedNormal = true; } } else { drill_.Add(currObj); if (!noAttributesPadsLayerNameCreated) { allNewLayerDict.Add(currLayerName + "_", drill_); noAttributesPadsLayerNameCreated = true; } } } #endregion #region Without Rout else { if (objDict[PCBI.FeatureAttributeEnum.drill] == "non_plated") { drillNonPlatedRout.Add(currObj); if (!nonPlatedLayerNameCreatedRout) { allNewLayerDict.Add(currLayerName + "_non_plated_rout", drillNonPlatedRout); nonPlatedLayerNameCreatedRout = true; } } else if (objDict[PCBI.FeatureAttributeEnum.drill] == "plated") { drillPlatedRout.Add(currObj); if (!platedLayerNameCreatedRout) { allNewLayerDict.Add(currLayerName + "_plated_rout", drillPlatedRout); platedLayerNameCreatedRout = true; } } else if (objDict[PCBI.FeatureAttributeEnum.drill] == "via") { drillViaRout.Add(currObj); if (!viaLayerNameCreatedRout) { allNewLayerDict.Add(currLayerName + "_via_rout", drillViaRout); viaLayerNameCreatedRout = true; } } else { drill_.Add(currObj); if (!noAttributesPadsLayerNameCreated) { allNewLayerDict.Add(currLayerName + "_", drill_); noAttributesPadsLayerNameCreated = true; } } } #endregion } else if (withRout) { #region Line-Arcs-Surfaces-Text + Rout if (objDict[PCBI.FeatureAttributeEnum.drill] == "non_plated") { drillNonPlatedRout.Add(currObj); if (!nonPlatedLayerNameCreatedRout) { allNewLayerDict.Add("rout_" + currLayerName + "_non_plated", drillNonPlatedRout); nonPlatedLayerNameCreatedRout = true; } } else if (objDict[PCBI.FeatureAttributeEnum.drill] == "plated") { drillPlatedRout.Add(currObj); if (!platedLayerNameCreatedRout) { allNewLayerDict.Add("rout_" + currLayerName + "_plated", drillPlatedRout); platedLayerNameCreatedRout = true; } } else if (objDict[PCBI.FeatureAttributeEnum.drill] == "via") { drillViaRout.Add(currObj); if (!viaLayerNameCreatedRout) { allNewLayerDict.Add("rout_" + currLayerName + "_via", drillViaRout); viaLayerNameCreatedRout = true; } } else { drillRout.Add(currObj); if (!noAttributesNotPadsLayerNameCreated) { allNewLayerDict.Add("rout_" + currLayerName, drillRout); noAttributesNotPadsLayerNameCreated = true; } } #endregion } } } else { #region No Attributes + Rout if (withRout) { if (currObj.Type == IObjectType.Pad) { drill_.Add(currObj); if (!noAttributesPadsLayerNameCreated) { allNewLayerDict.Add(currLayerName + "_", drill_); noAttributesPadsLayerNameCreated = true; } } else { drillRout.Add(currObj); if (!noAttributesNotPadsLayerNameCreated) { allNewLayerDict.Add("rout_" + currLayerName, drillRout); noAttributesNotPadsLayerNameCreated = true; } } } #endregion #region No Attributes Without Rout else { if (currObj.Type == IObjectType.Pad) { drill_.Add(currObj); if (!noAttributesPadsLayerNameCreated) { allNewLayerDict.Add(currLayerName + "_", drill_); noAttributesPadsLayerNameCreated = true; } } } #endregion } } if (allNewLayerDict.Count > 1) //wenn alle vom gleichen Typ sind muss nicht gesplittet werden! { foreach (string currNewLayerName in allNewLayerDict.Keys) { filter = new IFilter(parent); CreateNewDrillODBLayer(filter, currNewLayerName, parent, allNewLayerDict[currNewLayerName], activateNewCreatedLayer); } } } } matrix.UpdateDataAndList(); }