Send Multiple Commands to AutoCAD LispTips

Click on interface elements to find out more about them

 This image is a clickable map.
You can click on various LispPad interface elements to find out more about them.

Introducing LispPad

LispPad is a small, fast, highly-specialized code editor for AutoLISP and Dialog Control Language (DCL) development, and other related AutoCAD customization tasks. LispPad was originally designed for my own personal use, with the goal of streamlining common programming chores and eliminating many repetitive activities associated with loading and testing AutoLISP and DCL code

LispPad achieves its goal via a highly-specialized interface and tight intergration with AutoCAD, using asynchronous Dynamic Data Exchange and Windows messaging. This combination results in a highly-focused, task-oriented tool which fully-automates the repetitive actions commonly performed within the "edit/save/load/test/debug" AutoLISP and DCL coding cycles, effectively reducing them to nothing more than a mouse click.

Optimized for AutoLISP and DCL

LispPad operates in a manner that is largely consistent with Microsoft Notepad and most other Windows-based editors. It provides all of the same basic functionality as those tools, and adds many functions specifically designed for editing, testing, and debugging AutoLISP and DCL code.

With most normal editors not specifically designed for AutoLISP code editing, you must perform the following steps every time you want to test the code you are developing:

LispPad eliminates all of these steps by automatically loading the current selection, or the entire contents of the editor buffer directly into AutoCAD with nothing more than a single keystroke or button-click. LispPad can also simplify the creation, editing, testing, and debugging of menu macros, script, and DCL files.

The first time you launch LispPad, the license agreement appears, and you are required to read it in its entirety, and confirm your acceptance of the terms and conditions of the License Agreement by pressing the Accept button.

LispPad Features

The following is a brief explanation of prominent LispPad features which are accessed via user-interface elements.

 

Load as Lisp

When you click on this button, the entire document (or the currently selected text) is loaded into AutoCAD as AutoLISP code, and the AutoCAD window is brought to the top and given focus. If there is no selection the entire document is loaded. Using this button is the same as saving the contents of the editor to a file, switching to AutoCAD, and issuing (load "filespec") to load the saved file. You can also access this function by pressing CTRL+L.

Paste To AutoCAD (Load as Script file)

When you click on this button, the entire document or current selection is sent directly to AutoCAD's command line as keyboard input. Doing this is similar to saving the document or selection to a file with an SCR extension and executing it using the AutoCAD SCRIPT command. This is useful for testing programs that request input, and for writing and testing script files on the fly. You can also access this function by pressing SHIFT+CTRL+ENTER.

LispTips

LispTips are real-time tooltips that display the calling syntax of built-in and user-defined AutoLISP functions. Simply move the arrow cursor over the name of a built-in or user-defined function, and its calling syntax instantly appears as a tooltip.

Goto Definition

When editing AutoLISP files, this drop-down list displays the names of all user-defined functions or variables in the current document; and allows you to go to the definition of a function, or the assignment expression of a variable by selecting the function or variable name from the dropdown list. Push the 'F' button to list functions, or the 'V' button to list variables. The only variables that appear are those assigned via SETQ.

When editing DCL files, this same drop-down list displays the names of all dialogs defined in the DCL file, or the key attribute values of all tiles in the DCL file, and positions the caret at the definition of a dialog or tile key attribute assignment when either is chosen from list. Push the 'D' button to list dialog boxes, or the 'K' button to list tile key attributes.

LispPad Dialog Box Preview

LispPad's interactive DCL dialog preview function makes designing and testing dialog boxes a breeze.When editing DCL code, LispPad can display a dialog box that's defined in a DCL file currently open in the editor, by simply clicking a button.

To better understand how much easier dialog box design is with LispPad, try the following exercise:

