Sends a command string from a VB or VBA application to the document for processing.
Supported platforms: Windows only
VBA:
object.SendCommand Command
Type: Document
The object this method applies to.
Access: Input-only
Type: String
The command to send to the document.
No return value.
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 drawing specified is not active, it will be made active.
This method is generally synchronous. However, if the command sent with this method requires any user interaction (such as picking a point on the screen) then this method will continue as soon as the user input begins. The command will then continue to be processed asynchronously.
When this method is called from an event handler it is processed asynchronously.
You should never use this method to issue a command for which there is an ActiveX method available. For example, do not use SendCommand "VBALOAD ". Instead, use the LoadDVB method.
VBA:
Sub Example_SendCommand() ' This example sends a command for evaluation to the AutoCAD command line ' of a particular drawing ' Create a Circle in the active drawing and ' zoom to display the entire circle ThisDrawing.SendCommand "_Circle" & vbCr & "2,2,0" & vbCr & "4" & vbCr ThisDrawing.SendCommand "_zoom" & vbCr & "a" & vbCr ' Refresh view ThisDrawing.Regen acAllViewports MsgBox "A circle command has been sent to the command line of the current drawing." End Sub
Visual LISP:
(vl-load-com) (defun c:Example_SendCommand() ;; This example sends a command for evaluation to the AutoCAD command line ;; of a particular drawing (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) ;; Create a Circle in the active drawing and ;; zoom to display the entire circle (vla-SendCommand doc (strcat "_circle 2,2,0 4 ")) (vla-SendCommand doc (strcat "_zoom a ")) ;; Refresh view (vla-Regen doc acAllViewports) (alert "A circle command has been sent to the command line of the current drawing.") )