Bug Watch April 2004

31 Mar, 2004 By: Steve Johnson

Tatty Text, Qleader Quirks, and Mouse Mayhem get the workaround in this month’s column.

Tatty text revisited
Last month, we reported a problem in which the Mtext editor displays text as too light, too dark, fuzzy, or otherwise difficult to read. Here's another workaround.

Workaround: When you're in the Mtext editor, hold down the Ctrl key and roll the scroll button on your pointing device. As with various other Windows applications (Word, Excel), this makes the editing window zoom in and out. Do this until the text is readable.

Wrap trap (R14 to 2005)
If you zoom the Mtext editor using Ctrl-scroll as described above, the right margin doesn't adjust, causing a false impression of where word wrap occurs and how long the paragraphs are.

No known workaround.

Ruler fooler (2004 to 2005)
If you zoom the Mtext editor using Ctrl-scroll as described above, the ruler doesn't adjust to match the text. This means you can't see where your indents and tab stops are in relation to the text you're editing.

No known workaround.

Qleader quirk (2000 to 2005)
This is a long history lesson with a tiny bug at the end. If you're not into nostalgic AutoCAD trivia and just want to know what's causing your Qleader command to work improperly, you may wish to skip the next three paragraphs and head straight to the meaty bit.

Over the years, AutoCAD has provided a variety of different ways to specify whether you want to use the dialog-box version of a command or the command-line version. These days, AutoCAD is pretty consistent. To use the dialogbox version of the command, just use the plain command name: Plot, for example. For the command-line version, put a hyphen before the command name: -Plot. In AutoLISP and scripts, the command-line version is typically used with or without the hyphen, but you can use the (initdia) function to force the use of the command-line version.

Things weren't always so simple. AutoCAD has gradually gained dialog-box versions of various commands since Release 9 (from 1987—not quite as old as Cadalyst!), and it was traditional for each new release to do things that were different from the last. Most of these different ways have survived for sound compatibility reasons, leaving a rich landscape of old and new ways of doing the same thing. For example, to edit an attribute value in AutoCAD 2005, you can use -Attedit for a verbose command-line experience, either Ddatte or Attedit for the traditional dialog box, and either Eattedit or double-click for a newer, more powerful dialog box.

What does this have to do with a Qleader quirk, you ask? Well, one of the old legacy items is the CMDDIA system variable, introduced in Release 12, last documented in Release 14, and still there in AutoCAD 2005. Originally, the only documented use for it was to control whether dialog boxes were used with the Plot command, and it no longer has any such effect. However, it also affects a few other things such as external database commands (this was documented in Release 14) and the one we're interested in here-the behavior of dimension leader command prompts.

When you use the Leader command, pick some points and then press Enter twice. When you enter M to type mtext, what happens next depends on CMDDIA. If it's set to 1, you use a dialog box to enter the text; if it's set to 0, you use a command line. That's not a bug, it's a genuine undocumented feature. The bug occurs when you use the Qleader command to draw your leader with CMDDIA set to 0. Enter Qleader, pick some points, press Enter twice, and this prompt appears:

  Enter first line of annotation text <Mtext>:

Based on normal AutoCAD conventions, you see this prompt and expect to be able to press Enter or M and Enter to enter some mtext. When you press Enter, the command ends without giving you the opportunity to do anything. When you type M and Enter, the M is used as the first line of your leader mtext.

Workaround: If your CMDDIA system variable is set to 0, it's probably that way by accident, because some old script or AutoLISP routine set it that way. Setting it back to 1 is unlikely to cause any problems. If you have sound reasons for deliberately leaving CMDDIA set to 0, you can enter your leader text lines at the Command prompt. Just don't press Enter when AutoCAD tells you to!

Menu mouse move mayhem (R14 to 2005)
When you create a menu macro that begins with an asterisk (*), the macro keeps repeating until you press Esc. When the menu item contains a backslash (\), the macro pauses at that point until you pick a point or enter something. Use these two in combination with some simple AutoLISP code, and things get a little strange. For example, the following macro should prompt you to pick an object, and when you've done so, it should make a copy of that object 10 units to the right. The macro should then repeat, prompting you for the next object.

  *^C^C(setq es (entsel)) \_.COPY !es ;10,0;;

The macro actually does this, but it also does something odd. As you move the pointer around, you see something flash past on the command line. Make the text screen visible to see that AutoCAD repeats the following for every mouse move:

  Command: (setq es (entsel))
  Select object: *Cancel*
  ; error: Function cancelled

Of course, if you move your pointing device a lot, any useful information in the text screen has scrolled away by now. The same problem applies to AutoLISP code that's not embedded in the macro. For example, define a SETES command as follows:

  (defun C:SETES () (setq es (entsel)))

Then modify the macro to look like this:

  *^C^CSETES \_.COPY !es ;10,0;;

This acts in the same way, repeating the following for each move of your pointing device:

  Command: SETES
  Select object: *Cancel*
  ; error: Function cancelled

In this case, it's not too inconvenient because the macro still does the job required of it, but in many cases having the function cancelled stops the macro from working correctly.

While we're discussing ancient history, it's ironic to note that the notoriously buggy Release 13 was the last AutoCAD in which this bug was absent!

Workaround: If you have control over both the AutoLISP and the menu macro, you can rewrite your code to put everything (including a loop) into the AutoLISP code. Then eliminate the troublesome asterisk from the menu macro.

More News and Resources from Cadalyst Partners

For Mold Designers! Cadalyst has an area of our site focused on technologies and resources specific to the mold design professional. Sponsored by Siemens NX.  Visit the Equipped Mold Designer here!

For Architects! Cadalyst has an area of our site focused on technologies and resources specific to the building design professional. Sponsored by HP.  Visit the Equipped Architect here!