| SendCommand 方法 (ActiveX) 将命令字符串从 VB 或 VBA 应用程序发送到文档进行处理。 支持的平台:仅限 Windows 返回值 (RetVal)无返回值。 言论在命令字符串末尾使用空格或 ASCII 回车符 () 结束命令;这相当于按键盘上的 Enter。vbCr 此方法处理任何 AutoCAD 命令行函数,包括 AutoLISP 表达式。 如果指定的图形未处于活动状态,则该图形将处于活动状态。 此方法通常是同步的。但是,如果使用此方法发送的命令需要任何用户交互(例如在屏幕上选取一个点),则此方法将在用户输入开始后立即继续。然后,该命令将继续异步处理。 从事件处理程序调用此方法时,将异步处理该方法。 切勿使用此方法发出具有可用 ActiveX 方法的命令。例如,不要使用 .请改用该方法。SendCommand "VBALOAD "LoadDVB 例子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 可视化 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.")
) | 
 |Archiver|CAD开发者社区
( 苏ICP备2022047690号-1   苏公网安备32011402011833)
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1   苏公网安备32011402011833)
GMT+8, 2025-10-31 06:50
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.