Skip navigation
Currently Being Moderated

How to visit each schematic sheet in DxDesigner 2007.x

VERSION 4  Click to view document history
Created on: Nov 25, 2008 4:44 AM by john_dube - Last Modified:  Mar 3, 2011 5:12 PM by john_dube

Many scripts need to perform some function on every schematic sheet in a design, whether it is searching for component properties or replacing text.

 

If you simply need a listing of the schematic sheets in a project, without the hierarchical context, you can use the SchematicSheetDocuments.GetAvailableSchematics and SchematicSheetDocuments.GetAvailableSheets methods.

 

Both of these methods return a StringList object that can iterated using the "For Each" construct in VBScript, or use numeric indexing from 1 to the value returned by GetCount.

 

So with these two methods and the StringList collection we can print each schematic sheet to the output window like this:

 

Dim sSchematic, sSheet
For Each sSchematic In Application.SchematicSheetDocuments.GetAvailableSchematics
     For Each sSheet In Application.SchematicSheetDocuments.GetAvailableSheets(sSchematic)
          Application.AppendOutput "List Sheets", sSchematic & "." & sSheet
     Next
Next

 

If you need to access the contents of each schematic sheet, you can use the SchematicSheetDocuments.Open method to open the schematic, and then use the Query method on the ActiveView. Here the previous example is extended to list each component unique id:

 

 

Dim sSchematic, sSheet, objComp
For Each sSchematic In Application.SchematicSheetDocuments.GetAvailableSchematics
     For Each sSheet In Application.SchematicSheetDocuments.GetAvailableSheets(sSchematic)
          Application.SchematicSheetDocuments.Open sSchematic, sSheet
          For Each objComp In Application.ActiveView.Query(VDM_COMP, VD_ALL)
               Application.AppendOutput "List Comps", objComp.UID
          Next
     Next
Next

 

Now, chances are you are using hierarchy in your schematics, and you will need to establish the proper hierarchical context when opening schematics. Instance values, especially on blocks that are instantiated more than once, can be accessed only with the proper hierarchical context. So instead of using the Open method to open the schematic sheet, we need to use the PushPath method that opens the schematic sheet with the specified hierarchical context.

 

To get the list of schematics that need to be opened, and the hierarchical context for each sheet, we need to use the DesignComponents method to find all the composite symbols in the design. The composite blocks and their context path is stored in a dictionary object, where the key is the context, and the value is the schematic name. After the script has finished the DesignComponents loop, the next step is to loop over the unique contexts, and open each sheet in the composite blocks with the hierarchical path.

 

The example is once again extended to print the full hierarchical context of each component in the design:

 

Function WalkDesign(sTopBlock)
     Dim dictPaths, objComp, sPath, sSchematic, sSheet
     
     SchematicSheetDocuments.Close

     Set dictPaths = CreateObject("Scripting.Dictionary")
     dictPaths.Add "", sTopBlock
     For Each objComp In Application.DesignComponents("", sTopBlock, "-1", "STD", True)
          If objComp.SymbolBlock.SymbolType = VDB_COMPOSITE Then
               sPath = objComp.GetName(0)
               On Error Resume Next
               sSchematic = objComp.SymbolBlock.GetChildBlock.GetName(0)
               If Err.Number > 0 Then
                    sSchematic = objComp.SymbolBlock.GetName(2)
               End If
               dictPaths.Add sPath, sSchematic
          End If
     Next
     
     For Each sPath In dictPaths.Keys
          sSchematic = dictPaths(sPath)
          For Each sSheet In Application.SchematicSheetDocuments.GetAvailableSheets(sSchematic)
               Application.PushPath sTopBlock, sPath, sSheet
               For Each objComp In ActiveView.Query(VDM_COMP, VD_ALL)
                    AppendOutput "List Comps", objComp.GetName(FULL_PATH_FROM_BLOCK)
               Next
               SchematicSheetDocuments.Close
          Next
     Next
End Function
Average User Rating
(2 ratings)