LISP to bump revision numbers, dates and descriptions

LISP to bump revision numbers, dates and descriptions

Anonymous
Not applicable
1,119 Views
4 Replies
Message 1 of 5

LISP to bump revision numbers, dates and descriptions

Anonymous
Not applicable

The fisrt thing I'm trying to create is a LISP that will modify the REV block in the attached file i.e. if the attribute is already populated with 0 then the lisp will change it to 1, if is already populated with 1 then the lisp will change it to 2 and so on.

 

The second thing I am trying to create is a LISP that will modify the REVISION block in the attached file by populating the next open revision number, date, initails and revision information.

 

I think the first thing can be done but I don't know about the second.  Ideally both items would be in a lisp file that can be added to a script so I could batch drawings...

 

my lisp skills are lacking, thanks for any help.

 

 

0 Likes
1,120 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

I'm not sure how good you are with lisp.  I wrote this for publishing multiple layout tabs.  It will do what you want but you will have to modify the code a little.  This code is not commented very well. It will also insert initials based on the windows login name.  Not sure where all of this came from. it is partyl peicemealed  from the web.

 

Matthew

0 Likes
Message 3 of 5

Anonymous
Not applicable

Thanks Matt but I don't even know where to begin....

0 Likes
Message 4 of 5

Anonymous
Not applicable

Will this get you started?

 

;THIS WILL BUILD A SELECTION SET OF ALL THE TITLE BLOCKS
  ; CHANGE TB_22x34 TO THE NAME OF YOUR BLOCK
(DEFUN UPDATE-TITLEBLOCK (/)
(SETQ BLKS (SSGET "X" (LIST (CONS 0 "INSERT")(CONS 410 (getvar "ctab"))(CONS 2 "TB_22x34"))) )
(IF BLKS (PROGN
; DWG_REV IS TEH TAG OF THE ATTRIBUTE CHANGE THIS TO MATCH YOUR SITUATION
(SETQ REVTMP (vl-GetAttributeValue (VLAX-ENAME->VLA-OBJECT (SSNAME BLKS 0)) "DWG_REV"))
(while (> (sslength BLKS) 0)

' increment the rev value
(SETQ UPD (CHR (1+ (ASCII REVTMP))))

(vl-SetAttributeValue (VLAX-ENAME->VLA-OBJECT (SSNAME BLKS 0)) "DWG_REV" UPD)
) )
(PRINC "\nThere are no Title Blocks: "))
(PRINC UPD))


(DEFUN UPDATE-BRDREV (REVNMB DESC INIT DATE /)
  ;THIS WILL BUILD A SELECTION SET OF ALL THE REVISION BLOCKS
  ; CHANGE BRDREV TO THE NAME OF YOUR BLOCK
  (SETQ TAGS (SSGET "X" (LIST (CONS 0 "INSERT")(CONS 410  (getvar "ctab"))(CONS 2 "brdrev"))) )

   ; THIS WILL EXTRACT THE FIRST BLOCK OF THE SELECTION SET.
  (SETQ BLOCK (VLAX-ENAME->VLA-OBJECT (SSNAME TAGS 0)))
  ;CHANGE THE ATTRIBUTE TAG NAME AND VALUE FOR THE ATTRIBUTE YOU NEED
  (IF (NOT (= "" REVNMB)) (vl-SetAttributeValue BLOCK "REV_BLOCK_NO" REVNMB))
  (IF (NOT (= "" DESC))   (vl-SetAttributeValue BLOCK "REV_BLOCK_DESC" DESC))
  (IF (NOT (= "" INIT))   (vl-SetAttributeValue BLOCK "REV_BLOCK_BY" INIT))
  (IF (NOT (= "" DATE))   (vl-SetAttributeValue BLOCK "REV_BLOCK_DATE" DATE))
  (PRINC (SSNAME TAGS 0)))

;THESE WILL DO JUST WHAT THE NAME IMPLIES
(defun vl-GetAttributeValue (block tag)    (setq tag (strcase tag))
  (vl-some (function (lambda (attrib)
    (if (eq tag (strcase (vla-get-Tagstring attrib)))(vla-get-TextString attrib)  )))
        (vlax-invoke block 'GetAttributes)    ))

(defun vl-SetAttributeValue (block tag value)  (setq tag (strcase tag) VALUE (IF (= " " VALUE) "" VALUE))
  (vl-some (function (lambda (attrib)
    (if (eq tag (strcase (vla-get-TagString attrib)))(progn (vla-put-TextString attrib value) value)  )))
        (vlax-invoke block 'GetAttributes)    ))

0 Likes
Message 5 of 5

Anonymous
Not applicable

that helps, thanks!

0 Likes