Back

AutoLISP: Free Samples, The Spring Edition

Spring Cleaning

Spring!!! This is the time when snow starts to melt, daylight lasts longer, everything starts to grow and come back to life. This is also when the popular phrase "Spring Cleaning" comes to mind. Now is the time to dive into those closets, find clothes you no longer wear or shoes that no longer fit and have a yard sale. Or dig through your garage, discover all those items you no longer need or want and just throw them out. After all, you do need to make room so you can get more new stuff!!!

Free Stuff

Well, this is also a great time to open up and dig through the AutoCAD program folder looking for all the free stuff that comes with the program. Last year I started this new series called Free Samples. In these articles I review the many open source lisp programs that come packaged with AutoCAD free for the taking. This time I'm going to continue the Free Samples series by focusing on four open-source lisp routines that were introduced with AutoCAD R12. This was the release when AutoCAD introduced customizable dialog boxes with the use of dialog control language (dcl) making user input dramatically easier than before. Like my previous Free Samples articles, I'll introduce the lisp command, explain what it does and discuss what came of it as AutoCAD continues to develop after another 12 releases to the current version.

1. Appload

In 1992 when Microsoft’s Disk Operating System (DOS) was still king and only a single program ran effectively at a time, it was quite a challenge to look for and correctly type in a filename to successfully load an add-in into AutoCAD. There was no option to open another program like Windows Explorer to drag and drop the add-in file into the AutoCAD drawing window for loading. So, AutoCAD R12 came with a new lisp and dcl function called Appload (see Figure 1).

The Appload command opens a custom dialog box titled “Load AutoLISP, ADS and ARX Files.” The dcl code implements the following:

  1. List Box – showing files previously selected for loading
  2. Buttons – to select more files to Load/Unload or Remove current files from the list
  3. Toggle Button – that saves changes made to the current list

This was a tremendous time saver for users who needed a simple but effective way to selectively load add-ins while working in AutoCAD.

Unfortunately, the free open source Appload lisp and dcl files were short lived. They were only included in two more AutoCAD releases (R13 & R14). By the time AutoCAD 2000 came out Autodesk chose to compile the Appload code into a single AutoCAD Runtime Extention (arx) file. The newly compiled Appload.arx file now offers a lot more features and functions (see Figure 2).

The more powerful Appload command now presents a window titled “Load/Unload Applications” that combines a File List on top with a columned style List Box showing add-ins that have been loaded on the bottom. In addition, there’s a Startup Suite Contents button that launches a separate window to add files to automatically load each time a drawing session opens. Appload.arx has been so effective with these added features that it has continued to accompany AutoCAD releases since 2000 to the current AutoCAD version today.

2. DDModify

AutoCAD’s LIST command back in the DOS days was used quite often to get property information on an object drawn. With this command users can see the object’s Type, Layer, Color, Linetype and etc. (see Figure 3).

But unfortunately, there wasn’t an option to make any changes to the listed properties. This once again prompted Autodesk to add this needed feature into AutoCAD R12.  With the implementation of lisp and dcl AutoCAD R12 came with a newly added function called DDModify (see Figure 4)

Similar to the LIST command, DDModify retrieves the properties of an object (Type, Layer, Color, Linetype and etc.) and displays them in a custom dialog box. With the click of a Button additional options are displayed for changes. Also Edit Boxes are implemented to show the current value for modification.

But one of the drawbacks of DDModify was that it did not offer the option to display Attributes within Blocks for modification. So, I decided to create a new function (based on DDModify’s lisp and dcl code) called DDAttMod. This command is included in my free TextApps add-in and can be downloaded from the Autodesk App Store (see Figure 5).

In addition to implementing Buttons, Toggle Buttons and Edit Boxes I included with DDAttMod an Image Tile to display a preview of the Attribute’s Justification. Also, since AutoCAD’s Color selection window was just way too small, I used lisp and dcl code to generate a larger Color selection window with the use of Image Buttons (see Figure 6).

Like Appload, DDModify lisp and dcl files continued to ship with AutoCAD for two more releases (R13 & R14). Then AutoCAD 2000 came out implementing the new “Heads-Up Design Environment” and “Improved Access and Usability”. Unlike the previous dcl custom dialog boxes, the new and improved graphics user interface offered both floating and docked windows. AutoCAD used this new feature to replace the DDModify command with the new Properties command. The Properties command opens up a window that can float or dock showing items that can be changed with the use of Drop-down Lists or Editable Fields (see Figure 7).

Though the DDModify code still can be loaded and run successfully even in the current version of AutoCAD, there’s been no updates to include the many improvements added since AutoCAD R14. Also, once you become accustomed to using the Properties window, there’s little incentive to go back to using the DDModify command. For backwards compatibility, AutoCAD since release 2000 has included an alias in the acad.pgp file so that when DDModify is entered the Properties window appears.