InstructionEffect
Launch AutoCAD for Windows and LispPad
In LispPad, Open the file DDIM.DCL (which can be found in the AutoCAD common support directory).Loads DDIM.DCL into LispPad
From the Goto Definition dropdown list, choose the ddimx_geometry dialog. LispPad will scroll to, and put the caret on the first line of the ddimx_geometry dialog's definition
Press the Test Dialog Box button.The Test Dialog button goes down, the AutoCAD window is minimized, and the ddimx_geometry dialog appears
Position both the ddimx_geometry dialog and LispPad window on the desktop to eliminate or minimize window overlap.If using a smaller display format, you can reduce the size of the LispPad editor window as needed to eliminate or minimize window overlap.
From the Goto Definition dropdown list, choose the ddimx_annotation dialog The ddimx_geometry dialog closes, LispPad scrolls to the first line of the ddimx_annotation dialog's definition, and that same dialog appears.
Go to the button definition shown to the right, (which is within the ddimx_annotation dialog definition)
: button {
    fixed_width = true;
    label = "&Units...";
    key = /*MSG0*/"annot_unitsp";
} 
Change the value of the label attribute in the code shown above from "&Units..." to "&Linear Units...", so the button definition appears exactly as shown to the right.
: button {
    fixed_width = true;
    label = "&Linear Units...";
    key = /*MSG0*/"annot_unitsp";
} 
Press CTRL+L.The ddimx_annotation dialog will momentarily disappear and reappear.

Note that the revision you have just made to the button is now reflected in the dialog!

Press the Test Dialog Box buttonThe Test Dialog Box button comes up and the ddimx_annotation dialog closes.
Close LispPad (DO NOT SAVE CHANGES TO DDIM.DCL!), Close AutoCAD.

When you open a DCL file in LispPad and display a dialog, you can then repeatedly edit the dialog's DCL code in LispPad, and view the effects of the changes immediately (without having to save the DCL file), by simply pressing CTRL+L while the caret is within the dialog's definition in the editor. To dismiss a visible dialog, just press the Test Dialog Box button again.

Select List

This button will select a list or complex expression by extending the start and end of the selection highlight to the nearest pair of matching parentheses that encloses the caret. After selecting a list, you can progressively select each of its enclosing or "parent" lists by repeatedly clicking the same button until you've selected a top-level list. You can also access this function by pressing ALT+L.

Find Matching Parentheses

This button will move the caret to the parenthesis, square bracket, or curly brace that matches or balances with the one at the caret location. This makes it easier to find the start or end of a list or expression from either of its enclosing parentheses. You can click the button repeatedly to jump between the open and close parentheses surrounding an expression. You can also access this function by pressing CTRL+M.

Quick Find Control

This control consists of four buttons that resemble the controls on a VCR, and a combo box.

Rather than having to display a dialog box to find text in the document, you can type it into the combo box, and then press ENTER to find the next occurrence of .the search text. The buttons allow you to find the first, last, previous, and next occurrences of the search text, respectively. The combo box holds a history of all text searched for in the current session, any of which can be restored by selecting it from the drop-down list. This function can also be accessed by pressing CTRL+F. The Find Next and Previous button functions can also be accessed by pressing ALT+N and ALT+P, respectively.

Dynamic Parentheses Counter

This pane on the status bar at the bottom of the window, dynamically shows the difference between the total number of open and closed parentheses in the current selection or the entire document when nothing is selected. When the parentheses in the selection or document are balanced, the contents of this pane will read (=), meaning that there are an equal number of open and closed parentheses. If the parentheses in the selection or document are not balanced, the value in this pane will begin with either an open or close parenthesis, a plus sign, and a number that represents the difference between the number of open and close parentheses in the document. For example, if there are 30 occurrences of "(" and 28 occurrences of ")" in the current document or selection, the contents of the pane will be (+2. If there are five missing open parentheses in the selection or document, the contents of the pane will be )+5.

Send Line

You can send the contents of the editor line that the caret is currently on directly to AutoCAD's command line by choosing CTRL+ENTER or by selecting Send Line from the editor shortcut menu.

Dynamic Syntax Display

This panel, located directly above the status line at the bottom of the window, provides a dynamic, real-time quick-reference of the calling syntax of built-in AutoLISP functions, as well as user-defined functions that are defined in the current file.

When you position the cursor over, or enter the name of a user-defined or built-in function, the calling form or syntax of the function appears on the Syntax Display Panel. Arguments are italicized, and optional arguments are surrounded by square braces.

The Favorites Folder

