Command Watcher

Il command watcher permette di agganciare eventi Lua ai comandi di AutoCAD. Per esempio è possibile agganciare particolari funzioni alla partenza o chiusura del comando "TOP_USERLIBPERS" di TOP.

Esempio utilizzo Command Watcher.

local navigator = GetNavigator()
-- Usare cmdWatcherOff() per disabilitare il watcher
navigator:cmdWatcherOn()    
-- Usare cmdWatcherStop(cmdname) per smettere di controllare il comando cmdname
navigator:cmdWatcherStart("TOP_USERLIBPERS")  
-- Aggancia gli eventi
LuaAddEvent("OnCommandWillStart", function(cmdname)
  if strupr(cmdname == "TOP_USERLIBPERS") then
    alert("La libreria utente di TOP sta per partire!")
  end)
LuaAddEvent("OnCommandEnded", function(cmdname)
   if strupr(cmdname == "TOP_USERLIBPERS") then
     alert("La libreria utente di TOP è stata chiusa")
   end)
LuaAddEvent("OnCommandCancelled", function(cmdname) end)
LuaAddEvent("OnCommandFailed", function(cmdname) end)

Sono quattro gli eventi esposti dalle API: OnCommandWillStart, OnCommandEnded, OnCommandCancelled, OnCommandFailed. Per maggiori informazioni sugli eventi consultate il manuale ARX di AutoCAD.


Il funzionamento delle API relative al funzionamento del command watcher saranno illustrate nelle sezioni successive.

Created with the Personal Edition of HelpNDoc: Free help authoring tool