14 Replies Latest reply on Oct 21, 2016 7:41 AM by jim.cosenzo@gd-ms.ca

    Getting started with automation

    jim.cosenzo@gd-ms.ca

      Hi

      I am a complete noob with automation in the Xpedition flow and am looking for some guidance.

      I have written quite a bit of automation years back in the old Board Station flow and when we went to the Expedition flow back in 2012 we decided to use it "out of the box".

      Of course there is some things which have risen which lend itself to automation and I think it is time to bite the bullet write some automation scripts to address these "things".

      I apologize for questions I'm about to ask, but after reading the online documentation and  the forums for the last day I feel you folks may be able to get me up and running quicker.

       

      Baby steps and silly questions first:

      A simple "hello world" script, How do I run it?

      A GUI script, how do I automatically load it and run it?

       

      My goal it to write a script which runs in DxDesigner and takes all the sections of a non-homogeneous FPGA symbol and creates a csv text report of the all the pins on the device and grabs the pin name, pin number, and optionally the net name attached to the pin..

       

      Any recommendations as to, Where do I start? sample code, pitfalls will be greatly appreciated.

       

      Thanks

      Jim

        • 1. Re: Getting started with automation
          Patrick.Cashman

          There are basically 3 ways to do this:

          vbscript - the most prmitive, no gui, just command interfaces with minimal user interaction.  From the user's point of view, it's a menu pick and then something happens.  Or not . . .  Mentor supports this environment.

           

          EFM - this is a vbscript + simple GUI environment.  Same basic syntax and commands as vbscript alone, but now you get some user controls and other useful interfaces.  This environment is also officially supported by Mentor.

           

          Compiled scripts/applications: VB6 or any of the .net flavors.  .Net is the full monty, with all the power of the .net world available, all the gui/user controls, memory and data structures, and gazillions of examples of anything you can dream up all over the web.  Plus you can use the C# language, which is very similar to Ample, which was a C derivative, but you get all the .net stuff at the same time. It's the most flexible, most adaptable to interfaces with other software tools, and capable of being the fastest if you learn how to use the functionality.  Compiled scripts are officially not supported by Mentor, so you are on your own as far as debugging and getting any help from their Support staff.

           

          I use vb.net. For me, the power and flexibility it gives you, in addition to the vast resources available on the web, make it clearly head and shoulders above the other options.

           

          Another significant factor is what version of Expedition you are using.  If 7.9.5 or earlier, there are some big differences to the latest VX release.  Primarily it's a bit more difficult to run automation tools in VX, due to the need to determine the version of the Mentor tools being used on the fly as the automation application starts up. 

           

          So, steps 1 and 2 are to determine which scripting environment you want to use, then which release of Mentor tools you are using.  Once you know that, we can move forward with specifics on how to take the baby steps.

           

          If by chance you are going to use vb.net or C#.net, and are also using VX.1.x, I have a complete automation template I can share with you which has the startup routines and automation interface hooks already in place for all the major Xpedition flow modules: DxDesigner, Xpedition, Fablink, Drawing editor, and Variant Manager, which runs alongside the rest of the tools.  IMO that would be the best way to start.  It may seem like jumping into the deep water will have the steepest learning curve, but not really.  The cool thing about this is that you can start off very simply and just build up and up.  No need to use what you don't need.

          1 of 1 people found this helpful
          • 2. Re: Getting started with automation
            Mike_Walsh

            While not widely known,  you can also use Tcl/Tk for automation.  I like Tcl because you don't have to compile it, it is simple to build a fairly complex GUI, and there is tons of code available online to use.  It is also cross platform so a script runs the same and without modification on Windows with 32 Xpedition as it does on Linux under 64 bit Xpedition.

             

            However, you can't just any version of Tcl - you have to use the Tcl environment Mentor ships with the Xpedition installation as it comes with the COM binding (even on Linux).

             

            On Windows, open a Mentor Command Window:

             

            %SDD_HOME%\common\%SDD_PLATFORM%\tclwtcom\bin\wish84.exe

             

            On Linux 32 bit:

            $SDD_HOME/common/linux/bin/wish8.4

             

            On Linux 64 bit:

            $SDD_HOME/common/amd64_linux/bin/wish8.4

             

            One of the limitations is you cannot run Tcl in process - it only runs out of process  by connecting to an Xpedition (or other application) session.

            1 of 1 people found this helpful
            • 3. Re: Getting started with automation
              peter_festesen

              Hi Jim

               

              Since you ask for the 'Helleo World' script, it seems that you haven't yet found the 'PCB Automation tutorial'. It is located in your installed documentation - for me (EEVX2) it is located at 

              c:\MentorGraphics\EEVX.2\docs\pdfdocs\pcb_auto_tut.pdf

               

              On page 50, there is a 'Hello World' example

              Have fun !!!

              /Peter

              1 of 1 people found this helpful
              • 4. Re: Getting started with automation
                peter_festesen

                Hi Patrick

                Thanks for your excellent explanation !!

                I have created quite a bit of automation scripts for various Mentor tools, but haven't really embarked on the vb.net way of scripting yet, but it may become relevant for me (Visual Studio Express 2013) soon. I would like a copy of your 'Starter Template' if possible.

                 

                Thanks,
                Peter 

                • 5. Re: Getting started with automation
                  jim.cosenzo@gd-ms.ca

                  Hi Patrick

                   

                  Awesome explanation!

                  I like the way you broke it down from simple scripting, to "full monty".

                  We are currently running ee7.9.5 update 6,  but I plan to migrate to VX.2 in the new year.

                   

                  I think I want to start with the primitive model first, get something written in vbscript which can operate on a single sheet then move on to wrapping it in a GUI. I should mention I have not touched vbscripting nor .net, but am up for the challenge. My background is Perl, bash, and of course ample. You might have guessed I am Linux oriented and stayed away from Windows as long as possible, but alas, with Expedition I had to come over to the dark (MS) side. That is a topic for another discussion.

                   

                  I'd like to take you up on your generous off to share your complete automation template, given that I will be migrating us to the VX.2  release in the near future.

                   

                  I think once I get the first simple vbscript written and working I  would like to "jump into the deep water" as you said. Hey, if I don't shoot the puck at the .net,  I won't score.

                   

                  Thanks!

                  Jim

                  • 6. Re: Getting started with automation
                    jim.cosenzo@gd-ms.ca

                    Hi Peter

                     

                    Thanks!

                    You are correct, I  had not found it, but will give it a go.

                    Rolling up the sleeves as we speak.

                     

                    Cheers,

                    Jim

                    • 7. Re: Getting started with automation
                      jim.cosenzo@gd-ms.ca

                      Hi Mike

                       

                      I was not aware of the tkl/tk path. Thanks!

                       

                      Cheers

                      Jim

                      • 8. Re: Getting started with automation
                        Patrick.Cashman

                        Your first vbscript: Make a text file called hello_world.vbs  .  Inside the file, paste this:

                         

                        msgbox("Hello World")

                         

                        Save and close the file.  Double click it.  Boom, you're done.

                         

                         

                        Guys, the automation template is here

                         

                        Thank you for the kind words, and feel free to use that template any way you want.

                        • 9. Re: Getting started with automation
                          Mike_Walsh

                          As I said, it isn't well know or well documented.  You are very much "on your own" when using Tcl as Mentor Customer Support will not accept Tcl SR requests.

                           

                          Here is a simple example I did a few months ago when playing around with Scripting.Globals for something we were looking at.

                           

                          #!/usr/bin/env tclsh8.4

                          ## vim: set expandtab tabstop=4 shiftwidth=4:

                          ##

                          ##  Scripting.Globals.tcl

                          ##

                          ##  Example Tcl script which shows how to

                          ##

                          ##  This script should be run with eithe Tcl or Wish included in the

                          ##  Mentor Xpedition installation as they are built with Tcom support

                          ##  required to use the API.

                          ##

                          ##  Linux:

                          ##     $SDD_HOME/common/$SDD_PLATFORM/bin/wish8.4

                          ##     $SDD_HOME/common/$SDD_PLATFORM/bin/tclsh8.4

                          ##

                          ##  Windows:

                          ##     %SDD_HOME%\common\%SDD_PLATFORM%\tclwtcom\bin\wish84.exe

                          ##     %SDD_HOME%\common\%SDD_PLATFORM%\tclwtcom\bin\tclsh84.exe

                          ##

                          ##

                          ##  (c) May 2016 - Mentor Graphics Corporation

                          ##

                          ##  Mike Walsh - mike_walsh@mentor.com

                          ##

                          ##  Mentor Graphics Corporation

                          ##  1001 Winstead Drive, Suite 380

                          ##  Cary, North Carolina 27513

                          ##

                          ##  This software is NOT officially supported by Mentor Graphics.

                          ##

                          ##  ####################################################################

                          ##  ####################################################################

                          ##  ## The following  software  is  "freeware" which  Mentor Graphics ##

                          ##  ## Corporation  provides as a courtesy  to our users.  "freeware" ##

                          ##  ## is provided  "as is" and  Mentor  Graphics makes no warranties ##

                          ##  ## with  respect  to "freeware",  either  expressed  or  implied, ##

                          ##  ## including any implied warranties of merchantability or fitness ##

                          ##  ## for a particular purpose.                                      ##

                          ##  ####################################################################

                          ##  ####################################################################

                          ##

                          ##  Change Log:

                          ##

                          ##    05/27/2016 - Initial version.

                          ##

                           

                           

                          package require tcom

                           

                           

                          ##  Output Tcl platform

                          parray tcl_platform

                           

                           

                          ##  Platform?

                           

                           

                          if { [string equal $::tcl_platform(platform) windows] } {

                              ##  Load the Mentor DLL for Xpedition

                              set DLL [file join $::env(SDD_HOME) wg $::env(SDD_PLATFORM) bin ExpeditionPCB.exe]

                              if { [file exists $DLL] } {

                                  ::tcom::import $DLL

                              } else {

                                  puts stderr [format "Unable to load Xpedition API from \"%s\"." $DLL]

                                  exit 1

                             }

                          } elseif { [string equal $::tcl_platform(platform) unix] } {

                              ##  Load the Mentor TLB for Xpedition

                              set TLB [file join $::env(SDD_HOME) wg $::env(SDD_PLATFORM) bin ExpeditionPCB.tlb]

                              if { [file exists $TLB] } {

                                  ::tcom::import $TLB

                              } else {

                                  puts stderr [format "Unable to load Xpedition API from \"%s\"." $TLB]

                                  exit 1

                             }

                          } else {

                              ##  Unsupported platform

                              puts [format "Platform \"%s\" is unsupported." $tcl_platform(platform)]

                              exit 1

                          }

                           

                           

                          # Function that returns a licensed doc object

                          proc getLicensedDoc {appObj} {

                               # collect the active document

                               set docObj [$appObj ActiveDocument]

                           

                           

                               # Ask Expeditions document for the key

                               set key [$docObj Validate "0" ]

                           

                           

                               # Get token from license server

                               set licenseServer [::tcom::ref createobject {MGCPCBAutomationLicensing.Application}]

                           

                           

                               set licenseToken [ $licenseServer GetToken $key ]

                           

                           

                               # Ask the document to validate the license token

                               $docObj Validate $licenseToken

                           

                           

                               # everything is OK, return document

                               return $docObj

                          }

                           

                           

                          set pcbApp [::tcom::ref getactiveobject {MGCPCB.ExpeditionPCBApplication}]

                          set pcbDoc [ $pcbApp ActiveDocument ]

                          set pcbToken [ getLicensedDoc $pcbApp ]

                          set pcbGui [$pcbApp Gui]

                          set pcbUtil [$pcbApp Utility]

                           

                           

                          puts "\n Current Scripting.Globals"

                          puts "-----------------"

                           

                           

                          ##  Iterate over the keys and output the values

                          ::tcom::foreach key [[$pcbUtil Globals] Keys] {

                              puts [format "%-30s = %-30s" $key [[$pcbUtil Globals] Data $key]]

                          }

                           

                           

                          puts "-----------------"

                           

                           

                          puts "\n Creating Example Settings in Scripting.Globals"

                          puts "-------------------------------------------------"

                           

                           

                          for {set i 0} {$i < 10} {incr i} {

                              set sg [format "Sample_SG_%s" $i]

                              puts [format "Creating Scripting.Global %s ..." $sg]

                              [$pcbUtil Globals] Data $sg [format "%s_Value" $sg]

                          }

                           

                           

                          puts "\n Current Scripting.Globals"

                          puts "-----------------"

                           

                           

                          ##  Iterate over the keys and output the values

                          ::tcom::foreach key [[$pcbUtil Globals] Keys] {

                              puts [format "%-30s = %-30s" $key [[$pcbUtil Globals] Data $key]]

                          }

                           

                           

                          puts "-----------------"

                          puts "Done.\n"

                          1 of 1 people found this helpful
                          • 10. Re: Getting started with automation
                            Mike_Walsh

                            Well that example code didn't format very well.  Looks like the PRE tag gets filtered out.  I've attached the file instead.

                            2 of 2 people found this helpful
                            • 12. Re: Getting started with automation
                              jeff@viavi

                              I would suggest downloading the Mentor AATK (AATK_1719 released ).  There is a help directory that has a bunch of Powerpoint slides to help you get going

                              • 13. Re: Getting started with automation
                                jim.cosenzo@gd-ms.ca

                                Hey Patrick

                                Thanks for this.

                                 

                                regards

                                Jim

                                • 14. Re: Getting started with automation
                                  jim.cosenzo@gd-ms.ca

                                  Thanks Jeff, will do.