PostCommand Method (ActiveX)

Posts a command string to the document for execution when the document enters an idle state.

Supported platforms: Windows only

Signature

VBA:

object.PostCommand Command
object

Type: Document

The object this method applies to.

Command

Access: Input-only

Type: String

The command string to post.

Return Value (RetVal)

No return value.

Remarks

Use a space or the ASCII carriage return character (vbCr) at the end of the command string to end the command; this is equivalent to pressing Enter on the keyboard.

This method processes any AutoCAD command-line function, including AutoLISP expressions.

If the document is not active, the document is made activated and the string is not executed until the document has focus.

This method is asynchronous. If you need to execute a command string synchronously, use the SendCommand method.

Examples

VBA:

Sub Example_PostCommand()
   ' This example sends a command for evaluation to the AutoCAD Command prompt
   ' of the current drawing
   
   ' Start creating a Circle in the active drawing
   ThisDrawing.PostCommand "._circle" & vbCr & "2,2,0" & vbCr
   
   MsgBox "CIRCLE command has been started, enter a radius to finish the command."
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_PostCommand()
    ;; This example sends a command for evaluation to the AutoCAD Command prompt
    ;; of the current drawing
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    ;; Start creating a Circle in the active drawing
    (vla-PostCommand doc "._circle 2,2,0 ")
   
    (alert "CIRCLE command has been started, enter a radius to finish the command.")
)