你好
这是一个快捷方式
- (defun c:setAtt (/ ent elst val ss tag)
- (if
- (and
- (setq ent (car (nentsel "\nSelect the attribute: ")))
- (setq elst (entget ent))
- (= (cdr (assoc 0 elst)) "ATTRIB")
- (setq val (getstring "\nNew value: "))
- (princ "\nSelect blocks to be edited (Enter for all)")
- (or
- (setq
- ss
- (ssget (list '(0 . "INSERT") (assoc 2 (entget (cdr (assoc 330 elst))))))
- )
- (setq
- ss
- (ssget "_X"
- (list '(0 . "INSERT") (assoc 2 (entget (cdr (assoc 330 elst)))))
- )
- )
- )
- (setq tag (cdr (assoc 2 elst)))
- (setq n 0)
- )
- (progn
- (while (setq ent (ssname ss n))
- (SetAttValue ent tag val)
- (setq n (1+ n))
- )
- )
- (princ "\nInvalid input")
- )
- (princ)
- )
- ;;; SetAttValue (gile)
- ;;; Sets a value to an attribute
- ;;;
- ;;; Arguments
- ;;; blk : block ename
- ;;; tag : attribute tag
- ;;; val : new value
- (defun SetAttValue (blk tag val / lst loop)
- (setq lst (entget (entnext blk))
- loop (= "ATTRIB" (cdr (assoc 0 lst)))
- )
- (while loop
- (if (= (strcase tag) (cdr (assoc 2 lst)))
- (progn
- (entmod (subst (cons 1 val) (assoc 1 lst) lst))
- (setq loop nil)
- (entupd blk)
- )
- (setq lst (entget (entnext (cdr (assoc -1 lst))))
- loop (= "ATTRIB" (cdr (assoc 0 lst)))
- )
- )
- )
- )
|