Quantcast
Channel: Mentor Graphics Communities: Message List
Viewing all articles
Browse latest Browse all 4541

Re: Key Binding on PlaceMode, RouteMode and Draw Mode.

$
0
0

Hi,

 

You can run those commands by using the command ID (Call pcbAppObj.Gui.ProcessCommand(CommandId,True))
It seems though that .AddKeyBinding does not support running a commandID but you can bind to a script that runs Gui.processcommand(..)

 

Script to toggle hover snap mode:

 

'-------------------------------------------------------------------------
'Internal script connect to expedition pcb and get pcbAppObj and pcbDocObj
'-------------------------------------------------------------------------
Dim pcbAppObj                'Application object
Dim pcbDocObj                'Document object
Scripting.AddTypeLibrary("MGCPCB.ExpeditionPCBApplication")

' Get the application object.
Set pcbAppObj = Application

' Get the active document
Set pcbDocObj = pcbAppObj.ActiveDocument

' License the document
ValidateServer(pcbDocObj)
'-------------------------------------------------------------------------

 

'call GetToolbarCommandId("Snap",5) 'get command id to enter in code

Call pcbAppObj.Gui.ProcessCommand(59417,True)

 

'=============================================================
Function GetToolbarCommandId(ToolbarName,ButtonLocation)
'=============================================================

Dim stdToolBar : Set stdToolBar = Gui.CommandBars(ToolbarName)

      if stdToolBar is nothing then
          Msgbox "Could not find '" & ToolbarName & "' toolbar.",0+16
      else

          dim stdTBCtrls : Set stdTBCtrls = stdToolBar.Controls

          if stdTBCtrls is nothing then
               Msgbox "Error getting controls on '" & ToolbarName & "' toolbar.",0+16
          else

               for i = 1 to stdTBCtrls.count

                    if i = ButtonLocation then
                         msgbox stdTBCtrls.item(i).id
                         exit for
                    end if

               next
          end if
      end if

end function
'=============================================================

 

'=============================================================
' Validate server function
'=============================================================
Private Function ValidateServer(doc)

    Dim key, licenseServer, licenseToken

    ' Ask Expedition’s document for the key
    key = doc.Validate(0)

    ' Get license server
    Set licenseServer = CreateObject("MGCPCBAutomationLicensing.Application")

    ' Ask the license server for the license token
    licenseToken = licenseServer.GetToken(key)

    ' 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(licenseToken)
    If Err Then
        ValidateServer = 0
    Else
        ValidateServer = 1
    End If

End Function
'=============================================================


Viewing all articles
Browse latest Browse all 4541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>