Tuesday, August 18, 2009

How to Use the Command-Line Alternative in AutoCAD Map 3D

Ribbons, menus, tool bars, dialog boxes and palettes are easy to use and intuitive compared to using the command-line in AutoCAD Map 3D. For example, the Create Buffer dialog box (refer to my other buffer related posts), allows you to choose the features to be buffered, indicate the buffer distance, and specify other buffer creation options – and all with just a point-and-click of the mouse and minimal input from the keyboard.

Such methods are fine in an interactive mode when we need to manually create buffers. However, if you are writing macros to help automate the process, you need a command-line alternative that avoids launching a dialog box. To do this for our Create Buffer example, simply precede the command name, MAPFDOBUFFERCREATE, with a hyphen when you enter the command on the command-line. Here’s how to create a 20ft buffer via the command-line:
  1. At the command line enter –MAPFDOBUFFERCREATE (note the minus sign) and press Enter. The following prompt appears:
    Buffer create options [Input/Distance/Merging/Output/Go]:

  2. Enter ‘D’ then 20 to enter the buffer distance.
    Buffer create options [Input/Distance/Merging/Output/Go]: D
    Enter a buffer distance in Feet <>: 20

  3. Enter ‘M’ and then ‘S’ to ensure that multiple buffers are merged into a single feature.
    Merge buffers [None/Single/Overlapping]: S
    A single output buffer will be created

  4. Enter ‘I’ then select the features to be buffered.
    Buffer create options [Input/Distance/Merging/Output/Go]: I
    Select objects: 1 found
    Select objects:

  5. Enter ‘G’ to create the buffer as specified.
    Buffer create options [Input/Distance/Merging/Output/Go] : G
This technique allows you to use Create Buffer tool in macros, scripts, custom toolbars and workflows. In fact, the hyphen can be used for other selected AutoCAD Map 3D and AutoCAD dialog boxes including the ones listed below.

Layer Properties Manager
Command: -Layers
Prompt: [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck

Block Definition
Command: -Block
Prompt: Enter block name or [?]:

Drawing Cleanup
Command: -MapClean
Prompt: Enter profile name to load:

Attach Object Class Definition File
Command: -AttachDef
Prompt: Enter name of object definition file:

In addition, certain system variables can also be used to affect the display of dialog boxes. For example, the EXPERT variable controls the display of warning dialog boxes. When the value of EXPERT is set to ‘0’, warnings and prompts are issued normally; when EXPERT is set to a value between ‘1’ and ‘5,’ specific warnings and prompts are suppressed.

Another useful system variable is FILEDIA. This variable controls the display of dialog boxes used with commands that read and write files. When the value of FILEDIA is set to ‘0’, command-line prompts are used to prompt for file names; when FILEDIA is set to ‘1’, dialog boxes are used.

1 comment:

Murph said...

Along with the variable "filedia" don't forget about the "cmddia" variable, some of the original map commands from the adeXXX functions will still call a dialog box if that's set to 1.