4 Replies Latest reply on Sep 3, 2012 11:27 PM by Wolfgang_Antrey

    Startup Script to open TOP Hirarchy page automaticly?

    Wolfgang_Antrey

      Hello,

       

      Is there a possibilty to open the top block page directly after starting DxDesigner. This would safe some mouse clicks everytime DxDesigner starts up.

       

      I tried:

      Dim vdapp : Set vdapp = GetObject(, "ViewDraw.Application")

      Dim sTopBlock

      sTopBlock = vdapp.GetProjectData.GetiCDBDesignRootBlock(vdapp.GetActiveDesign())

      Application.SchematicSheetDocuments.Open sTopBlock, "1"

       

      but this did not help.

       

      best regards

       

      Wolfgang

        • 1. Re: Startup Script to open TOP Hirarchy page automaticly?
          Satoru

          Hi Wolfgang,

           

          When getting a Design name by GetActiveDesign method, it needs to be selected in the navigator window.

           

          It is necessary to get a Designs collection by GetiCDBDesigns Method.

           

          Please set a sample script in Run on Startup.

           

          Satoru

          • 2. Re: Startup Script to open TOP Hirarchy page automaticly?
            Wolfgang_Antrey

            startup.JPG

            Dim vdapp : Set vdapp = GetObject(, "ViewDraw.Application")

            Dim sTopBlock

             

            Dim Design_Coll

            set Design_Coll = vdapp.GetProjectData.GetiCDBDesigns()

            MsgBox Design_Coll.GetCount()

             

            Now this script was put under Run at StartUp entry in DxDesigner Setup.

            As DxDesigern starts up I try now to get the iCDBDesigns - but the collections is empty.

             

            No Project is opened until - after pressing the OK button it takes about 10 seconds and in the navigator window the selected project from dashboard is shown - but the top hirarchy page must be opened manually.

            This is what I would like to automate ....

             

            How to proceed?

            • 3. Re: Startup Script to open TOP Hirarchy page automaticly?
              taco.de.vries

              This is what I have,  it is possibly not complete, I snarfed some code from what we use.

              Code is meant to create a 'top' sheet and open it, this to ensure that we allways have

              a 'fixed' name for the top sheet. A nice side effect is that this top sheet is allways opened when

              a project is opened.

               

              The 'Sub' makes it a trigger kind of thing that gets executed when a project is changed

               

              Taco

               

              Sub Application_ProjectChanged(project)

               

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

                  schName = "top"

              Set prj     = dxdApp.GetProjectData

              Set Designs = prj.GetiCDBDesigns()

               

              If prj.AddiCDBDesign(PrjName) Then

                Call prj.SetiCDBDesignRootBlock(prjName & schName, prjName)

                Set schDocs = dxdApp.SchematicSheetDocuments

                If schDocs.InsertSheet(prjName & schName, "1") Then

                  set SchDoc = schDocs.Open(prjName & schName, "1")

                  set Block = Application.ActiveView.Block

                  Block.InsertBorder()

                  dxdApp.CloseProject

                End If

              End If

              dxdApp.CloseProject            ' have to close and re-open to update navigator...

              dxdApp.OpenProject(prjFile)

               

              Scripting.Sleep 1              ' need this, otherwise opensheet fails

              Call Application.SchematicSheetDocuments.Open(prjName & schName, "1")

              End Sub

              1 of 1 people found this helpful
              • 4. Re: Startup Script to open TOP Hirarchy page automaticly?
                Wolfgang_Antrey

                This does not work anymore in EE7.9.4.

                 

                Scripting.AttachEvents Application, "App"

                Scripting.DontExit = True

                 

                Sub App_ProjectChanged(prjData)

                    Dim desns

                    Dim schName

                    Dim shetList

                    Dim schDocs, schDoc

                 

                    ' Get Designs List

                    Set desns = prjData.GetiCDBDesigns

                 

                    ' Get Schematic Name

                    schName = prjData.GetiCDBDesignRootBlock(desns.GetItem(1))

                 

                    ' Get Schematic Sheet Documents

                    Set schDocs = dxdApp.SchematicSheetDocuments

                 

                    ' Get Sheets List

                    Set shetList = schDocs.GetAvailableSheets(schName)

                 

                    ' Open Schematic Sheet Document

                    Set schDoc = schDocs.Open(schName, shetList.GetItem(1))

                 

                End Sub

                 

                After calling this subroutine DxDesigner 7.9.4 ends in a crash loop - that means, creating mini dump restart creating mini dump restart ....

                When I deactivate the

                'Scripting.AttachEvents Application, "App"

                'Scripting.DontExit = True

                thing DxDesigner will start up as expected ....