CADTutor: The best free help for AutoCAD on the web

Michael BeallMichael’s Corner #110
February 2012

Gotta Love Shortcuts

by Michael Beall

It's February, and love is in the air. You may love Winter (no comment), love horses, love skiing, love your significant other, love to read, love to fly Southwest Airlines, etc., but I think we can all agree: We all love AutoCAD shortcuts.

This month I reached back into the Corner vault to solve a couple issues that happened over the last 48 hours in my training seminars, and created some shortcut solutions using Lisp routines. My Lisp knowledge is extremely limited, but the little bit that I know – and that I'm passing along to you - can be extremely powerful. So here's what's in store for February 2012…

…Creating and automating several one-line Lisp routines
…Toggling the Selection Preview setting when you rollover an object in the drawing
…A possible solution for the disappearing cursor
…The Command line version of the Purge command

Give these a shot and I think you'll LOVE leaving the office just a wee bit earlier!

If you would like to contact me directly, you can do that also.

Blessings to one and all,
Michael

Quick Lisps

Say that three times fast!

This month's Power Tool and Odd Sport articles each address circumstances where you need a temporary solution. Each solution could be automated by putting them on the Quick Access Toolbar or on your Tool Palette, but I wanted to change it up a bit and revisit how to create a one-line Lisp routine so you can just type the solution, not pick it.

The fundamentals of the following overview was originally posted 9 years ago(!) in Michael's Corner, February 2003, and can also be found in my book, The AutoCAD Workbench, beginning on page 203.

The example used here will incorporate the coverage of switching Visual Styles found in this month's Odd Spot article.

