Saturday, April 6, 2024

Why Prefix a Command in AutoCAD With a Hyphen?

You are probably all familiar with the XLIST command, one of the Express Tools available with Autodesk® AutoCAD® and its verticals (but may not be available in AutoCAD LT®). This post explains why you might want to prefix that command with a hyphen.

The XLIST command.

The XLIST command reports properties of a nested object, such as the layer and linetype of a polyline within a block or an xreference drawing. This command is useful in identifying the layer and xref hosting a specific object. The command launches a small dialog to display the query results, as shown in Figure 1. 

The Xref/Block Nested Object List dialog.
Figure 1: The Xref/Block Nested Object List dialog. 

Based on the layer value in the dialog, the object is a polyline in an xreference drawing named x00000_p-site on a layer named cs-esmt-line

NOTE: The vertical bar in the layer value separates the xreference name from the layer name.

In the previous example, the layer name is completely visible within the dialog. Since the dialog can't be resized, if the xref name + layer name is too long, it might extend past the edge of the dialog, as shown in Figure 2.

A layer property value that extends past the edge of the Xref/Block Nested object List dialog.
Figure 2: A layer property value that extends past the edge of the dialog. 

Hyphens to the rescue!

Some commands allow a hyphen as a prefix, and XLIST is one. With the hyphen prefix, the command outputs the query results in the command line instead of the dialog. The result of running the -XLIST command on the same object is shown in Figure 3.

The command line result of the -XLIST query.
Figure 3: The command line result of the -XLIST query.

The query results in the command line show the full xreference name and the full layer name. As a bonus feature, you can copy the layer value to the clipboard and paste it into the layer palette filter of another drawing.

More Examples?

Another example of when to add a hyphen prefix is with the PURGE command. By running the command with the hyphen prefix, you can access the option to purge registered applications (Regapps), as shown in Figure 4.

The command line options for the -PURGE command.
Figure 4: The command line options for the -PURGE command.

For Civil 3D® users, multiple commands can be run in multiple drawings by creating a script file and using the Autodesk Batch Save Utility. It does a lot more than just saving files! Using -LAYER you can create and modify layer properties directly from the command line. These commands can then be converted into programmable pieces for scripts or LISP routines.

  • (command "-LAYER" "ON" "G-ANNO-TTBL" "THAW" "G-ANNO-TTBL" "")
  • (command "-LAYER" "MAKE" "G-ANNO-SEAL" "")
Note that some commands, such as -LINETYPE, might begin in command line only mode, but once a dialog such as "file open" is launched, the command is no longer command-line only.  Details of that process will not be covered in this post.

I hope you find this information useful.


No comments: