3 Replies Latest reply on Jan 5, 2012 7:32 AM by pete.osborne

    SheetNum Property from all Sheets in a Schematic?


      Hallo together,


      how can i get access to SheetNum Property for all Sheets in a Schematic? At the moment i only get access for one sheet!


      number = application.ActiveView.Block.Sheetnum() --> only for one single sheet


      Anybody an idea?




        • 1. Re: SheetNum Property from all Sheets in a Schematic?

          Function ShowSheetNums()

              Dim oApp, oBlock, sDesignName, sDesignLib, sSheetNum, sPath, sSchName

              Dim collBlocks, collSheets, oComp, sTemp, sSheet


              Set oApp = GetObject(,"ViewDraw.Application")

              Set oBlock = activeView.TopBlock


              'Initialize the Design Objects

              sDesignName = oBlock.GetName(SHORT_NAME)

              sDesignLib = oBlock.LibraryName

              sSheetNum = oBlock.SheetNum

              If sSheetNum <> "1" Then

                  msgbox "Please activate the FIRST sheet of the schematic then rerun macro"

                  exit function

              End If



              'Create a collection of all the Blocks

              Set collBlocks = CreateObject("Scripting.Dictionary")

          '    iSheetCount = 0

              Call oApp.StatusBarText("Creating Sheet number list")

              'Add the root block to the collection of blocks

              collBlocks.add "", sDesignName

              'Find all the Hierarchical Blocks in the design

              For Each oComp In oApp.DesignComponents("", sDesignName, "-1", "STD", true)

                  'Check every composite symbol to see if there is an underlying schematic

                  If oComp.SymbolBlock.SymbolType = VDB_COMPOSITE Then

                      sPath = oComp.GetName(FULL_PATH_NAME)

                      On Error Resume Next

                      sSchName = oComp.SymbolBlock.GetChildBlock.GetName(FULL_PATH_NAME)

                      If Err.Number > 0 Then

                          sSchName = objComp.SymbolBlock.GetName(FULL_PATH_FROM_BLOCK)

                      End If


                      On Error goto 0

                      'Add the Path and the Schematic name to the Collection

                      collBlocks.Add  sPath, sSchName

                  End If



              Set collSheets = CreateObject("Scripting.Dictionary")


              For Each sPath In collBlocks.Keys

                  sSchName = collBlocks(sPath)

                  'msgbox "About to open " & sSchName & " from " & sPath

                  For Each sSheet In oApp.SchematicSheetDocuments.GetAvailableSheets(sSchname)

                      'Push into each sheet

                      If oApp.pushpath ( sDesignName , sPath, sSheet) Then


                          msgbox oApp.ActiveView.Block.Sheetnum()


                          msgbox "Couldn't Push into " & sSheet

                      End If





          End Function

          1 of 1 people found this helpful
          • 2. Re: SheetNum Property from all Sheets in a Schematic?

            Thank you, Pete, it works!


            Is there a difference between property SheetNum and @Sheet? I don´t think so!


            Best regards


            • 3. Re: SheetNum Property from all Sheets in a Schematic?

              Are you 2005.x or 7.9.x?


              I believe @SHEET is a property attached to the border symbol.  In our 7.9.x config, we use SHEET as the property attached to the border symbol.  Either property is updated by the Scout/Xref utility. (Depending on your config)


              After Scout/XREF has been run, the @SHEET/SHEET property contains the sheet number wrt the Top Block.  In our configuration, SHEET actually shows "x of n"  ie "3 of 11"


              The SheetNum Property  shows you the Sheet Number wrt the Block.   So,  if you are in a hierarchical design, with 2 sheets in the top design and 2 in the lower design, recusring through the SheetNum properties will return 1,2,1,2  . That's assuming you never renamed your Sheets.  In the Navigator Pane, you can rename each Sheet to whatever you want.


              If you want to see the @SHEET properties,  Something like this may help you out.


              Function ReadSheetAttr()

                  Dim oComp, oAttr, oApp, oBlock


                  Set oApp = GetObject(,"ViewDraw.Application")

                  Set oBlock = ActiveView.TopBlock


                  sDesignName = oBlock.GetName(SHORT_NAME)


                  'For Each oComp In oApp.ActiveView.Query(VDM_COMP, VD_ALL)  ' If you are recursing through using views, use this line

                  For Each oComp In Application.DesignComponents("", sDesignName, "-1", "STD", True)   ' This way will look through the whole design in one shot

                      If oComp.SymbolBlock.SymbolType = VDB_ANNOTATE Then

                          If ucase(oComp.SymbolBlock.GetName(SHORT_NAME)) = "INSERT_BORDER_SYMBOL_NAME_HERE" Then

                              Set oAttr = oComp.FindAttribute("@SHEET")

                              If oAttr Is Nothing Then


                                  msgbox "The @Sheet Property is " & oAttr.InstanceValue

                              End If

                          End If

                      End If


              End Function