没有你的TEXTLIST和TAGLIST,没有调试,你自己看看,调调,应该不难,FILL函数是调试过的,所有函数未加错误处理,只是一个功能的实现,,剩下的应该你自己做完成了
- (defun Fill(entAtt Text tag / entv str att attlist i)
- (setq entv (vlax-ename->vla-object entAtt))
- (setq att (vla-getattributes entv))
- (setq attlist (vlax-safearray->list (vlax-variant-value att)))
- (setq i 0)
- (while (< i (length attlist))
- (if (= (vla-get-tagstring (nth i attlist)) tag)
- (progn
- (vla-put-textstring (nth i attlist) text)
- (setq i (length attlist))
- )
- )
- (setq i (1+ i))
- )
- (princ)
- )
- (defun main( / ss i sslist )
- (prompt "选择属性块...")
- (setq ss (ssget '((0 . "Insert"))))
- (setq i 0)
- (while (< i (sslength ss))
- (setq sslist (append sslist (list (ssname ss i))))
- (setq i (1+ i))
- )
- (setq sslist (vl-sort sslist '(lambda (e1 e2) (< (caddr (assoc 10 (entget e1))) (caddr (assoc 10 (entget e2)))))))
- (setq i 0)
- (while (< i (length taglist))
- (fill (nth i sslist) (nth i textlist) (nth i taglist))
- (setq i (1+ i))
- )
- )
|