Jump to content

Add 2 attributes to a Lisp...


Billy Ray

Recommended Posts

2 hours ago, Steven P said:

 

I also have this as an alternative. Go into the LISP code, and change the revisionboxtext lists to suit your project, run the lisp and select according to the prompt each bit of text in the block to change. It takes a bit longer than yours however it is not relying on a specific named title block (for example we have title blocks A1, A2, A3 etc in one project - this will cover them all). it won't let you skip past an attribute so just have to fill in the next one a couple of times until is loops round to fill it in if you want to skip something

 

This is very useful as well. Especially if I can find a way to run it on directorys. Any chance changing the date values to current date code like above is easy (Rev date MM/DD/YY & stamp date MMM DD, YYYY)? As you may have seen I have not figured that out yet. This is really cool!

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:revbox(/ acount revisionboxtext listlength ent entlist) ;;adds revbox text


;;Make array of texts to change
;;- "prompt" "new text"-
;;add lines here to suit
  (setq revisionboxtext (list '"MAIN REVISION" '"A"))
  (setq revisionboxtext (append revisionboxtext (list '"REVISION NO." '"A")))
  (setq revisionboxtext (append revisionboxtext (list '"REVISION DATE" '"07/18/19")))
  (setq revisionboxtext (append revisionboxtext (list '"DRAWN BY" '"BRS")))
  (setq revisionboxtext (append revisionboxtext (list '"REVISION DESCRIPTION" '"ISSUED FOR APPROVAL")))
  (setq revisionboxtext (append revisionboxtext (list '"CHECKED BY" '"SC")))
  (setq revisionboxtext (append revisionboxtext (list '"APPROVED BY" '"DEE")))
  (setq revisionboxtext (append revisionboxtext (list '"STAMP DESCRIPTION" '"ISSUED FOR APPROVAL")))
  (setq revisionboxtext (append revisionboxtext (list '"STAMP DATE" '"JUL 18, 2019")))

;;Loop through array and change rev box details
  (setq acount 0)
  (setq listlength (length revisionboxtext))

  (while (< acount listlength)
    (princ "\n")
    (setq ent (car (nentsel (strcat "\nSelect " (nth acount revisionboxtext) " Text:"))))
    (setq entlst (entget ent))
    (setq entlst (subst (cons 1 (nth (+ 1 acount) revisionboxtext)) (assoc 1 entlst) entlst))
    (entmod entlst)
    (entupd ent)
    (setq acount (+ 2 acount))
  )

  (princ)
)

 

Edited by Billy Ray
Link to comment
Share on other sites

  • Replies 26
  • Created
  • Last Reply

Top Posters In This Topic

  • Billy Ray

    15

  • Roy_043

    5

  • Steven P

    4

  • tombu

    2

