CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ObjectARX 开发指南

响应 AutoCAD 消息

2023-1-1 07:12| 发布者: admin| 查看: 445| 评论: 0|来自: AutoCAD

AutoCAD 向 ObjectARX 应用程序发送的消息有四类:

  • 发送到所有应用程序的消息
  • 仅当应用程序已向 AutoLISP函数注册时发送的消息 ® acedDefun()
  • 发送到已向 ObjectARX 注册服务的应用程序的消息
  • 仅由使用 ActiveX 自动化的应用程序响应的消息(仅限 Windows)

以下五个表描述了 AutoCAD 发送到 ObjectARX 应用程序的消息。第一个表列出了发送到所有应用程序的消息。

发送到所有应用程序的消息

消息

描述

kInitAppMsg

在加载 ObjectARX 应用程序以打开 AutoCAD 与应用程序之间的通信时发送。

kUnloadAppMsg

在卸载 ObjectARX 应用程序时发送(当用户卸载应用程序时或 AutoCAD 本身终止时)。关闭文件并执行清理操作。

kLoadDwgMsg

打开图形时发送一次。然后,如果应用程序向 AutoLISP 注册任何函数,AutoCAD 会针对加载到编辑器中的每个图形发送一次此消息。此时,AutoCAD 编辑器已完全初始化,所有全局函数都可用。

但是,不能使用 kLoadDwgMsg 中的 /函数。acedCommandS()acedCommandC()

kSaveMsg

当 AutoCAD 由于输入了“保存”、“保存”、“新建”或“打开”命令而保存图形时发送。

kUnloadDwgMsg

当用户退出绘图会话时发送(按加载时间的相反顺序)。

kPreQuitMsg

在 AutoCAD 退出时发送,但在开始卸载所有 ObjectARX 应用程序之前发送。

下表列出了 AutoCAD 发送给已注册 AutoLISP 函数的应用程序的消息:acedDefun()

仅当应用程序已注册 AutoLISP 函数时才发送的消息

消息

描述

kInvkSubrMsg

发送到调用使用 aceedDefun() 注册的函数。

kEndMsg

仅在输入 END 命令并且需要保存更改时发送(当 dbmod != 0 时)。kEndMsg 不会发送 NEW 或 OPEN,而是发送 kSaveMsg 和 kLoadDwgMsg。对于 END,如果 dbmod = 0,则发送 kQuitMsg 而不是 kEndMsg。

kQuitMsg

当 AutoCAD 因输入 QUIT 命令而退出(结束而不保存)图形时发送。如上所述,kQuitMsg 也可以使用 END 命令接收。如果发送了 END 命令并且 dbmod = 0,则发送 kQuitMsg。

注意:kQuitMsg 可以在 kPreQuitMsg 之前发送。

kCfgMsg

当 AutoCAD 从配置程序返回时发送,仅用于更改显示驱动程序。

下表列出了应用程序在向 ObjectARX 注册服务时收到的消息。

仅已注册服务的应用程序接收的消息

消息

描述

kDependencyMsg

当 ObjectARX 应用程序注册了 AcRxService 对象并且该服务的依赖项计数从 0 更改为 1 时发送。

kNoDependencyMsg

当 ObjectARX 应用程序注册了 AcRxService 对象并且该服务的依赖项计数从 1 更改为 0 时发送。

下表列出了应用程序在 Windows 上使用 ActiveX 自动化时需要响应的消息。请参阅COM 和 ActiveX 自动化

Messages only responded to by applications that use ActiveX Automation (Windows only)

Message

Description

kOleUnloadAppMsg

Sent to determine if the application can be unloaded (that is, none of its ActiveX objects or interfaces are being referenced by other applications).

See the rxdefs.h file where these enumeration constants are defined by the type declaration. AppMsgCode

You will need to decide which messages your ObjectARX application will respond to. The following table describes recommended actions upon receipt of a given message.

ObjectARX application reactions to AutoCAD messages

Message

Recommended Actions

kInitAppMsg

Do register services, classes, AcEd commands and reactors, and AcRxDynamicLinker reactors. Initialize application's system resources, such as devices and windows. Perform all one-time early initialization. AcRx, AcEd, and AcGe are all active. Store the value of the pkt parameter if you want to unlock and relock your application.

Don't expect device drivers to be initialized, any user interface resources to be active, applications to be loaded in a particular order, AutoLISP to be present, or any databases to be open. Calls involving any of these assumptions will result in an error condition, sometimes fatal. AcDb and AcGi libraries are generally not yet active, although related AcRx and other structures are in place.

kUnloadAppMsg

Do perform final system resource cleanup. Anything started or created in kInitAppMsg should now be stopped or destroyed.

Don't expect things to be any different from the description of kInitAppMsg. AutoCAD could be mostly dismantled by the time this call is made, except for the libraries listed as active in the kInitAppMsg Do description.

kOleUnloadAppMsg

This message should be responded to only by applications using ActiveX Automation on Windows.

Do respond with AcRx::kRetOK, if the application can be unloaded (none of its ActiveX objects or interfaces are being referenced by other applications). If it cannot be unloaded, respond with AcRx::kRetError.

kLoadDwgMsg

执行与当前图形编辑会话相关的初始化。AcDb、AcGi 和用户界面 API 现在都处于活动状态。未指定是否对图形执行了任何操作。所有 AutoCAD 提供的 API 现在都处于活动状态。此时可以执行 AutoLISP 函数注册,并初始化用户界面。现在要执行的其他操作包括轮询 AutoCAD 驱动程序和查询 AcEditorReactor 事件(如果您希望尽早访问)。acdbHostApplicationServices()->workingDatabase()

不要对每个图形编辑会话执行不希望发生的任何操作。假设每次程序执行多次发送此消息。

kUnloadDwgMsg

发布或清理为响应 kLoadDwgMsg 代码而启动或注册的所有内容。释放所有AcDb反应器,不包括持久性反应器。

不要释放未绑定到编辑会话的系统资源,也不要清理 AcRx 类、AcEd 反应器或命令;它们在编辑会话保持有效。

kDependencyMsg

当其他应用程序依赖于应用程序时,执行应用程序所需的任何操作,例如锁定应用程序,使其无法卸载。

kNoDependencyMsg

当不再有任何其他应用程序依赖于您的应用程序时,执行应用程序所需的任何操作,例如解锁应用程序,以便用户可以根据需要卸载它。

kInvkSubrMsg

调用注册时使用的函数。通过调用 来确定函数。使用 aceedRetxxx() 返回值。acedDefun()acedGetFuncode()

除了函数调用之外,这里做太多事情。

kPreQuitMsg

卸载应用程序控制的任何依赖项(应用程序、DLL 等),以确保在应用程序之前卸载这些依赖项。

kEndMsg

kCfgMsg

kQuitMsg

kSaveMsg

请考虑使用 AcEditorReactor 事件回调作为响应这些消息的替代方法。

如果要响应通过 AcEditorReactor 进行的等效事件回调,请不要响应这些消息。


路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-19 11:55

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部