快速编写且未经测试!
- (defun c:blkupd (/ bEnt aEnt eLst aNode aAmp ss EntLst attEnt attEntLst)
- (if (and (setq bEnt (car (entsel "\nSelect Block to Retrieve Attribute Values > ")))
- (= "INSERT" (cdadr (entget bEnt))) (= 1 (cdr (assoc 66 (entget bEnt)))))
- (progn
- (setq aEnt (entnext bEnt))
- (while (= "ATTRIB" (cdadr (setq eLst (entget aEnt))))
- (cond ((= "NODE_ID" (cdr (assoc 2 eLst)))
- (setq aNode (cdr (assoc 1 eLst))))
- ((= "AMP_ID" (cdr (assoc 2 eLst)))
- (setq aAmp (cdr (assoc 1 eLst)))))
- (setq aEnt (entnext aEnt)))
- (if (and aNode aAmp)
- (progn
- (if (setq ss (ssget (list (cons 0 "INSERT")(cons 66 1)
- (if (getvar "CTAB")(cons 410 (getvar "CTAB")) (cons 67 (- 1 (getvar "TILEMODE")))))))
- (progn
- (setq EntLst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
- (foreach e EntLst
- (setq attEnt (entnext e))
- (while (= "ATTRIB" (cdadr (setq attEntLst (entget attEnt))))
- (cond ((= "NODE_ID" (cdr (assoc 2 attEntLst)))
- (entmod (subst (cons 1 aNode) (assoc 1 attEntLst) attEntLst)))
- ((= "DEVICE_NUMBER" (cdr (assoc 2 attEntLst)))
- (entmod (subst (cons 1 aAmp) (assoc 1 attEntLst) attEntLst))))
- (setq attEnt (entnext attEnt)))))
- (princ "\n<!> No Blocks Selected <!>")))
- (princ "\n<!> Selected Block Doesn't Contain Required Attributes <!> ")))
- (princ "\n<!> No Block Selected <!>"))
- (command "_regenall")
- (princ))
|