CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2018 开发者帮助

处理非线性反应器序列

2024-5-18 16:52| 发布者: admin| 查看: 128| 评论: 0|原作者: admin|来自: AutoCAD

处理非线性反应器序列

最后一个重要细节涉及用户使用专用 GRIP 命令修改折线时 AutoCAD 中命令/反应器序列中的一个怪癖。这些命令(如 GRIP_MOVE 和 GRIP_ROTATE)可在选择对象的夹点并单击鼠标右键后从快捷菜单中使用。反应器序列不像简单的 MOVE 或 ERASE 命令那样线性。实际上,用户在另一个命令中更改为其他命令。为了演示这种情况,您可以加载第 6 课中的代码,该代码跟踪反应堆事件的顺序。或者只需查看以下带注释的 Visual LISP 控制台窗口输出,看看会发生什么:

;; To start, select the polyline and some of the circles by using a 
;; crossing selection box. The items in the selection set-- 
;; the chosen circles and the polyline--are now shown with grips on.
;; To initiate the sequence, click on one of the polyline grips:
(GP:COMMAND-WILL-START #<VLR-Command-reactor> (GRIP_STRETCH))

;; Now change the command to a move by right-clicking and choosing
;; MOVE from the pop-up menu.  Notice that the command-ended
;; reactor fires in order to close out the GRIP_STRETCH command
;; without having fired an object reactor event:
(GP:COMMAND-ENDED #<VLR-Command-reactor> (GRIP_STRETCH))
(GP:COMMAND-WILL-START #<VLR-Command-reactor> (GRIP_MOVE))

;; Now drag the outline (and the selected circles) to a new location.
(GP:OUTLINE-CHANGED #<VLA-OBJECT IAcadLWPolyline 028f3188> 
                 #<VLR-Object-reactor> nil)
(GP:COMMAND-ENDED #<VLR-Command-reactor> (GRIP_MOVE))

这表明您无法确定在所有情况下都会调用对象反应器回调。

这个序列中有一个相关的怪癖。即使在最终的命令结尾回调期间,仍属于夹点选择集的圆圈也无法删除。AutoCAD 仍打开这些圆圈。如果在命令结束的回调期间尝试擦除它们,则可能会使AutoCAD崩溃。若要解决此问题,可以使用另一个全局变量来存储指向磁贴对象的指针列表,直到可以将其删除为止。

处理非线性反应器序列

  1. 将以下函数添加到 gpreact.lsp 文件:
    (defun gp:erase-tiles (reactor / reactorData tiles tile)
      (if (setq reactorData (vlr-data reactor))
        (progn
          ;; Tiles in the path are stored as data in the reactor.
          (setq tiles (cdr (assoc 100 reactorData)))
          ;; Erase all the existing tiles in the path.
          (foreach tile tiles
              (if (and (null (member tile *Safe-to-Delete*))
                     (not (vlax-erased-p tile))
                     )
                  (progn
                     (vla-put-visible tile 0)
                     (setq *Safe-to-Delete* (cons tile *Safe-to-Delete*))
                  )
              )
          )
          (vlr-data-set reactor nil)
          ) 
        )
     )

    这个新功能将用于擦除瓷砖的第一阶段。请注意,这些图块实际上并没有被擦除:它们被设置为不可见,并被添加到名为 的全局变量中。*Safe-to-Delete*

  2. 将以下函数添加到 gpreact.lsp 文件:
    (defun Gp:Safe-Delete (activeCommand)
      (if (not (equal
          (strcase (substr activeCommand 1 5))
            "GRIP_"
          )
      )
      (progn
         (if *Safe-to-Delete*
            (foreach Item *Safe-to-Delete*
              (if (not (vlax-erased-p Item))
                (vla-erase item)
              )
            )
          )
          (setq *Safe-to-Delete* nil)
          )
        )
     )

    可以在未执行GRIP_MOVE或GRIP_STRETCH命令时调用此函数。


路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2025-3-20 03:19

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部