/// <summary> /// Get the height parameter value from all schematic components. /// </summary> /// <param name="argHeights">Reference to the dict storing report info.</param> void GetParamHeights(ref Dictionary <string, Heights> argHeights) { try { ISch_ServerInterface schServer = SCH.GlobalVars.SchServer; if (schServer == null) { return; } ISch_Document currentSheet = schServer.GetCurrentSchDocument(); SCH.TObjectSet objectSet = new SCH.TObjectSet(); objectSet.Add(SCH.TObjectId.eSchComponent); ISch_Iterator iterator = currentSheet.SchIterator_Create(); iterator.AddFilter_ObjectSet(objectSet); ISch_Component schComponent = iterator.FirstSchObject() as ISch_Component; while (schComponent != null) { ObtainParamHeight(ref argHeights, schComponent); if (argHeights == null) { return; } schComponent = iterator.NextSchObject() as ISch_Component; } return; } catch (Exception ex) { ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex); return; } }
/// <summary> /// Gets height parameter of specified component. /// </summary> /// <param name="argHeights">Reference to the dict storing report info.</param> /// <param name="argComponent">Component to get height from.</param> private void ObtainParamHeight(ref Dictionary <string, Heights> argHeights, ISch_Component argComponent) { try { ISch_Designator designator = argComponent.GetState_SchDesignator(); ISch_Iterator paramIterator = argComponent.SchIterator_Create(); paramIterator.SetState_IterationDepth((int)SCH.TIterationDepth.eIterateAllLevels); SCH.TObjectSet objectSet = new SCH.TObjectSet(); objectSet.Add(SCH.TObjectId.eParameter); paramIterator.AddFilter_ObjectSet(objectSet); if (argComponent.GetState_CurrentPartID() > 1) { return; } //Make sure component is already logged. if (!argHeights.ContainsKey(designator.GetState_Text())) { argHeights.Add(designator.GetState_Text(), new Heights()); } else { argHeights = null; DXP.Utils.ShowWarning("A duplicate refdes detected. Opeartion will stop. Please correct this issue."); return; } argHeights[designator.GetState_Text()].Library = argComponent.GetState_LibraryIdentifier() + "/" + argComponent.GetState_DesignItemId(); //Go through all parameters looking for component height. ISch_Parameter param = paramIterator.FirstSchObject() as ISch_Parameter; while (param != null) { if (param.GetState_Name() == "ComponentHeight") { if (param.GetState_Text() == null) { argComponent.SchIterator_Destroy(ref paramIterator); return; } int height; if (Int32.TryParse(param.GetState_Text(), out height)) { argHeights[designator.GetState_Text()].ParameterHeight = height; } argComponent.SchIterator_Destroy(ref paramIterator); return; } param = paramIterator.NextSchObject() as ISch_Parameter; } argComponent.SchIterator_Destroy(ref paramIterator); } catch (Exception ex) { ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex); return; } }
private void CleanUpSamtecSymbols() { ISch_ServerInterface SchServer = SCH.GlobalVars.SchServer; if (SchServer == null) { return; } ISch_Lib currentLib = SchServer.GetCurrentSchDocument() as ISch_Lib; if (currentLib == null) { return; } 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); }
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 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); } }