How to Use Autolisp at the Command Line to Remember the Selected Drawing Objects And Points

Monday, February 21, 2011
Ads


If are an ordinary autocad used user, chances are you are not familiar with Autolisp to automate autocad. I know you are probably a bit scared when someone talks about automation or programming. But hey give yourself a favor. I can tell that it's very easy and once you figure out what it does and how it helps you, I bet you'll keep asking for more.

Have you ever used the GROUP command in autocad to remember the objects you selected? There's actually a short line Autolisp code that can do this. This autolisp code does not only remember the selection of objects you selected but you can also refer back to the selection using a variable. In the command line, type in (setq h (ssget)) and then press enter. The letter h in the autolisp code above is the letter that refer to the selected objetcs. After you hit enter, autocad will prompt you to select the objects. So just select the drawing objects you want to remember and then press enter. Those selected objects are now in the autocad memory and when you need to select these objects automatically during the drawing session, this happens when you see the prompt Select Objects, just type in !h in the command prompt and press enter. The objects you selected will automatically highlight. Now, if you want to remember a point in autocad just type in this autolisp code (setq p (getpoint)) in the command line and press enter, then pick a point. If you want to recall the selected point, just type in !p. This is useful when you draw lines or circles. Type in the corresponding commands and when prompted to Select a point, simply type in !p and your line will drawn from that point or your circle will be centered on that point.

Ads