[已解決] 請問如何用LISP修改圖塊屬性的值?
本帖最后由 pizg 于 2011-4-28 17:45 编辑在不使用ATTEDIT指令的情況下,請問如何用LISP修改圖塊屬性的值?
不錯不錯,學習了 請參考,修改屬性標籤為"REV“的值
;修改圖框檔版次
(defun c:ay-REVIS()
(setvar "cmdecho" 0)
(Setq Rev (Strcase (Getstring "\n 請輸入版次:")))
(SETQ ENT (ENTGET (CAR (ENTSEL)))
ENT1 ENT)
(setq SS (Cdr (Assoc -1 ent1)))
(IF (/= "SEQEND" (cdr (assoc 0 ENT)))
(WHILE (= (CDR (ASSOC 0 (SETQ ENT1 (ENTGET (ENTNEXT (CDR (ASSOC -1 ENT1))))))) "ATTRIB")
(cond
((= (CDR (ASSOC 2 ENT1)) "REV")
(SETQ ENT1 (SUBST (CONS 1 REV) (ASSOC 1 ENT1) ENT1))
(ENTMOD ENT1))
)
)
)
(entdel SS)
(entdel SS)
(setvar "cmdecho" 1)
(p 漏了 rinc)
) 感謝 alwtyp 解答. 批量修改
(defun c:ay-REVIS()
(setvar "cmdecho" 0)
(Setq Rev (Strcase (Getstring "\n 請輸入版次:")))
(Setq Block (Ssget "_X" '((0 . "Insert"))))
(Setq N 0)
(Repeat (Sslength Block)
(Setq Ent (Entget (Ssname Block N)))
(Setq Ent1 Ent)
(setq SS (Cdr (Assoc -1 ent1)))
(IF (/= "SEQEND" (cdr (assoc 0 ENT)))
(WHILE (= (CDR (ASSOC 0 (SETQ ENT1 (ENTGET (ENTNEXT (CDR (ASSOC -1 ENT1))))))) "ATTRIB")
(cond
((= (CDR (ASSOC 2 ENT1)) "REV")
(SETQ ENT1 (SUBST (CONS 1 REV) (ASSOC 1 ENT1) ENT1))
(ENTMOD ENT1))
)
)
)
(entdel SS)
(entdel SS)
(setq n (1+ n))
)
(setvar "cmdecho" 1)
(princ)
) 那要看你想选择成什么? 回复 alwtyp 的帖子
谢谢楼主,这个程序真好,我一直想找这个,终于看到了 楼主要的是这个吧,你试试(用alwtyp 的改了一点点)
(defun c:yy3()
(setvar "cmdecho" 0)
(Setq Rev (Strcase (Getstring "\n 請輸入版次:")))
(Setq Block (Ssget '((0 . "Insert"))))
(Setq N 0)
(Repeat (Sslength Block)
(Setq Ent (Entget (Ssname Block N)))
(Setq Ent1 Ent)
(setq SS (Cdr (Assoc -1 ent1)))
(IF (/= "SEQEND" (cdr (assoc 0 ENT)))
(WHILE (= (CDR (ASSOC 0 (SETQ ENT1 (ENTGET (ENTNEXT (CDR (ASSOC -1 ENT1))))))) "ATTRIB")
(cond
((= (CDR (ASSOC 2 ENT1)) "版本")
(SETQ ENT1 (SUBST (CONS 1 REV) (ASSOC 1 ENT1) ENT1))
(ENTMOD ENT1))
)
)
)
(entdel SS)
(entdel SS)
(setq n (1+ n))
)
(setvar "cmdecho" 1)
(princ)
)
学习了!谢谢!!!! 很不错。我写的这个更长
页:
[1]
2