本帖最后由 vectra 于 2014-12-24 12:50 编辑
人家提来的条件图,每次都要删除一些无用的内容,当他修改版发来时,又要重复删除。所以,想操作一次,多次应用,就有了下面的代码,火热出炉。
2014-12-24
修改了记录文件的指定逻辑。
2014-12-23 初次发布
- ;; 删除操作记录器,方便重复删除
- (defun get-recordfilename (filename)
- (getfiled "操作记录文件"
- (if (null filename)
- (strcat (getvar "DWGPREFIX")
- (vl-filename-base (getvar "DWGNAME"))
- )
- filename
- )
- "txt"
- 1
- )
- )
- (defun c:rerf (/ filename)
- (setq filename (get-recordfilename *erase-record-filename*))
- (if (= 'str (type filename))
- (progn
- (setq *erase-record-filename* filename)
- (princ (strcat "\n已设置记录文件为 \"" *erase-record-filename* "\""))
- )
- )
- (princ)
- )
- (defun c:rer (/ file i id obj ss)
- (setq ss (ssget))
- (if (null *erase-record-filename*)
- (setq *erase-record-filename* (get-recordfilename *erase-record-filename*))
- )
- (if (and ss
- *erase-record-filename*
- )
- (progn
- (setq file (open *erase-record-filename* "A"))
- (repeat (setq i (sslength ss))
- (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i))))
- id (vla-get-handle obj)
- )
- (write-line id file)
- (vla-erase obj)
- )
- (close file)
- (princ (strcat "\n" (itoa (sslength ss)) " 个删除操作已记录。"))
- ;;(startapp "notepad" fname)
- )
- )
- (princ)
- )
- (defun c:der (/ file i id)
- (if *erase-record-filename*
- (progn
- (setq file (open *erase-record-filename* "R")
- i 0
- )
- (while (setq id (read-line file))
- (if (setq id (handent id))
- (progn
- (entdel id)
- (setq i (1+ i))
- )
- )
- )
- (close file)
- (princ (strcat "\n" (itoa i) " 个删除操作已应用。"))
- )
- (princ "\n请先指定删除记录文件。")
- )
- (princ)
- )
|