3 Replies Latest reply on May 28, 2015 10:57 PM by raliesch

    Close View via Automation in Xpedition


      Hi Everyone


      I just started with scripting so I don’t have a lot of experience with scripting. Last Friday I have been trying to find a way to close the 3D View screen via Automation.

      Does anyone know if this is possible and if possible how it has to be done?  I found a way to open the 3D View with the Add PCB View button in the Window Menu, unfortunately there is no close button in that Menu, so to close the 3D View I need something else. The only way I know to close the 3D View is with the x in the upper right corner, anyone know how I can access this? 


      What I can for example is “pcbDocObj.close” but this will close the complete Layout, but I just like to close the 3D View with the Automation.


      So if anyone has a idea or can give me a hint how I can do this, that would be great.


      Thx alot in advance 


      BR Ralf

        • 1. Re: Close View via Automation in Xpedition



          The 3D View window was acquirable by following code.

          But the window was not closed even if it executed the Delete method...


              Set viws = pcbDoc.ViewsEx(epcbViewAllViews, "*")

              For Each viw In viws

                  If viw.OriginalName = "3D View" Then

                      Call viw.Delete

                  End If





          • 2. Re: Close View via Automation in Xpedition

            If the functionality you need to access a particular object is not available in the provided scripting or COM environment, you can use the UI Automation methods.


            It's like gui.processcommand, but on steroids.  If there is an object in a window, you can find out what it's name is and then interact with it.  The processcommand stuff is useful if all you are doing is raising a dialog box and hitting the OK button, But if you need to access sub-elements, there is nothing there for that.  UI Automation gives you access to everything.


            First caveat: I use VB.net for all my automation.  I have never tried to use UI Automation with vbscript or the Mentor Scripting tools. I have no idea if it will work at all in either of those environments.  For VB.net, you can use either the Sharp Develop IDE or Visual Studio Express.  Both are free and work equally well. I use Sharp Develop.


            First you will need to get the UI Automation Verify software.  It's hard to get it standalone.  Microsoft used to provide it as a separate tool, but now it's bundled with the Windows SDK.  You could go that route and install the entire SDK if you want, or you can get the source code for UIAVerify from here.


            If you have UIAVerify as part of the SDK already, skip down to "Using UIAVerify"


            If you are using the source code I linked above, download it and unpack in the location of your choice.  Open the solution (.sln) file.  The project will open in whatever IDE you have set up.  Build the program.  Executable files will be created in the bin/Debug folder.  Run the VisualUIAVerify.exe file in there.


            Using UIAVerify


            When you run the UIAVerify software, the panel on the left will show you all the windows/objects/controls open on your system, starting with the Desktop at the top.  Each object has a type, like pane, window, edit, etc. The type is important, as you will see below.  See this image for an example:



            You can see that the Xpedition window has been expanded, along with the Workspace pane, and the two workspace windows below it.  That is the information you need to interact with those windows.


            Now you just need some code to do all this interaction.  I've attached a sample subroutine with some methods for stepping through the levels of controls and working with them.  The basic process is to get an object, then cycle through all its children to find the next level object, then repeat the process until you get to the object of interest.  Once you get the object you want, then you can interact with it in whatever ways are appropriate. You will have to do some googling to find out how to get each kind of control, and what functions are available for that control through the UI Automation interfaces.


            I know you are new to scripting, and there are probably people who will think this is too advanced for you.  Perhaps it is.  Perhaps it's not.  Until Mentor exposes all of the objects in every window to their COM, or provides alternative methods, sometimes something like this is the only way to skin the cat. 


            I've used the UIAutomation stuff to do many things with various Mentor tools, and have yet to suffer a nuclear holocaust as a result. For example, the contours on the outer edges of the board in the image above are created using the Grow/Shrink box in the draw object properties dialog.  I copy the board outline, then expand and trim it, then add more segments to close the loop, then turn it into a contour.  It saves a ton of time trying to follow the board edge with a contour when the board edge has a complex shape. (the grow/shrink command uses Mentor's mask engine to do all the heavy lifting.  You could also use it to do the same thing, but that would require a lot more coding effort, and an automation pro license. Using the grow/shrink box bypasses all of that in a couple of easy steps.)


            If you run into some roadblocks, continue to post up here and we will continue to try to help you. 

            1 of 1 people found this helpful
            • 3. Re: Close View via Automation in Xpedition

              Hi Patrick


              Thx a lot for yourresponse, it is really great from you that you try to help me. I will try to follow your guide, and see how fare I get. I will keep you updated on the progress, but this may take a while since I have other Projects to do atm.


              But now i know in whichdirection I have to go, if I want to find a solution for this. So the first step will be to set up the development environment like you explained, and then try to get some example code to work, and then continue…

              I can’t wait to start with this, I just need the time to do so.

              Alright thx a lot for taking the time to answer my question, I am sure this will also help other people that want to do
              similar stuff.


              Ok I will keep you updated, again great post thx for this.


              Best regards