CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoLISP 开发指南

规划回调函数

2023-1-5 06:58| 发布者: admin| 查看: 293| 评论: 0|来自: AutoCAD

对于每个反应器事件,必须规划事件发生时将调用的函数。以下伪代码概述了当用户将其中一个折线折点拖动到新位置时应发生的事件的逻辑顺序:

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

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-19 14:59

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部