Search code examples
autocad-pluginautolisp

Does autolisp have a 'wait for x seconds'?


is there a way to make AutoLisp wait for X seconds (or milliseconds) before proceeding to the next line of code? I haven't found a function in the cad software I'm using (DraftSight 2023).


Solution

  • I might suggest the following to avoid unnecessarily calling the DELAY command repeatedly unless absolutely required -

    (defun sleep ( sec / cmd )
        (setq cmd (getvar 'cmdecho))
        (setvar 'cmdecho 0)
        (repeat (/ (fix sec) 32767) (command "_.delay" "32767"))
        (command "_.delay" (rem sec 32767))
        (setvar 'cmdecho cmd)
        nil
    )