4 Replies Latest reply on Jan 10, 2013 9:20 AM by STHBRDG

    Manage DxD sheet numbers programmatically

    STHBRDG

      Hello,

       

      I have a hierarchical schematic and I need to organize the sheets in a more meaningful manner than what is allowed through the "setup->settings" approach.  I can see through the navigator that the blocks have a property called $(Number) that dictates the sheet ordering.  I cannot find a way to modify that attribtue programmatically.  How can I adjust the overall sheet order programmatically?  The SHEETNUM block attribute doesn't work nor does the NAME attribute of a schematicSheetDocument.  Is there such thing as an attribute that is specific to the instantiation of a block that I can use to uniquely identify and control the sheet number that the pdf converter will recognize?  It seems that there are no unique properties to the blocks that have multiple instantiations...

       

      Thanks,

      Nick

        • 1. Re: Manage DxD sheet numbers programmatically
          Patrick.Cashman

          There are a number of sticky areas surrounding your questions.

           

          1. It is possible to iterate through design sheets using something like this:

           

          Public schms As ViewDraw.IStringList

          Public sheets As ViewDraw.IStringList

          schms = app.SchematicSheetDocuments.GetAvailableSchematics    

          For n = 1 To schms.GetCount

               sheets = app.SchematicSheetDocuments.GetAvailableSheets(tmp1)

               For i = 1 To sheets.GetCount

                    'some code here for each sheet

           

               Next

          Next

           

          2. One would expect that the resulting iteration would always match what you see in the Navigator.  It doesn't.

           

          3. If the sheets are re-ordered, the sheet iteration above will produce results that do not match the Navigator sheet order.

           

          4. This indicates that there are two separate indices that control the Navigator and the iteration through sheets. To my knowledge, they do not mingle and there is no accessible way to correlate the two.

           

          5. I discovered the following, which indirectly gets you to the Navigator index:

           

          Public sheet_names as New ArrayList

          Public design_name as String

           

          Sub get_sheet_names()

                  Dim blocks as Object

                  dim block as ViewDraw.Block

           

                  design_name = app.GetProjectData.GetiCDBDesignRootBlock(app.GetActiveDesign())    'this is the schematic, not the board

                  blocks = app.QueryPages(design_name)

                  sheet_names.Clear

                  For Each block In blocks

                      sheet_names.Add(block.SheetNum)

                  Next

           

              End Sub

           

          6. The result of the above is an arraylist with all the names of the sheets in it that matches the Navigator sheet numbering and order.  It needs some error-checking and validation steps added but it's a starting point for being able to step through your schematic sheets.  Further exploration needs to be done to find the full capabilities of app.GetProjectData.GetiCDBDesignRootBlock and anything that might work around it.

           

          7. There is no way I know of to correlate or connect any of this to the PDF output routine.  It's been a while since I looked at that but I do not remember any way of getting automation hooks into it or even being able to use command-line switches or other parameters to affect it.  Another useful tool that is completely under lock and key. And somewhat limited in what it is allowed to do.

           

          I realize that I have not directly answered your question, but I hope you can use some of this as a starting point for further exploration.  Please report back if you are able to find anything else on this subject that will assist the rest of us.

           

          Edit: This code is for vb.net.  May not be compatible with other VB systems.

          • 2. Re: Manage DxD sheet numbers programmatically
            Patrick.Cashman

            You will also want to look at this technote regarding hierarchical sheet numbering using the Scout Cross Reference tool.  If that is set up properly, you should be able to programatically change the SHEET property while stepping through the different schematics/blocks in the design and thus define the dxPDF output.

            • 3. Re: Manage DxD sheet numbers programmatically
              STHBRDG

              Hi Patrick,

               

              Thanks for your info.  I was able to work this out using your guidance and an appnote for scout and John Dubes code for visiting each sheet in a hierarchical design.

               

              REFERENCES:

              1.  Creating a Page Number File for Use with Cross Reference, Scout and DxPDF

                   http://supportnet.mentor.com/reference/technotes/public/technote.cfm?id=MG540690

               

              2.  How to visit each schematic sheet in DxDesigner 2007.x

                   http://communities.mentor.com/docs/DOC-1345

               

              OVERVIEW:

              Controlling the print order and sheet numbering is fairly straight forward.  You may need to be able to change or influence someone to change the border symbol properties.  You will need to export a hierarchical schematic sheet list with VBA.  You will need to augment your scout.ini file to update the numbers during cross referencing.

               

              PROCEDURE:

              1.     Export a list of sheets from the schematic.  I like to use Excel VBA editor because it has an object browser. Set a reference to the Viewdraw object model and to the Microsoft Scripting Runtime.

              2.     Open your DxD project but don't open any sheets.

              3.     Hard code the sTopBlock string in the main function that is specific to your design.

              4.     Run the main subroutine.  The WalkDesign routine will print the sheet_order.txt data into the output window in DxD.

              5.     Copy/Paste this into a blank text file and call it SHEET_ORDER.txt.  Save the file in your "additional files" project subfolder.

                        If you want to reorder the sheets, you simply modify the numbers in the SHEET_ORDER.txt file.

              6.     Open up your scout.ini file.  Add the following lines:

               

              page_number_file "[FULLY QUALIFIED PATH TO]\SHEET_ORDER.txt"

               

              7.     Add the following "direct_reference" command.  I Notice that directref1 applies to my border symbol.  You need to specify yours there.  Also notice that I placed this at 32.1, 0.70 with upper_center.  That is where I want the @PRINTORDER attribute placed.  I was using D size sheets.  Also - our librarian team had used "SHEETNUM" instead of "@PRINTORDER" so we had to augment our border symbols.  You may need to do the same.

               

              direct_reference directref1

                  attr any [YOUR_BORDER_SYMBOL_NAME] comp_attr any 32.10,0.70 upper_center

                  format_prefix "@PRINTORDER"

                  format_entry "$page_num"

                  format_attr_vis value_visible

                  format_attr_size 0.15

                  format_reset true

              end

               

              8. Add the following "direct_reference" command.Notice that directref1 applies to any composite symbol. I don't know for sure but this seems to apply in part to hierarchical blocks.  As soon as I realized that this was starting to work I also grimaced because I was sloppy with my hierarchical block symbols in that I didn't really care at first where the origin was.  Since I wanted a uniform apperance of the print order on each composite symbol, I had to update >60 blocks so that 0,0 corresponded to the upper right corner of the block.  I also added a square border around the location where I would drop the @printorder attribute.

               

              direct_reference directref2

                  attr composite any comp_attr any 0.00,0.00 middle_center

                  format_prefix "@PRINTORDER"

                  format_entry "$lvlpage_first"

                  format_attr_vis value_visible

                  format_attr_size 0.14

                  format_attr_shadow false

                  format_reset true

              end

               

              9.     use "Tools --> Cross Reference" and add cross referencing.

               

              SOURCE CODE

              This was based on John Dube's code from Ref. 2.

              **Use at your own risk

               

              Sub main()

               

              Set vdapp = GetObject(, "ViewDraw.Application")
               
                   Call WalkDesign("[YOUR TOP BLOCK HERE]")

              End Sub

               

               

              Sub WalkDesign(sTopBlock)
                   Dim sPath, sSchematic
                   Dim objComp As ViewDraw.Component
                   Dim sSheets As ViewDraw.StringList
                   Dim i
                   Dim dictPaths As Scripting.Dictionary
                  
                   vdapp.SchematicSheetDocuments.Close
                  
                   Set dictPaths = CreateObject("Scripting.Dictionary")
                  
                   dictPaths.Add "", sTopBlock
                  
                   For Each objComp In vdapp.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(FULL_PATH_FROM_BLOCK)
                            
                             If Err.Number > 0 Then
                                 
                                  sSchematic = objComp.SymbolBlock.GetName(2) ' not sure what this is but it was in the code from the user group.
                            
                             End If 'if Error
                            
                             dictPaths.Add sPath, sSchematic 'This loads the schematic and hierarchy paths into a hash table.
                       
                        End If 'objComp is composite symbol
                  
                   Next 'objComp
                  
                   j = 0 'This will be the sheet numbering index

                   For Each sPath In dictPaths.Keys  'loop through the hash table
                       
                        sSchematic = dictPaths.Item(sPath)  'extract the schematic item from the path key

               

                        Set sSheets = vdapp.SchematicSheetDocuments.GetAvailableSheets(sSchematic)  'string list of sheets from path\schematic
                       
                        For Each sSheet In sSheets 'iterate through each sheet
                       
                              j = j + 1
                            
                             vdapp.PushPath sTopBlock, sPath, sSheet 'Set the active view in DxD to the sheet target from the hash
                            
                             'Debug.Print vdapp.ActiveView.block.GetName(FULL_PATH_FROM_BLOCK)  'Test the code
                             'Print the hierarchical path and sheet index to the output windows called "List Sheets" in DxD
                            

                              vdapp.AppendOutput "List Sheets", sPath & "\" & sSchematic & "." & sSheet & "," & j
                      
                        Next 'sSheet
                  
                    Next 'sPath

               

              End Sub

               

              RESULTS

              hier.png

               

              hier2.png

              hier3.png