论坛dwg文件比较的帖子不是很多,今天发一个文件比较的功能,根据句柄不同判断图形是否一致。由于只判断了句柄,因此图元的位置,颜色改动都无法识别。
- ;;写入句柄到txt,两个图形都要执行一次写入组码
- (defun c:tt23( / path name newname shell reply ent entg hand i openff ss EL ENTALL)
- (setvar "cmdecho" 0)
- (setq Path (getvar "dwgprefix"))
- (setq newname (strcat path (vl-string-right-trim ".dwg" (getvar "dwgname") ) "句柄.txt"))
- (setq ss (ssget "x"))
- (repeat (setq i (sslength ss))
- (setq ent (ssname ss (setq i (1- i))))
- (setq entg (entget ent))
- (setq el (vl-remove-if
- '(lambda (x)
- (or
- (= (car x) 340)
- (= (car x) 350)
- ;(/= (car x) 5)
- (= (car x) -1)
- (= (car x) 330)
- )
- )
- entg
- )
- )
- (setq entall (cons el entall)) ;想把群码写入txt中比较,但不知道怎么将表写入txt???
- (setq hand (cons (cdr (assoc 5 entg)) hand));当前只识别句柄,如果图元移动位置或者改色都不能识别
- )
- (setq openff(open newname "w"))
- (foreach e hand
- (write-line e openff )
- )
- (close openff)
- (princ (strcat "写入句柄" newname " 成功"))
- (princ)
- )
- ;;;选择不相同的部分
- (defun c:tt3 (/ getpath en hd name newname oldos openff path ss)
- (setvar "cmdecho" 0)
- (setq oldos (getvar "osmode"))
- (setvar "osmode" 0)
- (setq ss (ssadd))
- (setq getpath(getvar "Dwgprefix") )
- (setq path (getfiled "" (strcat "" getpath "") "txt" 0) )
- ;读取文件列表
- (setq openff(open path "r"))
- (while (setq hd (read-line openff)) ;循环读取每一行
- (if (setq en (handent hd));根据句柄判断图形中是否有此对象 如果有就加入选择集
- (setq ss (ssadd en ss))
- )
- );_ 结束while
- (close openff)
- (setvar "osmode" oldos)
- (setvar "cmdecho" 1)
- (command ".select" "all" "r" ss "")
- (sssetfirst nil (ssget "p") );反选
- (princ)
- )
|