You could add something like this for revision date:

 

  (setq d (rtos (getvar "CDATE") 2 6)
        yr (substr d 3 2)
        mo (substr d 5 2)
        day (substr d 7 2)
  );setq
 (setq today (strcat day "/" mo "/" yr) )

 (setq revisionboxtext (append revisionboxtext (list '"DATE" today )))

 

and for the stamp date in dd/mm/yyyy format

 (setq yyyy (substr d 1 4))
 (setq longdate (strcat day "/" mo "/" yyyy) )

 

I'll have to come back with the month as words later

Link to comment
Share on other sites

Thank you Steven. That works just needs words instead of numbers as you said. I'll keep playing wit it. Man y'all are fast at this!

 

;;Make array of texts to change
;;- "prompt" "new text"-
;;add lines here to suit
  (setq revisionboxtext (list '"MAIN REVISION" '"A"))
  (setq revisionboxtext (append revisionboxtext (list '"REVISION NO." '"A")))
  (setq d (rtos (getvar "CDATE") 2 6)
        yr (substr d 3 2)
        mo (substr d 5 2)
        day (substr d 7 2)
  );setq
 (setq today (strcat mo "/" day "/" yr) )

  (setq revisionboxtext (append revisionboxtext (list '"REVISION DATE" today )))
  (setq revisionboxtext (append revisionboxtext (list '"DRAWN BY" '"BRS")))
  (setq revisionboxtext (append revisionboxtext (list '"REVISION DESCRIPTION" '"ISSUED FOR APPROVAL")))
  (setq revisionboxtext (append revisionboxtext (list '"CHECKED BY" '"SC")))
  (setq revisionboxtext (append revisionboxtext (list '"APPROVED BY" '"DEE")))
  (setq revisionboxtext (append revisionboxtext (list '"STAMP DESCRIPTION" '"ISSUED FOR APPROVAL")))
(setq yyyy (substr d 1 4))
 (setq longdate (strcat mo " " day "," yyyy) )
  (setq revisionboxtext (append revisionboxtext (list '"STAMP DATE" longdate)))

;;Loop through array and change rev box details
  (setq acount 0)
  (setq listlength (length revisionboxtext))

  (while (< acount listlength)
    (princ "\n")
    (setq ent (car (nentsel (strcat "\nSelect " (nth acount revisionboxtext) " Text:"))))
    (setq entlst (entget ent))
    (setq entlst (subst (cons 1 (nth (+ 1 acount) revisionboxtext)) (assoc 1 entlst) entlst))
    (entmod entlst)
    (entupd ent)
    (setq acount (+ 2 acount))
  )

  (princ)
)

 

Edited by Billy Ray
Link to comment
Share on other sites

Try adding this.

 

I've put the month words as a list and you can change them to whatever you want (for example, could be Jun, could be June)

  (setq mymonths (list '"Jan" '"Feb" '"Mar" '"Apr" '"May" '"Jun" '"Jul" '"Aug" '"Sep" '"Oct" '"Nov" '"Dec" ) )
  (setq d (rtos (getvar "CDATE") 2 6)
        yy (substr d 3 2)
        yyyy (substr d 1 4)
        mo (substr d 5 2)
        day (substr d 7 2)
  );setq
 (setq today (strcat day "/" mo "/" yy) )
 (setq longdate (strcat (nth (atoi mo) mymonths) " " day " " yyyy) )

 

Link to comment
Share on other sites

On 7/18/2019 at 11:16 AM, Steven P said:

Try adding this.

 

I've put the month words as a list and you can change them to whatever you want (for example, could be Jun, could be June)

 

 

Thanks! That works great now except for two things. The Stamp Date outputs "AUG" instead of "JUL" (so one month ahead somehow) and the stamp description never updates, not sure why. Current code is below, this is really useful.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:revbox(/ acount revisionboxtext listlength ent entlist) ;;adds revbox text


;;Make array of texts to change
;;- "prompt" "new text"-
;;add lines here to suit
  (setq revisionboxtext (list '"MAIN REVISION" '"A"))
  (setq revisionboxtext (append revisionboxtext (list '"REVISION NO." '"A")))
  (setq mymonths (list '"JAN" '"FEB" '"MAR" '"APR" '"MAY" '"JUN" '"JUL" '"AUG" '"SEP" '"OCT" '"NOV" '"DEC" ) )
  (setq d (rtos (getvar "CDATE") 2 6)
        yy (substr d 3 2)
        yyyy (substr d 1 4)
        mo (substr d 5 2)
        day (substr d 7 2)
  );setq
 (setq today (strcat mo "/" day "/" yy) )
 (setq longdate (strcat (nth (atoi mo) mymonths) " " day ", " yyyy) )

  (setq revisionboxtext (append revisionboxtext (list '"REVISION DATE" today )))
  (setq revisionboxtext (append revisionboxtext (list '"DRAWN BY" '"BRS")))
  (setq revisionboxtext (append revisionboxtext (list '"REVISION DESCRIPTION" '"ISSUED FOR APPROVAL")))
  (setq revisionboxtext (append revisionboxtext (list '"CHECKED BY" '"SC")))
  (setq revisionboxtext (append revisionboxtext (list '"APPROVED BY" '"DEE")))
  (setq revisionboxtext (append revisionboxtext (list '"STAMP DESCRIPTION" '"ISSUED FOR APPROVAL")))
  (setq revisionboxtext (append revisionboxtext (list '"STAMP DATE" longdate)))

;;Loop through array and change rev box details
  (setq acount 0)
  (setq listlength (length revisionboxtext))

  (while (< acount listlength)
    (princ "\n")
    (setq ent (car (nentsel (strcat "\nSelect " (nth acount revisionboxtext) " Text:"))))
    (setq entlst (entget ent))
    (setq entlst (subst (cons 1 (nth (+ 1 acount) revisionboxtext)) (assoc 1 entlst) entlst))
    (entmod entlst)
    (entupd ent)
    (setq acount (+ 2 acount))
  )

  (princ)
)

 

Link to comment
Share on other sites

Whoops - forgot the list starts at 0 and not 1, put in anything at the start of mymonths list for example

(setq mymonths (list '"DEC" '"JAN" '"FEB...

(DEC here could be anything)

 

I'm not sure why the stamp description doesn't update - it did when I checked quickly here. Does Stamp Update change as required?

Link to comment
Share on other sites

Thank you that works now for Stamp Date. I forgot but this entire time the Stamp Description has not updated on selection....not sure why. The Stamp description always matches the revision description.

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