Wednesday, July 11, 2012

Calling External Applications from AutoCAD/LT

While AutoCAD/LT is running, you can invoke (start) other programs or utilities such Windows system commands, utilities, and applications: the coding is simple and coded in the same file that AutoCAD/LT uses to read those command shortcuts we all use instead of typing full command names, the ACADLT.PGP file (for AutoCAD users, it's the ACAD.PGP file).

You define external commands by specifying a command name to be used from the AutoCAD command prompt and an executable command string that is passed to the operating system. By default, defined in the acadlt.pgp file are three commands that work to call up a couple of the most common Windows based Applications. These commands are listed as follows.

EXPLORER - Launches a session of Windows Explorer
NOTEPAD - Launches a session of NotePad with file provided if one is given
PBRUSH - Launches a session Windows Paint (or Paintbrush).

The coding structure inside the PGP for these external commands are as follows:
,[],,[*],

Examples of external commands for Windows built into LT by default:
EXPLORER,  START EXPLORER, 1,,
NOTEPAD,   START NOTEPAD,  1,,
PBRUSH,    START PBRUSH,   1,,

What does all ths coding mean?
  • The first part represents the command name that you type in AutoCAD to execute the line of code.Feel free to abbreviate any of these to your preference, we show them with full names for clarity of this article.
  • The second part calls a defined command from earlier in the Acad.pgp file.  This command is used to launch an executable that is registered on the current system (basically, how Windows calls the command).
  • The third part is used to allocate memory.  This field is used maintains compatibility with previous versions of AutoCAD.  Typically the number zero is present.
  • The fourth part is used to display a prompt at the AutoCAD Command Line.  This field is optional to use and the response to this prompt is appended to the string supplied in the executable field. If the first character of the prompt field is an asterisk (*), the response can contain spaces and the user must press ENTER to terminate it.
  • The fifth part is an optional bit-coded parameter.  These codes can be added together in order to reach the desired results.
Here are examples of external commands from Windows we modified and added to LT. In these first to examples, we added additional prompts at the command line to prompt the user:
EXPLORER,  START EXPLORER, 1,*Directory to Start in: ,
NOTEPAD,   START NOTEPAD,  1,*File to edit: ,
 
Other examples of external programs to call from inside LT at the command line, or a menu/screen button:
EXCEL,    START EXCEL,   1,,
WORD,    START WINWORD,   1,,
POWERPOINT,    START POWERPNT,   1,,
WORDPAD,    START WRITE,   1,,
OUTLOOK,    START OUTLOOK,   1,,
 
What external programs would you find useful to call from inside LT?

Share/Bookmark