Help is commonly one of the last things that many new developers think about or never think about, but it should be one of the first things you work on as it is your first line of support for your custom utilities. AutoCAD provides ways for you to call a help topic or file, and hook up F1 support for your custom commands that you define with AutoLISP, .NET, or ObjectARX.
In this article, I focus on calling help and hooking up F1 support for commands defined using AutoLISP. To accomplish these tasks, you use the HELP and SETFUNHELP functions.
Both the HELP and SETFUNHELP functions support the use of HyperText Markup Language (HTM/HTML), Microsoft Help (CHM), and WinHelp (HLP) files. When you make a call to a HTM/HTML file, the file is loaded into the AutoCAD Help browser. CHM and HLP files are displayed in their respective application windows.
The syntax for the HELP function is:
(help [help_file [chm_hlp_topic [chm_help_window_command]]])
The following examples demonstrate how to directly call help from AutoCAD:
;; Displays the topic for the LINE command from the default AutoCAD help
(help "" "LINE")
;; Displays a Web page
(help "http://www.hyperpics.com/")
;; Displays a local HTML file
(help "C:\\Program Files\\Autodesk\\AutoCAD 2013 Help\\English\\Help\\index.html")
;; Displays a CHM file
(help "acet.chm" "html/BLOCKREPLACE")
Now that you have seen how to call help with the HELP function, the SETFUNHELP function is very similar with the exception of needing to provide the name of the function. The function name must include the 'c:' (command) prefix.
The syntax for the SETFUNHELP function is:
(setfunhelp c:function_name [help_file [chm_hlp_topic [chm_help_window_command]]])
The following examples demonstrate how to set up contextual/F1 help for custom commands:
;; Displays the topic for the LINE command from the default AutoCAD help
(defun c:CMD1 () (getstring "\nEnter some text: "))
(setfunhelp "c:CMD1" "" "LINE")
;; Displays a Web page
(defun c:CMD2 () (getstring "\nEnter some text: "))
(setfunhelp "c:CMD2" "http://www.hyperpics.com/")
;; Displays a local HTML file
(defun c:CMD3 () (getstring "\nEnter some text: "))
(setfunhelp "c:CMD3" "C:\\Program Files\\Autodesk\\AutoCAD 2013 Help\\English\\Help\\index.html")
;; Displays a CHM file
(defun c:CMD4 () (getstring "\nEnter some text: "))
(setfunhelp "c:CMD4" "acet.chm" "html/BLOCKREPLACE")
Once the command is defined and the Help topic is associated with the command, you can display the topic by pressing F1 under the following situations:
- When AutoComplete is enabled and the full name of the command is displayed, but the command is not started yet.
- When the command is active.
For more information on these two functions, see the following:
Sincerely,
Lee
Recent Comments