明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1089|回复: 4

[提问] 用command做了一些图层操作,操作后用ctrl+z要很多次才能撤销,有办法一次撤销么

[复制链接]
发表于 2021-11-12 22:22:12 | 显示全部楼层 |阅读模式
(defun c:av ()
;打开所有、关闭计算书图层、
    (setvar "cmdecho" 0)
(setvar "Expert" 1)
(command "Layer" "on" "*"  "")(princ)
(command "Layer" "off" "*建筑图*|*"  "")(princ)
(command "Layer" "off" "*建施*|*"  "")(princ)
(command "Layer" "off" "*景观施*|*"  "")(princ)
(command "Layer" "off" "*人防施*|*"  "")(princ)
(command "Layer" "off" "*wpj*|*"  "")(princ)
(command "Layer" "off" "*配筋*|*"  "")(princ)
(command "Layer" "off" "*导荷*|*"  "")(princ)
(command "Layer" "off" "*板配筋*|*"  "")(princ)
(command "Layer" "off" "*配筋结果*|*"  "")(princ)
(command "Layer" "off" "*计算结果*|*"  "")(princ)
(command "Layer" "off" "*荷载简图*|*"  "")(princ)
(command "Layer" "off" "*荷载校核*|*"  "")(princ)
(command "Layer" "off" "*挠度*|*"  "")(princ)
(command "Layer" "off" "*冲切*|*"  "")(princ)
(command "Layer" "off" "*沉降*|*"  "")(princ)
(command "Layer" "on" "*结构参*"  "")(princ)
(command "Layer" "on" "*建筑参*"  "")(princ)
(setvar "Expert" 0)
    (setvar "cmdecho" 1)
);■■■■

发表于 2021-11-12 23:37:41 | 显示全部楼层
楼主整复杂了,注意command命令不能关闭当前图层.以下为简单示例.
  1. (defun c:tt ()
  2.   (command "undo" "be")
  3.   (command "Layer" "off" "text" "")
  4.   (command "Layer" "off" "text1" "")
  5.   (command "undo" "e")
  6.   (prin1)
  7. )

回复 支持 1 反对 0

使用道具 举报

发表于 2021-11-12 22:25:11 来自手机 | 显示全部楼层
在程序前面加上undo begin,末尾加上undo,论坛搜关键词undo
 楼主| 发表于 2021-11-12 22:55:46 | 显示全部楼层
tigcat 发表于 2021-11-12 22:25
在程序前面加上undo begin,末尾加上undo,论坛搜关键词undo

编组之后,就可以一次撤销
;;编组开始;(command "_.undo" "be")
(defun _StartUndo (*DOC*)
  (_EndUndo *DOC*)
  (vla-StartUndoMark *DOC*)
)
;;结束编组;(if (= 8 (logand (getvar "undoctl") 8)) (command "_.undo" "_e"))
(defun _EndUndo        (*DOC*)
  (if (= 8 (logand 8 (getvar 'UNDOCTL)))
    (vla-EndUndoMark *DOC*)
  )
)

(defun c:av ()
;打开所有、关闭计算书图层、
    (setvar "cmdecho" 0)
_StartUndo()
(setvar "Expert" 1)
(command "Layer" "on" "*"  "")(princ)
(command "Layer" "off" "*建筑图*|*"  "")(princ)
(command "Layer" "off" "*建施*|*"  "")(princ)
(command "Layer" "off" "*景观施*|*"  "")(princ)
(command "Layer" "off" "*人防施*|*"  "")(princ)
(command "Layer" "off" "*wpj*|*"  "")(princ)
(command "Layer" "off" "*配筋*|*"  "")(princ)
(command "Layer" "off" "*导荷*|*"  "")(princ)
(command "Layer" "off" "*板配筋*|*"  "")(princ)
(command "Layer" "off" "*配筋结果*|*"  "")(princ)
(command "Layer" "off" "*计算结果*|*"  "")(princ)
(command "Layer" "off" "*荷载简图*|*"  "")(princ)
(command "Layer" "off" "*荷载校核*|*"  "")(princ)
(command "Layer" "off" "*挠度*|*"  "")(princ)
(command "Layer" "off" "*冲切*|*"  "")(princ)
(command "Layer" "off" "*沉降*|*"  "")(princ)
(command "Layer" "on" "*结构参*"  "")(princ)
(command "Layer" "on" "*建筑参*"  "")(princ)
(setvar "Expert" 0)
    (setvar "cmdecho" 1)
_EndUndo()
);■■■■
是这样吗,还是不能一步撤掉呢,还是要撤好多步
 楼主| 发表于 2021-11-13 08:57:17 | 显示全部楼层
tigcat 发表于 2021-11-12 23:37
楼主整复杂了,注意command命令不能关闭当前图层.以下为简单示例.

好的,我是做结构设计的码盲。。。只会简单的调用哈,谢谢~
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-15 10:43 , Processed in 0.176357 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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