3. DDOsnap

AutoCAD introduced object snaps back in version 2.0. When used properly, object snaps are one of the major features that gives the AutoCAD user accuracy throughout the entire drawing process. Different object Types possess their own object snap settings. This makes it possible for you to locate and position objects exactly where you want them to be. For example, note the LINE, CIRCLE and TEXT object snap modes (see Figure 8):

A.    LINE objects contain two object snap modes:

1.    ENDpoint – this is located at each end of the LINE segment

2.    MIDpoint – this is located in the middle between the two end points

B.    CIRCLE objects contain the following two object snap modes:

1.    CENter – this is located at the center of the CIRCLE

2.    QUAdrant – this is located on the CIRCLE at the following angles: 0⁰, 90⁰, 180⁰ and 270⁰

C.    TEXT objects contain only one object snap mode:

1.    INSertion – this is also known as the TEXT’S Justification location (see Figure 9)

As you can see though TEXT only has one object snap setting, there are a number of locations where this can occur on the object.  Since there are so many TEXT justification options and I really wanted to get a visual of where they’re located, I created a command packaged as part of TextApps I call DDTxtJus. Similar to DDAttMod, DDTxtJus is a lisp function that uses dcl to create a custom dialog box to show the various TEXT justification options in a List Box. The selected option automatically changes the picture shown in the Image Tile giving the user a preview of where the INSertion position is located (see Figure 10).

The INSertion object snap setting also applies to BLOCK objects and there is one more object related object snap setting called NODe which applies to POINT objects. The rest are geometry related object snap settings: INTersection, PERpendicular and TANgent.

Note: I would avoid the use of the NEArest object snap setting because you can end up with inaccurate drawings where objects are placed close but not exactly where they should be.

All these object snap settings can be entered at the command prompt in the middle of drawing or editing commands. Or with the use of the OSNAP command permanent object snaps can be set for the entire drawing session (a.k.a. “running object snaps”). Furthermore, object snap settings can be combined together by entering them at the command prompt separating each with a comma. For example, to set ENDpoint, MIDpoint, CENter and INTersection as running object snaps, the following is entered at the command line:

Command: Osnap

Enter list of object snap modes: END,MID,CEN,INT

Notice that only uppercase letters are required to be entered. But what if you changed your mind and now want to include TANgent. You would have to enter the entire list again before adding the new TANgent object snap. Likewise, if you want to remove an object snap setting from the list, you will have to again re-enter all the object snap settings you want to keep. On top of all that the object snap settings even the shorter uppercase letters need to be entered and spelled correctly otherwise AutoCAD will reject the entry.

All of these drawbacks prompted Autodesk to introduce with AutoCAD R12 the new lisp combined with dcl command called DDOsnap (see Figure 11).

DDOsnap opens a custom dialog titled “Running Object Snap” and effectively implements Toggle Button combinations to select and unselect running object snap settings. In addition, at the bottom of the dialog box was an option using an Image Tile and a Slider Tile to adjust a related drawing tool called the Aperture Size.  The Aperture setting (ranges from 1 to 50 pixels) changes the "Target" crosshairs size affecting the area and location where object snap settings are scanned. So, an Aperture setting of 1 would result in a very small area where the crosshairs are scanned. On the other hand, an Aperture setting of 50 would result in a much larger crosshairs area to be scanned during the object snap selection process (see Figure 12).

Unlike Appload and DDModify, the DDOsnap lisp and dcl files were kept for only one more AutoCAD release (R13). AutoCAD R14 introduced a built-in DDOsnap command that displayed a custom Osnap Settings dialog box with the introduction of Tabs. Also added is a Clear All Button and a Slider Tile with a brand-new look (see Figure 13).

This was also short lived because AutoCAD 2000 completely revamped the DDOsnap command yet again. The command is now replaced by just entering the Osnap command or the DSettings command. The newer graphics user interface would now display the Drafting Settings window (see Figure 14).

In addition to adding a couple more Toggle object snap settings a Select All Button is now clustered with the Clear All Button at the upper right corner of the window. The Aperture Size setting at the bottom is completely dropped. Instead, a separate Options Button is added at the lower left corner to call up the Drafting Tab to make Aperture Size and other drawing environment changes. Lastly, to invoke the original command line version of Osnap the command would need to be preceded with a dash:

Command: -Osnap

So, having gotten used to running the DDOsnap command for three AutoCAD releases (R12, R13 & R14) and for the sake of backwards compatibility like with DDModify, the current AutoCAD release still continues to support the DDOsnap command. AutoCAD’s acad.pgp file includes an alias that calls up the Drafting Settings window which now shows even more Tabs and object snap settings (see Figure 15).

4. DDVpoint