How to Write and Save a One-Line Lisp

  1. Open Windows Notepad (not Word, it puts hidden characters in the header and footer).

  2. First, it's always a good idea to identify what your routine is doing by adding a comment line at the beginning. Comment lines have a semi-colon as the first character on the line. Add something similar to the following as the first three lines in your notepad file.

    ; CADTUTOR February 2012 Lisp routines.
    ;
    ; Change Visual Styles. 2D Wireframe, 3D Hidden, & Realistic
  3. Add the following text as the fourth line. It's not case-sensitive and there is no preceding semi-colon:

    (DEFUN C:V2()(COMMAND "-VISUALSTYLES" "C" "2")(PRINC))

    Here's how all that stuff breaks down:

    (AutoCAD takes off if you hit the spacebar, so the first open parenthesis puts AutoCAD on 'hold'.
    DEFUNDEfine FUNction. You're telling the Lisp routine what you're setting up.
    C:The Command: line. The text that comes after C: is what you type to 'run' the Lisp.
    ()(The 'clutch'. Push it in ( change the gear ) let it out ( No options. Don't need to know.
    COMMANDFor all one line Lisps, you need to let AutoCAD know you are using Commands.
    "whattodo"All commands and options go in quotes. Yes, you can put a space between them.

    Many AutoCAD commands invoke dialog boxes or a drop-down panel, as found in Visual Styles. You will also find that many of those commands have a Command-line equivalent (which is necessary if you're going to key in the desired responses as we need to do in a Lisp routine). Commands launched with a leading hyphen display the options on the Command line. The equivalent for the Visual Style drop-down box is -VISUALSTYLES and you see the following option string:

    Enter an option [set Current/Saveas/Rename/Delete/?]: C
    Enter an option [2dwireframe/Wireframe/Hidden/Realistic /Conceptual/Shaded/shaded with Edges/shades of Gray/SKetchy/X-ray/Other]: 2
    "C"The option for 'set Current', as shown above.
    "2"The option for '2dwireframe', as shown above.
    (PRINC)Locking the door on the way out. Suppresses that 'nil' you see in some routines.
    )Resolve all the open parentheses.

    Here's what I put in my Notepad after the initial comment lines…

    ;
    (DEFUN C:V2()(COMMAND "-VISUALSTYLES" "C" "2")(PRINC))
    ;
    (DEFUN C:V3()(COMMAND "-VISUALSTYLES" "C" "3")(PRINC))
    ;
    (DEFUN C:VR()(COMMAND "-VISUALSTYLES" "C" "R")(PRINC))
  4. When you're finished adding your one-liners (you can have as many as you want, I would recommend comment lines between them, though), click FileSave, then navigate to AutoCAD's ..\Support folder.

  5. IMPORTANT: You must enter the file extension of .LSP after the filename, not Notepad's .TXT. I'll name this one CTFeb12.LSP.

As I mentioned, your .LSP file can contain as many one-liners as you want. I simply recommend you put comment lines in between each routine so you can reference it later and so it doesn't look so cryptic when you review it later.

How to Quickly Run a One-Line Lisp

  1. To test the routine created in the above exercise, open any AutoCAD and draw any non-orthogonal line, then draw a circle on one side of it.

  2. Open 'My Computer' (also called Windows Explorer) with Windows key + E.

  3. Navigate to where you saved your .LSP, then drag and drop it into the AutoCAD drawing window. You will see something like the following response on the command line:

    LOAD "C:/Program Files(x86)/Autodesk/ AutoCAD 2012-English/Support/CTFeb12.LSP")
  4. Drag and drop the lisp file

    To run your routine, enter VR (the text after DEFUN C: in your lisp file) and you should see your screen background change. If you have a 3D drawing open, you will see the drawing in the Realistic visual style. That's all there is to it!

Bonus Points

This month's Power Tool article addresses the toggling of the Selection Preview feature. The variable for that feature – as you will read, below – is SELECTIONPREVIEW. After reading the article, you should be able to add the necessary lines to your .LSP file to toggle on or off the Selection Preview feature at your leisure. I'll leave it to you to specify what follows the DEFUN C: to launch your options.

Launching Your LSP from the Startup Suite

LaunchIf you have a .LSP file containing routines that you want to have available whenever you open AutoCAD, add that file to the Startup Suite. On the Manage tabApplications panel you will find Load Application. In the Load/Unload Application dialog box, you will find the golden key: The Startup Suite.

The following instructions are also found on the 'AutoCAD Stuff' link on my website.

How to Add Your .LSP to the Startup Suite

  1. Startup SuiteClick Load Application [Manage tabApplications panel] to open the Load/Unload Application dialog box.

  2. Click the Startup Suite suitcase at the bottom (or Contents) to open the Startup Suite dialog box.

  3. At the bottom of the Startup Suite dialog box, click Add, then navigate to the .LSP files in the ..\Support folder (or wherever you saved that file).

  4. Select your .LSP file(s), then click Open to return to the Startup Suite dialog where you will see the file(s) listed.

    File listing
  5. Click Close, then Close out of the Load Application dialog box.

  6. To make them work, you will need to close and re-launch AutoCAD.

Note: There are several Lisp routines on my website on the 'AutoCAD Stuff' page. The Lisp files on that page are zipped for ease of distribution and the instructions are there, too.

Top of page

Power Tool

Rollover Toggle

Selection previewI really like the feature that causes objects to 'light up' when you roll your cursor over them, however…

If you have a 3D drawing with intensely meshed 3D objects or blocks, your system may get really s-l-o-w. If that's the case, consider turning off the Selection Preview feature.

Insights

OptionsSelection tab – This is where you have the two check boxes to toggle off the feature, shown in the figure.

Express Tools >System Variable Editor – This is where you will find the variable related to this feature – SELECTIONPREVIEW – along with an explanation of the possible settings, which reads:

Controls the display of selection previewing.

Objects are highlighted when the pickbox cursor rolls over them. This selection previewing indicates that the object would be selected if you clicked. The setting is stored as a bitcode using the sum of the following values:

0Off
1On when no commands are active
2On when a command prompts for object selection

Bottom Line: If you want to toggle off the Selection Preview feature, set the SELECTIONPREVIEW variable to <0>… or create a Lisp routine as shown in this month's opening article so you can toggle it On and Off without typing the whole variable name!

Top of page

The Odd Spot

Disappearing Cursor Solution

3D HiddenHave you ever had the cursor disappear in the drawing area, but you can see it on the toolbars/Ribbon?? I had this happen in training on a customer's computer yesterday, and I think I found the solution: Change the Visual Style.

Application of the Logic

  1. If you have selected one of the Visual Styles to view your 3D drawing, you know that, by default, the background color changes.

  2. The visibility of the cursor has something to do with the graphics; it was fine a moment ago, and now it's gone.

  3. Therefore, if you change the visual style from what you were using – probably 2D Wireframe – to another style, then back again, it will effectively 'reboot' your cursor graphics.

This worked for Jesse's system, so I'm hoping if you ever encounter this frustrating anomaly, you try this tidbit and see if it works for you.

Top of page

The Basics

More Powerful Purge Command

PurgeIt was great to see my friends from Autodesk at AU last December. I was particularly pleased to be able to chat with Lee Ambrosius, a guy who I have immense respect for, primarily because his customizing skills are so far above and beyond my own.

As many of you know, the PURGE command gives you the opportunity to 'clean out' any unreferenced Blocks, Layers, Dimension Styles, etc. from your drawing. The potential is that it will make your file size smaller; always a good thing.

Not sure how the conversation came around to this, but Lee was saying that there's also a Command line version of the Purge command. When you type -PURGE (keeping in mind the hyphen is the golden key here), you see the following list of options:

Enter type of unused objects to purge[Blocks/Dimstyles/ Groups/LAyers/LTypes/MAterials/MUltileaderstyles/Plotstyles/SHapes/textSTyles/Mlinestyles/Tablestyles/ Visualstyles/Regapps/Zero-length geometry/Empty text objects/All]:

Of particular importance is the option for Regapps (Registered Applications). For a more complete review of the implication of registered applications, see this review regarding performance issues with excess unreferenced regapp IDs from the Autodesk Services & Support site.

Bottom Line: If your system is running slower than normal, try this:

Command: -PURGE
Enter type of unused objects to purge[Blocks… ] R
Enter name(s) to purge <*>: [Enter]
Verify each name to be purged? [Yes/No] <Y>: N

No guarantee, but that may just help your drawing move along a bit quicker.

Thanks, Lee!

Top of page

Left Field

Petoskey Stones: State Stone of Michigan
Petoskey StoneAs a kid, our family would go to Michigan for vacation, specifically to Bay View, outside Petoskey on Little Traverse Bay. Over the years, we spent hours scouring the shoreline for Petoskey stones and I have gathered more than I can lift. So here's a little information about this fascinating find.

The Petoskey Stone is a coral that lived during the Devonian age when the northern part of Michigan was covered with a sea of warm water. The scientific name is Hexagonaria percarinata (Hexagonaria meaning having six sides).

The soft living tissue of the corallite was called polyp. At the center of the polyp was the food intake opening or mouth. This dark spot, or the eye of the corallite, has been filled with silt or mud that petrified after falling into the openings. Surrounding the opening were tentacles that were used for gathering food and drawing the food into the mouth. This living corallite thrived on plankton which lived in the warm sea.

Calcite, silica and other minerals have replaced the original elements in each cell. Each chamber or corallite at one time was a living marine animal that grew in colonies. The Petoskey stone is also known as a colony coral.

Credit for this information goes to the Petoskey Area Visitor's Bureau.

Share this page:

Share at Facebook Submit a link at Reddit Share at StumbleUpon Share at del.icio.us Share at Technorati

Local Navigation

Sponsored Links

Accessibility statement

Valid XHTML 1.0!Valid CSS!Creative Commons Licence