3 Replies Latest reply on Sep 12, 2014 6:58 AM by Patrick.Cashman

    How to open the first sheet of root block when no sheet was opened initially

    andreas.rehn

      Hi,

       

      I'm trying to open the first sheet of the root block in DxDesigner. DxDesigner and the project are opened by automation. Once this is done no schematic or sheet is open.

      When I try now to access the collection schematicSheetDocuments() it fails due it is null.

       

      I use this code:

       

      DxDesignerApp.OpenProject(@"D:\cad\projects\test\test.prj");

        string rootBlockName = DxDesignerApp.GetProjectData().GetiCDBDesignRootBlock(DxDesignerApp.GetActiveDesign());

        string firstRootBlockSheetName = DxDesignerApp.SchematicSheetDocuments().GetAvailableSheets(rootBlockName).GetItem(0);

        DxDesignerApp.SchematicSheetDocuments().Open(rootBlockName, firstRootBlockSheetName);

       

      Does anybody know how to open/load a schematic by automation in order to get the SchematicSheetDocuments collection?

       

      Thanks!

        • 1. Re: How to open the first sheet of root block when no sheet was opened initially
          Patrick.Cashman

          In vb.net, I do something like this:

           

          Dim app as ViewDraw.Application

          Dim design_name As String

          Dim sheet as ViewDraw.SchematicSheetDocument

           

           

          process.Start("D:\\projects\my_project\project.prj")

          app = GetObject(,"ViewDraw.Application")

          design_name = app.GetProjectData.GetiCDBDesignRootBlock(app.GetActiveDesign())

          sheet = app.SchematicSheetDocuments.open(design_name, 1) 'opens sheet 1

           

          I verified that this does work. Starting with no DxDesigner open at all, it starts the tool, loads the project, then opens the sheet. Now if I was actually using it this way, I'd put some error checking in place to make sure the app was open and so on before diving into opening the sheet or doing anything else.  But that's the gist of it.

           

          If you want to get a list of the sheets, you can do this:

           

          Dim sheet_names as New Arraylist

          Dim blocks as Object

          Dim block as ViewDraw.Block

           

          blocks = app.QueryPages(design_name)

          sheet_names.Clear

          For Each block In blocks

               sheet_names.Add(block.SheetNum)

          Next

           

           

           

          In vbscript, the process.Start would be replaced with something like this:

           

          dim wsh

          set wsh = CreateObject("shell.application")

          path = "D:\\projects\my_project\project.prj"

          wsh.open path

          • 2. Re: How to open the first sheet of root block when no sheet was opened initially
            andreas.rehn

            Thanks Patrick, that's it. How did you paste in your code with syntax highlighting?

            • 3. Re: How to open the first sheet of root block when no sheet was opened initially
              Patrick.Cashman

              You're welcome.

               

              The text pasting is kind of kludgey.  If I paste from a text editor (notepad++), it doesn't get the colors.  If I paste directly from the editor in the IDE, it does.  Then I select all the text and quote it using the quote button here in the Reply text box, then change the font to Courier. 

               

              It would be really nice if they had a text formatting thing especially for pasting code that would not add but would add contextual formatting per language rules.