对于每个反应器事件,必须规划事件发生时将调用的函数。以下伪代码概述了当用户将其中一个折线折点拖动到新位置时应发生的事件的逻辑顺序: Defun gp:outline-changed
Erase the tiles.
Determine how the boundary changed.
Straighten up the boundary.
Redraw new tiles.
End function
不过,有一个复杂因素。当用户开始拖动折线折点的轮廓时,AutoCAD 会通过发出事件来通知应用程序。但是,此时用户刚刚开始拖动其中一个折线折点。如果立即调用该函数,则会中断用户正在执行的操作。您将不知道新顶点位置的位置,因为用户尚未选择其位置。最后,AutoCAD 将不允许函数在用户仍在拖动折线对象时对其进行修改。AutoCAD 使折线对象处于打开状态以供修改,并在用户完成重新定位对象之前保持打开状态。:vlr-modifiedgp:outline-changed 你需要改变你的方法。以下是更新的逻辑: When the user begins repositioning a polyline vertex,
Invoke the gp:outline-changed function
Defun gp:outline-changed
Set a global variable that stores a pointer to the polyline
being modified by the user
End function
When the command completes,
Invoke the gp:command-ended function
Defun gp:command-ended
Erase the tiles
Get information on the previous polyline vertex locations
Get information on the new polyline vertex locations
Redefine the polyline (straighten it up)
Redraw the tiles
End function
当用户完成修改路径轮廓时,AutoCAD 会通过发出 aevent(如果您已建立编辑器反应器)来通知您的应用程序。:vlr-commandEnded 使用全局变量来标识用户更改的折线是必要的,因为 and 函数之间没有连续性。在应用程序中,这两个函数彼此独立地调用和执行。全局变量存储在一个函数中设置并在另一个函数中访问的重要信息。gp:outline-changedgp:command-ended 现在考虑如果用户擦除花园路径边界时该怎么做。最终目标是擦除所有瓷砖。以下伪代码概述了逻辑: When the user begins to erase the boundary,
Invoke the gp:outline-erased function
Defun gp:outline-erased
Set a global variable that stores a pointer to the reactor
attached to the polyline currently being erased
End function
When the erase is completed,
Invoke the gp:command-ended function
Defun gp:command-ended
Erase the tiles that belonged to the now-deleted polyline
End function
|
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-29 14:28
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.