规划回调函数
对于每个反应器事件,必须规划事件发生时将调用的函数。以下伪代码概述了当用户将其中一个折线顶点拖动到新位置时应发生的事件的逻辑顺序: 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 会通过发出事件(如果已建立编辑器反应器)来通知您的应用程序。:vlr-commandEnded 使用全局变量来标识用户更改的折线是必要的,因为 和 函数之间没有连续性。在应用程序中,这两个函数都是相互独立调用和执行的。全局变量存储在一个函数中设置并在另一个函数中访问的重要信息。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-3-14 06:18
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.