private void CloseDocument(IServerDocument ArgDocument) { IClient client = DXP.GlobalVars.Client; client.HideDocument(ArgDocument); client.CloseDocument(ArgDocument); }
private void CountPrimitivesOfFootprint() { OpenFileDialog openDialog = InitFileOpenDialog("PCBLIB"); if (openDialog == null) { return; } string[] FootprintFiles = openDialog.FileNames; foreach (string FootprintFile in FootprintFiles) { System.Threading.Thread.Sleep(5000); IServerDocument PcbDocuemnt = OpenDocuemnt(FootprintFile, "PCBLIB"); if (PcbDocuemnt == null) { DXP.Utils.ShowMessage("Failed to open " + FootprintFile); return; } IPCB_ServerInterface PcbServer = PCB.GlobalVars.PCBServer; IPCB_Library PcbLib = PcbServer.GetCurrentPCBLibrary(); IPCB_Board currentBoard = PcbServer.GetCurrentPCBBoard(); currentBoard.GraphicalView_ZoomRedraw(); IPCB_LibraryIterator LibIteartor = PcbLib.LibraryIterator_Create(); LibIteartor.AddFilter_ObjectSet(new PCB.TObjectSet(PCB.TObjectId.eComponentObject)); IPCB_LibComponent PcbCmp = LibIteartor.FirstPCBObject() as IPCB_LibComponent; while (PcbCmp != null) { string FootprintDescription = PcbCmp.GetState_Description(); string FootprintName = PcbCmp.GetState_Pattern(); IPCB_GroupIterator PcbObjItera = PcbCmp.GroupIterator_Create(); int count = 0; IPCB_Primitive PcbObj = PcbObjItera.FirstPCBObject(); while (PcbObj != null) { count++; PcbObj = PcbObjItera.NextPCBObject(); } PcbCmp.GroupIterator_Destroy(ref PcbObjItera); System.IO.File.AppendAllText(@"G:\report.txt", FootprintName + "|" + FootprintDescription + "|" + count.ToString() + "\r\n"); PcbCmp = LibIteartor.NextPCBObject() as IPCB_LibComponent; } PcbLib.LibraryIterator_Destroy(ref LibIteartor); CloseDocument(PcbDocuemnt); } }
private void RemoveSymbolVaultLink() { OpenFileDialog openDialog = InitFileOpenDialog("SCHLIB"); if (openDialog == null) { return; } IClient client = DXP.GlobalVars.Client; string[] SchFiles = openDialog.FileNames; foreach (string SchFile in SchFiles) { IServerDocument SchDocument = client.OpenDocument("SCHLIB", SchFile); if (SchDocument == null) { return; } client.ShowDocumentDontFocus(SchDocument); ISch_ServerInterface SchServer = SCH.GlobalVars.SchServer; ISch_Lib currentLib = SchServer.GetCurrentSchDocument() as ISch_Lib; currentLib.SetState_FolderGUID(""); currentLib.SetState_LifeCycleDefinitionGUID(""); currentLib.SetState_ReleaseVaultGUID(""); currentLib.SetState_RevisionNamingSchemeGUID(""); if (currentLib.LibIsEmpty()) { DXP.Utils.ShowWarning("SCH library is empty"); return; } ISch_Iterator LibIterator = currentLib.SchLibIterator_Create(); LibIterator.AddFilter_ObjectSet(new SCH.TObjectSet(SCH.TObjectId.eSchComponent)); ISch_Component LibCmp = LibIterator.FirstSchObject() as ISch_Component; while (LibCmp != null) { LibCmp.SetState_ComponentDescription(""); LibCmp.SetState_SymbolItemGUID(""); LibCmp.SetState_SymbolRevisionGUID(""); LibCmp.SetState_SymbolVaultGUID(""); LibCmp.SetState_VaultGUID(""); LibCmp = LibIterator.NextSchObject() as ISch_Component; } currentLib.SchIterator_Destroy(ref LibIterator); } }
private bool CheckKindSchLib(IServerDocumentView ArgView) { if (ArgView != null) { IServerDocument OwnerDoucment = ArgView.GetOwnerDocument(); if (!"SCHLIB".Equals(OwnerDoucment.GetKind(), StringComparison.OrdinalIgnoreCase)) { DXP.Utils.ShowWarning("This is not a schmatic library doucment"); return(false); } } return(true); }
/// <summary> /// Generate CSV height report. /// </summary> /// <param name="argHeights">Reference to the dict storing report info.</param> private void GenerateCSV(ref Dictionary <string, Heights> argHeights) { try { DXP.Utils.PercentInit("Generating CSV", argHeights.Count); int i = 4; ArrayList report = new ArrayList(); report.Add("Excel Component Heights Report"); report.Add("========================"); report.Add("Ref,Footprint,Symbol Height (mils),Body Height (mils),Difference (Sym-Body),Library"); foreach (KeyValuePair <string, Heights> item in argHeights) { report.Add(item.Key + "," + item.Value.Footprint + "," + ((item.Value.ParameterHeight < 0) ? "N/A" : item.Value.ParameterHeight.ToString()) + "," + ((item.Value.BodyHeight < 0) ? "N/A" : item.Value.BodyHeight.ToString()) + "," + ("=C" + i + "-D" + i) + "," + item.Value.Library); i++; DXP.Utils.PercentUpdate(); } IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace; IDXPProject CurrentProject = CurrentWorkspace.DM_FocusedProject(); string fileName = CurrentProject.DM_GetOutputPath() + "\\HeightReport.csv"; if (!Directory.Exists(Path.GetDirectoryName(fileName))) { Directory.CreateDirectory(Path.GetDirectoryName(fileName)); } File.WriteAllLines(fileName, (string[])report.ToArray(typeof(string))); IServerDocument reportDocument = DXP.GlobalVars.Client.OpenDocument("Text", fileName); if (reportDocument != null) { CurrentProject.DM_AddGeneratedDocument(fileName); DXP.GlobalVars.Client.ShowDocument(reportDocument); } DXP.Utils.PercentFinish(); } catch (Exception ex) { ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex); return; } }
public void LibraryTest() { //Library testing ArrayList report = new ArrayList(); IIntegratedLibraryManager integratedLibraryManager = EDP.Utils.LoadIntegratedLibraryManager(); int count = integratedLibraryManager.InstalledLibraryCount(); report.Add("Installed Libray Count : " + count); for (int i = 0; i < count; i++) { string libPath = integratedLibraryManager.InstalledLibraryPath(i); int componentCount = integratedLibraryManager.GetComponentCount(libPath); DXP.Utils.PercentInit("Generating Library Report: Library " + i + " of " + count, componentCount); report.Add("============================================="); report.Add("Installed Libray Path : " + libPath); report.Add("Component Count : " + componentCount); for (int j = 0; j < componentCount; j++) { string componentName = integratedLibraryManager.GetComponentName(libPath, j); int paramCount = integratedLibraryManager.GetParameterCount(libPath, j); report.Add(" ------------------------------------"); report.Add(" Component Name : " + componentName); report.Add(" Parameter Count : " + paramCount); //report.Add(" Footprint : " + integratedLibraryManager.GetModelName(libPath, j, 0)); for (int k = 0; k < paramCount; k++) { report.Add(" " + integratedLibraryManager.GetParameterName(libPath, j, k) + " = " + integratedLibraryManager.GetParameterValue(libPath, j, k)); } DXP.Utils.PercentUpdate(); } } string fileName = "C:\\InstalledLibraries.txt"; File.WriteAllLines(fileName, (string[])report.ToArray(typeof(string))); IServerDocument reportDocument = DXP.GlobalVars.Client.OpenDocument("Text", fileName); if (reportDocument != null) { DXP.GlobalVars.Client.ShowDocument(reportDocument); } }
private IServerDocument OpenDocuemnt(string DocumentPath, string DocumentKind) { IClient client = DXP.GlobalVars.Client; try { IServerDocument document = client.OpenDocumentShowOrHide(DocumentKind, DocumentPath, false); client.ShowDocumentDontFocus(document); return(document); } catch (ExternalException e) { //DXP.Utils.ShowMessage(e.Message); return(null); } }
/// <summary> /// Generate text height report. /// </summary> /// <param name="argHeights">Reference to the dict storing report info.</param> private void GenerateReport(ref Dictionary <string, Heights> argHeights) { try {//Generating Report DXP.Utils.PercentInit("Generating Report", argHeights.Count); ArrayList report = new ArrayList(); report.Add("Component Heights Report"); report.Add("========================"); foreach (KeyValuePair <string, Heights> item in argHeights) { report.Add("Component " + item.Key); report.Add(item.Value.ToString()); report.Add(""); DXP.Utils.PercentUpdate(); } IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace; IDXPProject CurrentProject = CurrentWorkspace.DM_FocusedProject(); string fileName = CurrentProject.DM_GetOutputPath() + "\\HeightReport.txt"; File.WriteAllLines(fileName, (string[])report.ToArray(typeof(string))); IServerDocument reportDocument = DXP.GlobalVars.Client.OpenDocument("Text", fileName); if (reportDocument != null) { CurrentProject.DM_AddGeneratedDocument(fileName); DXP.GlobalVars.Client.ShowDocument(reportDocument); } DXP.Utils.PercentFinish(); } catch (Exception ex) { ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex); return; } }
private void CountPinsOfSymbol() { SCH.TObjectSet DontCountObject = new SCH.TObjectSet(SCH.TObjectId.eParameter, SCH.TObjectId.eDesignator); OpenFileDialog openDialog = InitFileOpenDialog("SCHLIB"); if (openDialog == null) { return; } IClient client = DXP.GlobalVars.Client; string[] SymbolFiles = openDialog.FileNames; foreach (string SymbolFile in SymbolFiles) { //IServerDocument SymbolDocument = OpenDocuemnt(SymbolFile, "SCHLIB"); IServerDocument SymbolDocument = client.OpenDocumentShowOrHide("SCHLIB", SymbolFile, false); ISch_ServerInterface SchServer = SCH.GlobalVars.SchServer; ISch_Lib SchLib = SchServer.GetSchDocumentByPath(SymbolFile) as ISch_Lib; //ISch_Lib SchLib = SchServer.GetCurrentSchDocument() as ISch_Lib; ISch_Iterator LibItera = SchLib.SchLibIterator_Create(); LibItera.AddFilter_ObjectSet(new SCH.TObjectSet(SCH.TObjectId.eSchComponent)); ISch_Component LibComp = LibItera.FirstSchObject() as ISch_Component; while (LibComp != null) { string SymbolName = LibComp.GetState_SymbolReference(); ISch_Iterator ObjIterator = LibComp.SchIterator_Create(); ISch_BasicContainer SchObj = ObjIterator.FirstSchObject(); int PinCount = 0; int PrimitiveCount = 0; while (SchObj != null) { bool CountIt = true; foreach (SCH.TObjectId ObjectKind in DontCountObject) { if (ObjectKind == SchObj.GetState_ObjectId()) { CountIt = false; } } if (SchObj.GetState_ObjectId() == SCH.TObjectId.ePin) { PinCount++; } if (CountIt) { PrimitiveCount++; } SchObj = ObjIterator.NextSchObject(); } LibComp.SchIterator_Destroy(ref ObjIterator); System.IO.File.AppendAllText(@"G:\report.txt", SymbolName + "|" + PinCount.ToString() + "|" + PrimitiveCount.ToString() + "\r\n"); LibComp = LibItera.NextSchObject() as ISch_Component; } SchLib.SchIterator_Destroy(ref LibItera); CloseDocument(SymbolDocument); } }
private void CleanUpSamtecSymbols() { OpenFileDialog openDialog = InitFileOpenDialog("SCHLIB"); if (openDialog == null) { return; } IClient client = DXP.GlobalVars.Client; string[] SchFiles = openDialog.FileNames; foreach (string SchFile in SchFiles) { IServerDocument SchDocument = client.OpenDocument("SCHLIB", SchFile); if (SchDocument == null) { return; } client.ShowDocumentDontFocus(SchDocument); ISch_ServerInterface SchServer = SCH.GlobalVars.SchServer; ISch_Lib currentLib = SchServer.GetCurrentSchDocument() as ISch_Lib; if (currentLib.LibIsEmpty()) { DXP.Utils.ShowWarning("SCH library is empty"); return; } ISch_Iterator LibIterator = currentLib.SchLibIterator_Create(); LibIterator.AddFilter_ObjectSet(new SCH.TObjectSet(SCH.TObjectId.eSchComponent)); ISch_Component LibCmp = LibIterator.FirstSchObject() as ISch_Component; while (LibCmp != null) { LibCmp.SetState_ComponentDescription(""); ISch_Iterator ObjIterator = LibCmp.SchIterator_Create(); ISch_BasicContainer SchObj = ObjIterator.FirstSchObject(); while (SchObj != null) { switch (SchObj.GetState_ObjectId()) { case SCH.TObjectId.ePin: CleanUpPin(SchObj as ISch_Pin); break; case SCH.TObjectId.eParameter: RemoveParameter(SchObj as ISch_Parameter, LibCmp); break; case SCH.TObjectId.eImplementation: RemoveLinkedModel(SchObj as ISch_Implementation, LibCmp); break; } SchObj = ObjIterator.NextSchObject(); } LibCmp.SchIterator_Destroy(ref ObjIterator); LibCmp = LibIterator.NextSchObject() as ISch_Component; } currentLib.SchIterator_Destroy(ref LibIterator); } }
/// <summary> /// Outjob medium information. /// </summary> /// <param name="Medium">The outjob that is actually generated</param> /// <param name="Document">The outjob document</param> /// <param name="ODB">True if outjob is and ODB++ medium.</param> public clsOutJob(IOutputMedium Medium, IServerDocument Document, bool ODB) { OutputMedium = Medium; ServerDoc = Document; this.ODB = ODB; }
//Autogenerated code. Commands implementation. Begin public void CommandReleasePartChoices(IServerDocument view, string parameters) { ReleasePartChoices(); }