CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

发送命令方法 (ActiveX)

2023-1-4 03:48| 发布者: admin| 查看: 867| 评论: 0|来自: AutoCAD

摘要: 将命令字符串从 VB 或 VBA 应用程序发送到文档进行处理。

将命令字符串从 VB 或 VBA 应用程序发送到文档进行处理。

支持的平台:仅窗口

签名

工 务 局:

object.SendCommand Command
对象

类型:文档

此方法适用的对象。

命令

访问:仅输入

类型:字符串

要发送到文档的命令。

返回值(RetVal)

无返回值。

言论

在命令字符串末尾使用空格或 ASCII 回车符 () 结束命令;这相当于按键盘上的回车键。vbCr

此方法处理任何 AutoCAD 命令行函数,包括 AutoLISP 表达式。

如果指定的图形未处于活动状态,则会将其变为活动状态。

此方法通常是同步的。但是,如果使用此方法发送的命令需要任何用户交互(例如在屏幕上选取一个点),则此方法将在用户输入开始后立即继续。然后,将继续异步处理该命令。

从事件处理程序调用此方法时,将异步处理此方法。

切勿使用此方法发出有 ActiveX 方法可用的命令。例如,不要使用。相反,请使用该方法。SendCommand "VBALOAD "LoadDVB

例子

工 务 局:

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.")
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-11 21:59

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部