Search code examples
autolisp

AutoCAD Lisp hook up help function to show Youtube video


I'm having trouble hooking up the F1 help function in AutoCAD Lisp with a custom Youtube video instead of showing the default AutoCAD Help files. I've found this article to be quite helpful, but it won't allow me to supply a youtube video in any way.

The custom AutoCAD browser is too old and does not support HTML5 (which is needed to run Youtube videos). Any help on how to solve my issue?

Case: How to bind the F1 help to a custom function in AutoCAD Lisp, then activate a Youtube clip on F1 keypress.


Solution

  • After a while, I got it all figured out. I had to use a combination of HTML/Javascript to trigger the default web browser (which hopefully supports HTML5), and then view the Youtube clip there:

    Lisp:

    (setfunhelp "C:MyFunction" "C:\\path\\to\\html\\file\\MyFunc_Help.html")
    (defun C:MyFunction ()
      (alert "this is my function")
    )
    

    HTML:

    <html>
        <body>
        <script>
        function OpenInNewTab(url, callback) {
          var acWindow = window.open("", "_self");
          acWindow.document.write("");
          setTimeout (function() {acWindow.close();},500);
    
          var newWindow = window.open(url, '_blank');
          newWindow.focus();
        }
        OpenInNewTab("https://youtu.be/FERNTAh5s0I");
        </script>
        </body>
    </html>
    

    This HTML code opens a new browser window in your default browser, then closes the AutoCAD default browser after 500 milliseconds.

    I hope this will be of help to someone.