Jump to content

Update attribute with actual $FILENAME$ lisp


Recommended Posts

Posted

Lee, if I were to not use the variable that is in Autocad itself, but wanted to replace the value for attribute DRAWINGNAME with only the text "UPDATED" - how would you modify the routine that you've just written? If I have this routine, it will help me update any blocks with either the a system variable or a regular text.

 

No hurry, as I think it's close to midnight maybe in England? As always, thank you.

  • Replies 23
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    11

  • kam1967

    8

  • uddfl

    3

  • dbroada

    1

Popular Days

Top Posters In This Topic

Posted
Thanks, Lee. I tested your routine and I got an extra right parenthesis error. I took away the other two on the right and it works fine now.

 

(entmod (subst (cons 1 dNme)(assoc 1 aEntLst) aEntLst)))

(entupd e)

(setq aEnt (entnext aEnt)))))

(princ "\n No Title Blocks Found "))

;(command "_regenall")

(princ))

 

Well, this has been most educational. Thanks for the input, everyone! Have a wonderful day, okay? Grab some zZzZ too! :)

 

Hmm... I checked the updated routine that I posted and parenthesis number seems correct :huh:

Posted

You're welcome to test it, Lee. I know, it's tough being a perfectionist, isn't it? ;)

Posted

Again, untested:

 

(defun c:dwgupd (/ ss ans eLst dNme aEnt aEntLst)
 (vl-load-com)
 (if (setq ss (ssget "X" (list (cons 0 "INSERT") (cons 2 "TITLE") (cons 66 1)
    (if (getvar "CTAB")
      (cons 410 (getvar "CTAB"))
      (cons 67 (- 1 (getvar "TILEMODE")))))))
   (progn
     (if (not oans) (setq oans "Filename"))
     (initget "Filename Updated")
     (setq ans (getkword (strcat "\nFilename or Updated? {F/U} <" oans ">: ")))
     (if (eq "" ans) (setq ans oans) (setq oans ans))
     (if (eq ans "Filename") (setq dNme (vl-filename-base (getvar "DWGNAME")))
   (setq dNme "UPDATED"))
   (setq eLst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
   (foreach e eLst
     (setq aEnt (entnext e))
     (while (not (eq "SEQEND" (cdadr (setq aEntLst (entget aEnt)))))
   (if (= "DRAWINGNAME" (cdr (assoc 2 aEntLst)))
     (entmod (subst (cons 1 dNme)(assoc 1 aEntLst) aEntLst)))
   (setq aEnt (entnext aEnt)))))
   (princ "\n<!> No Title Blocks Found <!> "))
 (command "_regenall")
 (princ))

 

Off to bed now to catch some Zzzzs :star:

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