I am looking for a lisp that when executed, would rename the current layout tab to "DRAWINGNAME Rev REVISIONNUMBER" where DRAWINGNAME & REVISIONNUMBER are attributes pulled from the standard titleblock and Rev is just text.
Anybody seen anything that may work or have some partial code I may be able to combine to get what I'm looking for?
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
@swankster wrote:
I am looking for a lisp that when executed, would rename the current layout tab to "DRAWINGNAME Rev REVISIONNUMBER" where DRAWINGNAME & REVISIONNUMBER are attributes pulled from the standard titleblock and Rev is just text.
Anybody seen anything that may work or have some partial code I may be able to combine to get what I'm looking for?
As a "demo",
change the "standard titleblock name" to the corret name
(defun c:demo ( / a aclyt attlst b hnd ss) (setq aclyt (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object)) ) ) (if (and (/= "Model" (vla-get-Name aclyt)) (setq ss (ssget "_X" (list '(0 . "INSERT") ) '(2 . "standard titleblock name");; change it to the corret name '(66 . 1) (cons 410 (getvar 'CTAB)) ) ) ) ) (progn (setq hnd (ssname ss 0) obj (vlax-ename->vla-object hnd) attlst (vlax-invoke obj 'GetAttributes) ) (foreach att attlst (cond ((= (vla-get-TagString att) "DRAWINGNAME") (setq a (vla-get-TextString att)) ) ((= (vla-get-TagString att) "REVISIONNUMBER") (setq b (vla-get-TextString att)) ) ) (if (and a b ) (vla-put-name aclyt (strcat a " Rev " b)) ) ) ) ) (princ) )
hope that helps
Henrique
Thanks, getting an issue though:
too few arguments: (IF (AND (/= "Model" (vla-get-Name ACLYT)) (SETQ SS (SSGET "_X" (LIST (QUOTE (0 . "INSERT"))) (QUOTE (2 .
I tried messing with it but I am a total noob with lisp. I imagine the "model" thing is some kind of fail-safe if the command is used inside modelspace...
swankster wrote:I imagine the "model" thing is some kind of fail-safe if the command is used inside modelspace...
Yes, it is.
Change only the '(2 . "standard titleblock name") to your titleblock name, and add
(defun c:demo ( / a aclyt attlst b hnd ss)
(vl-load-com)
(setq aclyt (vla-get-activelayout
Or post your full code...
Henrique
Something still isn't right. I have updated the lisp with the correct info as shown.
(defun c:demo ( / a aclyt attlst b hnd ss) (setq aclyt (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object)) ) ) (if (and (/= "Model" (vla-get-Name aclyt)) (setq ss (ssget "_X" (list '(0 . "INSERT") ) '(2 . "dwg info and location for wind xref border");; change it to the corret name '(66 . 1) (cons 410 (getvar 'CTAB)) ) ) ) ) (progn (setq hnd (ssname ss 0) obj (vlax-ename->vla-object hnd) attlst (vlax-invoke obj 'GetAttributes) ) (foreach att attlst (cond ((= (vla-get-TagString att) "DWGNAME") (setq a (vla-get-TextString att)) ) ((= (vla-get-TagString att) "REVNO.") (setq b (vla-get-TextString att)) ) ) (if (and a b ) (vla-put-name aclyt (strcat a " Rev " b)) ) ) ) ) (princ) )
was getting that same error while loading the lisp but then started getting a syntax error.
Sorry, my bad....
Had an extra bracket...
(defun c:demo (/ a aclyt attlst b hnd obj ss) (vl-load-com) (setq aclyt (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object)) ) ) (if (and (/= "Model" (vla-get-Name aclyt)) (setq ss (ssget "_X" (list '(0 . "INSERT") '(2 . "dwg info and location for wind xref border") '(66 . 1) (cons 410 (getvar 'CTAB)) ) ) ) ) (progn (setq hnd (ssname ss 0) obj (vlax-ename->vla-object hnd) attlst (vlax-invoke obj 'GetAttributes) ) (foreach att attlst (cond ((= (vla-get-TagString att) "DWGNAME") (setq a (vla-get-TextString att)) ) ((= (vla-get-TagString att) "REVNO.");; the TAG have a dot? (setq b (vla-get-TextString att)) ) ) (if (and a b ) (vla-put-name aclyt (strcat a " Rev " b)) ) ) ) ) (princ) )
EDIT: the above code has been fixed and should work as expected.
Henrique