cabltv1 Posted February 2, 2009 Posted February 2, 2009 I need a lisp routine that will do the following... 1) Click on a block with 2 attributes: NODE_ID AMP_ID 2) Click on another block to update 2 attributes: NODE_ID (This should equal NODE_ID from first block) DEVICE_NUMBER (This should equal AMP_ID from first block) Thanks for any help! Quote
Lee Mac Posted February 2, 2009 Posted February 2, 2009 Hahah, you and your blocks... Would you like the second selection to be for multiple blocks? or Automated? or would you rather just a simple two click job Quote
cabltv1 Posted February 2, 2009 Author Posted February 2, 2009 Yes. It's me again. I have this large project just about finished. I need to select multiple destination blocks at one time. Thanks again for your help. Quote
Lee Mac Posted February 2, 2009 Posted February 2, 2009 Quickly written and untested! (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)) Quote
cabltv1 Posted February 2, 2009 Author Posted February 2, 2009 You have done it once again! Thanks agin for your help. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.