Starting with release 2.18 AutoCAD slowly began the introduction of offering not only 2 dimensional (2D) but also 3 dimensional (3D) drafting tools. During this small step forward, most objects can be given a thickness but with no top or bottom surfaces. Only the Solid (2D) object Type when given a thickness would have surfaces on all six sides. All objects could be positioned in a different elevation other than the zero-elevation plane. For setting up 3D views AutoCAD added the new VPOINT command. The Vpoint command gives the user the option to respond with X,Y,Z coordinates rotating on the 2D (X,Y axis) plane and upward to look from a 3D (Z axis) direction. But the Vpoint coordinate entry process was quite cumbersome. You would have to remember the X,Y,Z coordinate entry sequence precisely in order to achieve the desired view or rely on selecting these coordinates from the AutoCAD on screen menu (see Figure 16).

A second method to respond to the Vpoint command instead of entering X,Y,Z coordinates is to hit the Enter key on the keyboard. This would make all the objects temporarily on the graphics drawing area disappear and allow you to freely rotate around the X,Y,Z axis using this tripod symbol as a navigational device (see Figure 17).

But this method of setting a 3D view with the Vpoint command lacked control. Also, the view is set blindly since no objects are displayed on the screen but the tripod symbol.

Since both of these Vpoint command entry methods have their drawbacks, AutoCAD R12 introduced the highly needed lisp and dcl command DDVPOINT. The DDVpoint command uses the third VPoint entry method which is based on the Rotation angle on and from the X,Y plane. DDVpoint’s custom dialog box displays a simple and yet very effective Vpoint Rotation angles selection process (see Figure 18).

At the center of the “Viewpoint Presets” dialog box is a large Image Button that’s basically divided into two sections. The left section shows an image for selecting the Rotation angle on the X,Y plane. Clicking on any of the angles labelled around the outside of the circle would return the angle matching those numbers. Clicking on areas inside the circle would return an angle that is an extrapolation of the angles in between. Similarly, the right section shows an image for selecting the angle above and below the X,Y plane. Clicking on the area between the trapezoidal shapes would return the matching labelled angle. Clicking on the area inside the inner arc would result in an extrapolation of the angles in between.

The DDVpoint custom command provided a very effective frontend graphic user interface solution to setting 3D views. The lisp and dcl files continued to be shipped with AutoCAD for five more releases (R13, R14, 2000, 2000i & 2002). Finally, AutoCAD 2004 incorporated DDVpoint as part of the built-in native AutoCAD command dropping the need for the custom DDVpoint lisp and dcl files (see Figure 19).

Autodesk purposely designed the dialog box to display the same look and feel as the previous custom DDVpoint command. The major differences are:

  1. Addition of the AutoCAD logo on the title bar
  2. White background to the Image Button
  3. Shorter Set to Plan View Button at the bottom

Like with the Osnap command eventually the Vpoint command took the place of displaying the dialog box. To invoke the command line version this required a dash to precede the command:

Command: -Vpoint

But the effectiveness of the Vpoint command quickly faded with AutoCAD 2009’s introduction of the ViewCube. This resizable icon can be positioned in any one of the four corners of the graphics drawing area. The ViewCube could be easily toggled on or off by invoking the command NAVCUBE. Clicking on any part of the ViewCube would change the view on the screen to match (see Figure 20).

Since all six surfaces of the ViewCube are labeled with TOP, BOTTOM, FRONT, BACK, LEFT and RIGHT, clicking on a surface would immediately set that as the 2D view. Clicking on any of the corners would change the view to a 3D isometric view. Now setting the desired view can easily be done without the need to temporarily hide drawn objects and you won’t have to deal with dialog boxes obstructing the graphics drawing area.

From 2.18 to now after many releases later AutoCAD has clearly developed into a fully functional 3D design program. Throughout this growth process, AutoCAD has introduced many powerful tools to assist the user in setting up the 3D environment. But like Osnap, the traditional Vpoint command continues to be available to execute in AutoCAD. Also, DDModify and DDOsnap AutoCAD’s acad.pgp file has kept an entry for DDVpoint to invoke the Vpoint dialog box.

Spring into Action

So, each of the four lisp and dcl custom commands released with AutoCAD R12 had their own unique though sometimes similar developmental cycles. I’ve placed in a table summarizing the process (see Figure 21).

Hopefully I’ve again piqued your interest on the many free sample lisp files available from previous up to the current version of AutoCAD. At the time this article is published, the next AutoCAD has either already been released or is just about to come out. After installation, this is the perfect time to crack open the AutoCAD 2025 program folder. Instead of “Spring Cleaning” let’s “Spring into Action” and eagerly go through all the free sample lisp files that are now waiting to be discovered in the new AutoCAD 2025.

Appears in these Categories

Back