Jump to content

Need Lisp to update attributes


cabltv1

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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))

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...