9 Replies Latest reply on Jun 22, 2017 11:24 AM by guyjj

    How to add my script in to my Expedition menu

    karthik.rangaraj

      I have some Scripts downloaded from  mentor user forums. I want  to add these scripts  in to  my expedition menu bar,

      and also i want to creat separate menu in Expedition user  window.

      i am begginer to this Automation.Can anyone  help  on this?

       

      Thanks

        • 1. Re: How to add my script in to my Expedition menu
          jeremy_parker

          Automation Manager, a tool I have created to do what you ask in DxDesigner, Expedtiion, Library Manager, will be released to the community in the next week or two.

          • 2. Re: How to add my script in to my Expedition menu
            Patrick.Cashman

            1. In your WDIR location there is a scripts.ini file. In there are some lines that define locations for startup scripts for all the tools.  Like this:

             

            [Expedition PCB]

            Script#0=X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\Load_Expedition.vbs

             

            'DxDesigner stuff

            [viewdraw]

            Script#0=X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\Load_DxDesigner.vbs

             

            [Fablink XE Pro - Document ]

            Script#0=X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\Load_Fablink.vbs

             

            [Fablink XE - Document ]

            Script#0=X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\Load_Fablink.vbs

             

            [Drawing Editor - Document]

            Script#0=X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\Load_Drawing_Editor.vbs

             

            [Library Manager]

            Script#0=X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\Load_LibraryManager.vbs

             

            These scripts will be fired every time one of the tools is loaded.  If this is your corporate WDIR, it will happen for every user.

             

             


            2. In your scripts directory, you have the files indicated by the paths above.  For example, the Load_DxDesigner.vbs file.  Contents look like this:

             

             

            dim menu, menu_1

             

             

            Set sMenu = CommandBars("Sheet Menu Bar").Controls.Add(cmdControlPopup,,,-1)

            sMenu.Caption = "Aeroflex"

             

             

            'CREATE DESIGN INFO MENU ITEM

            Set sButton = sMenu.Controls.Add

            sButton.Caption = "Design Info"

            sButton.OnAction = "run X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\DxDesigner_and_Expedition\Design_Info\Design_Info.vbs"

            'sButton.OnAction = "run Design_Info.vbs"

             

             

            'CREATE PAGE NAVIGATOR MENU ITEM

            Set sButton = sMenu.Controls.Add

            sButton.Caption = "Page Navigator"

            sButton.OnAction = "run X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\DxDesigner\DX_Page_Navigator\DX_Page_Navigator.vbs"

             

             

            'CREATE Export Variant BOM MENU ITEM

            Set sButton = sMenu.Controls.Add

            sButton.Caption = "Export Variant BOMs"

            sButton.OnAction = "run X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\DxDesigner\DxD_Export_Variant_BOM\DxD_Export_Variant_BOM.vbs"

             

            'CREATE DxDAU MENU AND SUBMENUS

            Set menu_1 = sMenu.Controls.Add(cmdControlPopup,,,-1)

            menu_1.Caption = "DxDAU"

             

            Set sButton = menu_1.Controls.Add

            sButton.Caption = "Color Nets"

            sButton.OnAction = "run X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\DxDesigner\DXDAU\ColorNets.vbs"

             

            Set sButton = menu_1.Controls.Add

            sButton.Caption = "Expedition Data"

            sButton.OnAction = "run X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\DxDesigner\DXDAU\ExpeditionData.vbs"

             

            Set sButton = menu_1.Controls.Add

            sButton.Caption = "Modify Component Properties"

            sButton.OnAction = "run X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\DxDesigner\DXDAU\ModifyComponentProperties.vbs"

             

            Set sButton = menu_1.Controls.Add

            sButton.Caption = "Update Symbol Partitions"

            sButton.OnAction = "run X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\DxDesigner\DXDAU\UpdateSymbolPartitions.vbs"

             

             

            The PCB tool menus are a little different.  Here is an example of the Load_Expedition.vbs file:

             

            Option Explicit

             

            Scripting.DontExit = True

             

            Dim g_objExpApp, g_objExpGui

            Dim shellObj

             

            ' Define common used COM objects

            Scripting.AddTypeLibrary("Scripting.FileSystemObject")

            Set shellObj = CreateObject("WScript.Shell")

            ' Type library declarations

            Scripting.AddTypeLibrary("MGCPCB.ExpeditionPCBApplication")

            Scripting.AddTypeLibrary("MGCPCB.Application")

             

             

            Set g_objExpApp = Application

            Set g_objExpGui = g_objExpApp.Gui

            CreateAeroflexMenu

             

             

            '=========================================================================================================================

            ' Add a new Menu command

            Sub CreateAeroflexMenu

                dim menubar, afxmenu, submenu, item

                Dim ctrls, subctrls

                Dim path

                dim wsh

             

                set menubar = g_objExpGui.CommandBars("Document Menu Bar")

                set afxmenu = menubar.Controls.Add(cmdControlPopup,,,-1)

                afxmenu.Caption = "Aeroflex"

             

                set ctrls = afxmenu.controls

             

                set item = ctrls.add

                item.caption = "Design Info"

                item.OnAction = "run X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\DxDesigner_and_Expedition\Design_Info\Design_Info.vbs"

             

                set item = ctrls.add

                item.caption = "BOM, PNP, CPL, ini"

                item.OnAction = "run X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\Expedition\Export_Variant_BOM_1.3\Export_Variant_BOM_1.3.vbs"

             

                set item = ctrls.add

                item.caption = "EZ Control"

                item.OnAction = "run X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\Expedition\EZ_Control\EZ-Control_2.efm"

             

                set item = ctrls.add

                item.caption = "Place Designators"

                item.OnAction = "run X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\Expedition\Place_Designators\Place_Designators.vbs"

             

                set item = ctrls.add

                item.caption = "Test Point Helper"

                item.OnAction = "run X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\Expedition\Test_Point_Helper\test_point_helper.vbs"

             

                set item = ctrls.add

                item.caption = "Report Modified Cells"

                item.OnAction = "run X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\Expedition\Bounce_Cells\bounce_cells.vbs"

             

            End Sub

             

             

            '==========================================================================================================================

            ' Check if the specified menu is already defined, return the menu control handler

            Function FindMenu(menuToFind, menuBar)

                Dim ctrls : Set ctrls = menuBar.Controls

                Dim ctrl, strMenuToFind

             

                Set FindMenu = Nothing

                strMenuToFind = Replace(menuToFind, "&", "")

                For Each ctrl In ctrls

                   Dim capt: capt = ctrl.Caption

                   capt = Replace(capt, "&", "")

                   If capt = strMenuToFind Then

                       Set FindMenu = ctrl

                       Exit For

                   End If

                Next       

            End Function

             


            If you want to run an EFM, do it like the EZ_Control item above.

             


            3. The files that actually start a program look like this:

             

            (Place_Designators.vbs)

             

            Option explicit

             

            Place_Designators

             

            sub Place_Designators()

                dim path

                dim wsh

             

                set wsh = CreateObject("shell.application")

                path = "X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\Expedition\Place_Designators\Place Designators.exe"

                wsh.open path

                set wsh = Nothing

            End sub

             

             

             

             

            4. This is all documented fairly well, but it will take a normal human a couple of days to get it all working correctly if you try to follow it through. 

            1 of 1 people found this helpful
            • 3. Small correction, Patrick ...
              Head1

              Hello Patrick,

               

              I think you have a small mistake in you code:

               

              As far as I remember, the lines in file scripts.ini should start with:

               

              Script#0=...

              Script#1=...

              Script#2=... 

               

              and not as you typed them.

               

               

                 Best regards,

                               Head1.

              • 4. Re: Small correction, Patrick ...
                Patrick.Cashman

                Script#0=X:\ENG\LIBRARY\...

                 

                Script#0=...

                 

                 

                I must be missing something because they appear to be the same.  And they all work as expected.  Can you clarify?

                • 5. Re: Small correction, Patrick ...
                  Head1

                  Hello patrick,

                   

                  The numbers after "Script#" must  ascend.

                    In your code , all lines start with Script#0.

                   

                    Attached 2 files. taken  from Mentor automation book, which

                    explain the subject.

                    The second file (pic_2.pdf) explains how NOT to write.

                   

                       Best regards,

                               Head1.

                   

                   

                  • 6. Re: Small correction, Patrick ...
                    Patrick.Cashman

                    I did it exactly as the documentation indicates.  The script lines for each application start with #0 and ascend from there. The pic_1 file you attached shows them this way.

                     

                    It does not mean

                     

                    [application_1]

                    Script#0=

                     

                    [application_2]

                    Script#1=

                     

                    [application_3]

                    Script#2=

                     

                    This is because if you had this all done and then had to go back and add another script line to [application_1], you would then have to reorder all the rest of them.  Which would be completely illogical.

                     

                     

                    It does mean:

                     

                    [application_1]

                    Script#0=

                    Script#1=

                    Script#2=

                     

                    [application_2]

                    Script#0=

                    Script#1=

                    Script#2=

                     

                    [application_3]

                    Script#0=

                    Script#1=

                    Script#2=

                     

                    They specifically say to start with #0 for each application.

                    1 of 1 people found this helpful
                    • 7. Re: Small correction, Patrick ...
                      Head1

                       

                      I had never more than one application in a script.ini   file.

                      Now I understand why you start from zero each time.

                       

                          Thanks,

                       

                                   Head1.

                      • 8. Re: How to add my script in to my Expedition menu
                        Patrick.Cashman

                        I'm adding some info here on how to implement hotkeys (keyboard shortcuts)

                         

                        In the scripts.ini file in your local WDIR, add an entry that points to a .vbs file.  The .vbs file can be anywhere.  For example, I have this:

                         

                        [Expedition PCB]

                        Script#0=X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\VX_.2.1\2_PCB_Layout\Hotkeys\key_bindings_X.vbs

                         

                        As described above, if there is already a Script#0, then use Script#1.

                         

                        In the key_bindings vbs file, there are some setup variables and then lines for each hotkey assignment.  My key bindings file looks like this:

                        Option Explicit

                         

                        Dim My_App       ' The application

                        Dim My_Board     ' The Board

                        Dim Gui

                        Dim BindMenu

                        Dim BindAccelerator

                        Dim BindCommand

                        Dim keyBindTables

                         

                        Set My_App = Application

                        Set My_Board = My_App.ActiveDocument

                        Set Gui = My_App.Gui

                         

                        BindMenu = 0

                        BindAccelerator = 1

                        BindCommand = 1

                         

                        Set keyBindTables = Gui.Bindings("Document")

                         

                        'align_differential_pins

                        keyBindTables.AddKeyBinding "a", "run X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\VX_.2.1\2_PCB_Layout\Hotkeys\align_differential_pins.vbs", BindCommand, BindAccelerator

                        keyBindTables.AddKeyBinding "A", "run X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\VX_.2.1\2_PCB_Layout\Hotkeys\align_differential_pins.vbs", BindCommand, BindAccelerator

                         

                        'select entire net

                        keyBindTables.AddKeyBinding "`", "run X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\VX_.2.1\2_PCB_Layout\Hotkeys\select_entire_net.vbs", BindCommand, BindAccelerator

                         

                        'select entire net and lock it

                        keyBindTables.AddKeyBinding "Ctrl+1", "run X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\VX_.2.1\2_PCB_Layout\Hotkeys\select_entire_net_and_lock.vbs", BindCommand, BindAccelerator

                         

                        'lock selected

                        keyBindTables.AddKeyBinding "Ctrl+`", "run X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\VX_.2.1\2_PCB_Layout\Hotkeys\lock_selected.vbs", BindCommand, BindAccelerator

                         

                        'unlock selected

                        keyBindTables.AddKeyBinding "3", "run X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\VX_.2.1\2_PCB_Layout\Hotkeys\unlock_selected.vbs", BindCommand, BindAccelerator

                         

                        'select entire net and unlock it

                        keyBindTables.AddKeyBinding "Ctrl+3", "run X:\ENG\LIBRARY\RELEASED\Mentor\Scripts\VX_.2.1\2_PCB_Layout\Hotkeys\select_entire_net_and_unlock.vbs", BindCommand, BindAccelerator

                         

                        Each of the .vbs files the hotkey lines point to is a normal vbscript automation file that the Mentor tools can run.  Some of them start other executables I have made in vb.net. 

                         

                        I use lots of hotkeys, as for me it is much faster to press a key on the keyboard than to press a button on the toolbar or go through a set of menus.  All of my most commonly used commands, functions, and automation tools are set up on hotkeys, so that while doing work on placement or routing, I rarely use a menu or toolbar button.  I have made a cheat sheet I have taped to my monitor with all the hotkeys and what they do listed out, so that if I forget what key does what I can quickly look and remind myself.

                         

                        Take note - the hotkeys are case sensitive.  That's why for some I have both the upper and lower case letter assigned to the same function, so that it works the same if I have caps lock on or off.

                        1 of 1 people found this helpful
                        • 9. Re: How to add my script in to my Expedition menu
                          guyjj

                          I downloaded the Automation Manager and initially set it
                          to save to a “script” folder on my desktop.  Now that I have it working I
                          want to save it to a network folder for everyone to use.  I keep trying to
                          change the environmental  variable to a different location but it keeps
                          looking at my desktop.  It also has deleted scripts from the folder.
                          The scripts.ini file in the WIDR folder hasn’t been touched.

                          How do I set up Mentor for all users to have the added menu item in Expedition?