This button and combo box allow you to quickly save selected text to a file, and easily paste it into the current document when needed. This control provides the equivalent of a persistent, multiple-object clipboard with entries that can be referenced by name. You can easily paste entries into the current document by selecting a name from the drop down list, or entering the name in the edit field.

Before can you use the Favorites function, you must first specify a folder where the files will be placed:

  1. From the Lisp, Favorites menu choose "Folder..."
  2. Select a folder (directory).

Once you do this, you can now save and restore frequently-used code snippets to/from files::

  1. In LispPad, Open a file.
  2. Enter and then select some text.
  3. In the Favorites combo box edit field, type a filename (don't include an extension).
  4. Press Enter, or click on the "Add Selection to Favorites" button.

The selected text is now saved in the favorites folder under the specified name, which will then appear on the dropdown list. To paste a favorites entry into the current document (replacing any currently selected text), just choose the name of file from the Favorites drop down list, or type its name in the edit box and press Enter.

Drag and Drop

LispPad supports drag and drop editing within the editor, across several instances of LispPad, and onto the AutoCAD window. You can drag and drop the current selection to a different place in the current document, or a document in another instance of AutoCAD (the default behavior moves the text to the dropped location, hold down shift to copy the text to the dropped location). You can also drag and drop the current selection onto the AutoCAD window, which causes AutoCAD to load the selection, as if you had pressed Ctrl+L.

Command Line

This combo box at the bottom of the window can be used to send multiple commands to AutoCAD's command line, providing a convenient way to test AutoLISP programs loaded directly from the editor. By entering the commands needed to test a program into edit box, you can send them to AutoCAD any number of times by clicking the button to the left of the control. The drop down list stores a history of all command strings that are sent to AutoCAD in the current session, allowing them to be recalled, edited, and resent.

Context Menu

The right-click editor context menu changes, depending on what type of object the caret is over (types of objects include the names of built-in or user-defined AutoLISP functions and variables; AutoCAD commands and system variables; files and URL's), as described in the following table.

Object at Caret

Object-specific Context-menu Items

A symbol assigned to a built-in AutoLISP functionA menu item that opens help for the built-in AutoLISP function..
A symbol assigned to a user-defined function (defined in current document)A menu item that jumps to the definition of the user-defined function.
A symbol assigned to an AutoLISP variable (assigned in the current document with SETQ)A menu item that jumps to the assignment expression of the variable.
The name of a DCL dialog boxA menu item that jumps to the definition of the dialog box.
The name of an existing file.A menu item that opens the file (using the application associated with the type of file).
The name of an AutoLISP fileA menu item that loads the AutoLISP file into AutoCAD.
The name of a built-in AutoCAD command or system variable.A menu item that opens AutoCAD help for the command or system variable.
An Internet URL (Uniform Resource Locator)A menu item that opens the URL in your installed web browser

Additional Functions

Smart Comments

Smart comments automatically repeat when you press ENTER at the end of a line that begins with one or more comment delimiters (the semi-colon). Each time you press ENTER on a line that starts with one or more comment delimiters, the delimeters are copied to the new line inserted immediately below the current line. Any whitespace before and after the comments are also repeated, if Smart Indent is enabled.

Smart Indent

Smart indent automatically duplicates leading whitespace from the current line, on the new line inserted when you press enter. In addition, one tab is added to or removed from the new line for each unmatched open or close parenthesis on the current line, respectively.

Pricing and Availability

The 16-bit standard edition of LispPad is currently under development, along with a professional edition that supports even more powerful features like syntax colorization and unlimited file sizes. A special Limited Edition of LispPad is currently shipping with the book Maximizing AutoCAD R13, and the soon-to-be published Maximizing AutoLISP R13. When the standard edition is released, there will be announcements and ordering information posted here and on the Usenet.

The newly-relased book Maximizing AutoCAD R13 includes a limited edition of LispPad, You can obtain Maximizing AutoCAD at most major book store chains, or directly from Delmar/Autodesk Press by calling 1-800-347-7707 and asking for ISBN 0-8273-7993-5. You may also fax orders to 606-647-5023 (include the ISBN # above, title, author, credit card number and expiration date, phone number, and ship-to address).

More information about Maximizing AutoCAD R13 can be found at the Group A Home Page

Top

local xarch copy