AnsweredAssumed Answered

Old script load very slow in VX

Question asked by eng.same.tan on Jun 15, 2017
Latest reply on Jun 21, 2017 by kendall_hiles

First, I did ask someone help me to write a script for me so when I press keyboard and it will automatically load specific scheme that I saved for me.

And I also can create my own shortcut key for certain option instead to access from the menu.

But after migrate to VX, when I hit my shortcut key, the scheme under display control took about 2 seconds to load which is slow for me.

Just wondering is anyone here can help me to review on the script as below is there any wrong on the script that need to update for VX?

There is no delay time when I used this script in EE7.9.5.

Really hope someone can help me on this, appreciate and thanks.

 

 

Below are some examples:

' -------------------------------------------------------------------------------

Option Explicit

Dim My_App       ' The application

Dim My_Board     ' The Board

 

Set My_App = Application

Set My_Board = My_App.ActiveDocument

' Add the new key binding.

 

  keyBindTables.AddKeyBinding "CTRL+SHIFT+Q", "Edit->Modify->Padstack Processor", BindMenu, BindAccelerator

  keyBindTables.AddKeyBinding "CTRL+SHIFT+W", "Route->Assign Net Name", BindMenu, BindAccelerator

 

  keyBindTables.AddKeyBinding "CTRL+SHIFT+A", "run C:\WDIR\Scripts\displaycontrol.vbs ""Loc: ALL_ON""", BindCommand, BindAccelerator

  keyBindTables.AddKeyBinding "CTRL+SHIFT+Z", "run C:\WDIR\Scripts\displaycontrol.vbs ""Loc: ALL_Off""", BindCommand, BindAccelerator

 

  keyBindTables.AddKeyBinding "CTRL+UP", "ms dx=0,0.5", BindCommand, BindAccelerator

  keyBindTables.AddKeyBinding "CTRL+DOWN", "ms dx=0,-0.5", BindCommand, BindAccelerator

' -------------------------------------------------------------------------------

 

 

Scrip for "displaycontrol.vbs":

 

Option Explicit

 

Dim scriptArgsObj, pcbAppObj, pcbDocObj, viewsColl, viewObj, schemeStr

 

Set scriptArgsObj = ScriptHelper.Arguments

schemeStr = scriptArgsObj.Item(3)

 

Set pcbAppObj = Application

Set pcbDocObj = pcbAppObj.ActiveDocument

 

If ValidateServer(pcbDocObj) = True Then

    Set viewsColl = pcbDocObj.Views(epcbViewDefaultView)

    For Each viewObj in viewsColl

        Call viewObj.DisplayControl.LoadScheme(schemeStr)

        Exit For

    Next

End If

 

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

' Function that returns a licensed doc object

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

Function ValidateServer(doc)

  Dim keyInt

  Dim licenseTokenInt

  Dim licenseServer

 

  'Ask Expedition's document for the key

  keyInt = doc.Validate (0)

 

  'Get license server

  Set licenseServer = CreateObject ("MGCPCBAutomationLicensing.Application")

 

  'Ask the license server for the license token

  licenseTokenInt = licenseServer.GetToken (keyInt)

 

  'Release license server

  Set licenseServer = nothing

 

  'Turn off error messages (validate may fail if the token is incorrect)

  On Error Resume Next

  Err.Clear

 

  'Ask the document to validate the license token

  doc.Validate(licenseTokenInt)

  If Err Then

  ValidateServer = False

  Else

  ValidateServer = True

  End If

End Function

Outcomes