1 Reply Latest reply on Jul 28, 2014 8:57 AM by fuba

    Open Block Schematics (Sub Blocks / Building Blocks) from Board Schematic


      Hello out there,


      I have an application running over all sheets in a schematic, scanning each sheet for electrical components, and extracting attributes, and much more.

      On a few designs we use Blocks (sub Schematics) / hierachical design.


      My Problem is now, how do I dive down / push / open via script vba / vb.net code the subschematic,

      and analyze the sheet in regards to my components attriutes and so on.


      The next question is also, how can I find out when checking a component on a schematic sheet if it is a sub block, or a "real component".

      I have tried a few things, but nothing really bullet proof / successful.


      Thanks to everyone contributing to this thread.


      Please do not miss the attached file.





        • 1. Re: Open Block Schematics (Sub Blocks / Building Blocks) from Board Schematic



          I found a solution, for sure there are more than one, but this one meets my requirements so far.

          But mentor friends out there, I am still open for your ideas.


          I am still thinking about how to use for example:




          But anyway, below my solution, feel free to use.


          I inspired myself by reading this thread.



          and first of all I needed a function telling me is this a part or a Block / Building Block something with a "sub-schematic"


          Function IsBuildingBlock(Component As ViewDraw.Component)



                  '# Check every composite symbol to see

                  '# if there is an underlying schematic

                  '# and dive into / push down to



                  'Call this function like this

                  'Dim ret As Boolean

                  'ret = IsBuildingBlock(Component)


                  Dim ret As Boolean

                  ret = False


                  If Component.SymbolBlock.SymbolType = ViewDraw.VdSymbolType.VDB_COMPOSITE Then


                      Dim BlockName As String

                      BlockName = Component.GetName(ViewDraw.VdNameType.FULL_PATH_NAME)


                      Dim SchematicName As String

                      SchematicName = Component.SymbolBlock.GetChildBlock.GetName(ViewDraw.VdNameType.FULL_PATH_NAME)


                      If IsNothing(SchematicName) Then

                          SchematicName = Component.SymbolBlock.GetName(ViewDraw.VdNameType.FULL_PATH_FROM_BLOCK)

                      End If



                      '# Add the BlockName and the Schematic Name to a Collection for later use


                      colBlocks.Add(BlockName, SchematicName)


                      ret = True


                  End If


                  Return ret


          End Function


          Here then the Sub/Function which runs over the buildingBlocks found on the Page/Design on the Selected Part, ...


          Sub LoopOverMyBuildingBlocks()



                  '# Analyze the blocks we found now in an extra loop



                  For k As Integer = 0 To colBlocks.Count - 1


                      Dim BlockName As String

                      BlockName = colBlocks.Keys(k)


                      Dim SchematicName As String

                      SchematicName = colBlocks.Values(k)


                      Dim sheets As ViewDraw.IStringList

                      sheets = vdApp.SchematicSheetDocuments.GetAvailableSheets(SchematicName)


                      Dim shtCnt As Integer

                      shtCnt = sheets.GetCount


                      For m As Integer = 1 To shtCnt


                          Dim SchematicSheetName As String

                          SchematicSheetName = sheets.GetItem(m)


                          Dim ProjectName As String

                          ProjectName = vdPrj.GetProjectName


                          Dim ret As Boolean

                          ret = vdApp.PushPath(ProjectName, BlockName, SchematicSheetName)


                          Debug.Print(ProjectName & "->" & BlockName & "->" & SchematicSheetName)


                          If ret Then



                              '# Check the Components on that page



                              Dim TheComponents As ViewDraw.IVdObjs

                              TheComponents = vdApp.ActiveView.Query(ViewDraw.VdObjectTypeMask.VDM_COMP, ViewDraw.VdAllOrSelected.VD_ALL)


                              Dim str As String

                              Str = "There are " & TheComponents.Count & " components on this sheet"




                          End If






          End Sub


          Yes, that's it so far.

          i still think it is a bad way, to open the schematic like this (with the PushPath-Method):


          ret = vdApp.PushPath(ProjectName, BlockName, SchematicSheetName)


          is there a better way, directely from the buildingBlock selected ?