明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 515|回复: 9

[提问] 双击CAD对象,显示自定义对话框实现方法,用vlisp怎么调用这个veto()方法?

[复制链接]
发表于 2023-10-29 03:03 | 显示全部楼层 |阅读模式
双击CAD对象,显示自定义对话框实现方法,用vlisp怎么调用这个veto()方法?
[size=13.3333px]
    class TlsApplication : IExtensionApplication
    {
        void IExtensionApplication.Initialize()
        {
            TTest.Start();
        }
        void IExtensionApplication.Terminate()
        {
        }
    }
    class TTest
    {
        static bool m_Veto = false;
        public static void Start()
        {
            Application.DocumentManager.DocumentLockModeChanged += new DocumentLockModeChangedEventHandler(vetoCommand);
            Application.BeginDoubleClick += new BeginDoubleClickEventHandler(beginDoubleClick);
        }
        static void beginDoubleClick(object sender, BeginDoubleClickEventArgs e)
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            PromptSelectionResult res = ed.SelectImplied();
            SelectionSet ss = res.Value;
            if (ss != null)
            {
                if (ss.Count == 1)
                {
                    using (Transaction tr = doc.TransactionManager.StartTransaction())
                    {
                        Line line = tr.GetObject(ss[0].ObjectId, OpenMode.ForRead) as Line;
                        if (line != null)
                        {
                            ResultBuffer rb = line.GetXDataForApplication("MyApp");
                            if (rb != null)
                            {
                                m_Veto = true;
                            }
                        }
                    }
                }
            }
        }
        static void vetoCommand(object sender, DocumentLockModeChangedEventArgs e)
        {
            if (e.GlobalCommandName.ToLower() == "properties")
            {
                if (m_Veto)
                {
                    e.Veto();

                    Application.ShowAlertDialog("hello");
                    m_Veto = false;
                }
            }
        }
    }



 楼主| 发表于 2023-10-29 03:31 | 显示全部楼层
Veto 如何用来屏蔽CAD命令,用lisp实现
 楼主| 发表于 2023-10-29 03:46 | 显示全部楼层
;;;=======创建文档管理器反应器*docmReactor*及回调函数==============================
(defun at_docm_reactor (/)
  (if (not *docmReactor*)
    (setq *docmReactor*
           (vlr-docmanager-reactor
             nil
             '((:vlr-documentLockModeChanged . vetoCommand))
           )
    )
  ) ;_定义文档管理器反应器*docmReactor*
)
(defun vetoCommand (reactorObject parameterlist / e)
  (setq e parameterlist)
  (if (wcmatch (strcase (nth 4 e)) "*eattedit*,*EATTEDIT*")
    (progn
      (princ "hello")
      (princ "如何调用 veto()方法屏蔽(阻止)命令运行")
    )
  )
)
;;;================================================================================
 楼主| 发表于 2023-10-29 10:08 | 显示全部楼层
http://bbs.mjtd.com/forum.php?mo ... AB%BB%F7&page=1 不知道是不是版本问题,双击调用了attrib,但是返回不了鼠标点。
发表于 2023-10-29 12:45 | 显示全部楼层
我在2022内用没变化
 楼主| 发表于 2023-10-29 14:57 | 显示全部楼层
wangsr 发表于 2023-10-29 12:45
我在2022内用没变化

我的是2021 机械版
 楼主| 发表于 2023-10-29 16:40 | 显示全部楼层
本帖最后由 sfzyr 于 2023-10-29 16:41 编辑

DocumentLockModeChangedEventArgs.Veto Method
Description
This function can be called during a DocumentLockModeChanged callback if it is a callback for a lock request. The result will be that the lock request will be vetoed, which normally means that the command will be canceled before it can start. When this function is called, DocumentLockModeChangeVetoed will be sent.

It is only active during DocumentLockModeChanged in case the receiver of the call needs to make any changes in the document before deciding whether to veto or not. By waiting until the changed callback, the document will be currently locked when the ability to veto is given. This is necessary because it is not possible to change the document's lock status from within any of these callbacks.

Visual Basic
Public Function Veto() As void
C#
public void Veto();
Links
DocumentLockModeChangedEventArgs Class, Autodesk.AutoCAD.ApplicationServices Namespace
==============================
在lisp中如何调用??请各位给与支持,谢谢。
 楼主| 发表于 2023-10-29 23:14 | 显示全部楼层
这个veto方法,或者叫函数,能在LISP里面调用,从而在特定场合下取消执行的命令,按照自己的程序执行。
发表于 2023-10-31 11:06 | 显示全部楼层
直接vlisp的反应器就可以实现,不过好像不能点击实体对象本身
 楼主| 发表于 2023-11-3 21:46 | 显示全部楼层
我爱lisp 发表于 2023-10-31 11:06
直接vlisp的反应器就可以实现,不过好像不能点击实体对象本身

;;;=======创建文档管理器反应器*docmReactor*及回调函数==============================
(defun at_docm_reactor (/)
  (if (not *docmReactor*)
    (setq *docmReactor*
           (vlr-docmanager-reactor
             nil
             '((:vlr-documentLockModeChanged . vetoCommand))
           )
    )
  ) ;_定义文档管理器反应器*docmReactor*
)
(defun vetoCommand (reactorObject parameterlist / e)
  (setq e parameterlist)
  (if (wcmatch (strcase (nth 4 e)) "*eattedit*,*EATTEDIT*")
    (progn
      (princ "hello")
      (princ "如何调用 veto()方法屏蔽(阻止)命令运行")
    )
  )
)
这个回调函数如何修改?才能把执行中的指令给取消掉,从而执行自定义函数
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-11 22:46 , Processed in 0.132939 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表