JADT Posted May 16, 2013 Posted May 16, 2013 I have used the single attribute pulling version I discovered in these forums, but would really like to know if pulling 2 attributes into the rename would work. I require the drawing number (att "DRAWINGNO.") and the revision (att "REV") eg drawing number abc123 Revision B would rename layout tab to abc123B is there anything out there. I have RSI from renaming 300 pdfs I know sheet sets probably does this but we don't work with them. All help guidance gratefully received. Quote
Tharwat Posted May 16, 2013 Posted May 16, 2013 Welcome to Cadtutor 1- What is the name of the attributed Block that holds the attributes for renaming the layout that it lays on ? 2- What are the tag name for the two attributes for each one ? Tharwat Quote
JADT Posted May 16, 2013 Author Posted May 16, 2013 Thanks for the reply: Block is "A1 Border" no quotes attribute tags are "DRAWINGNO." and "REV" again no quotes. if they could be separated with an underscore that would be ideal...but for now anything would be great. Cheers J Quote
Tharwat Posted May 16, 2013 Posted May 16, 2013 (edited) Hope this would work for you , try it and let me know (defun c:Test (/ outs spc s) (vl-load-com) ;; --- Tharwat 16. May. 2013 --- ;; (setq outs (vla-get-layouts (vla-get-ActiveDocument (vlax-get-acad-object)) ) spc (getvar 'ctab) ) (foreach l (layoutlist) (setvar 'ctab l) (if (setq s (ssget "_X" (list '(0 . "INSERT") (cons 2 "A1 Border")(cons 410 l)))) (progn ((lambda (j / sn e ent nm lst) (while (setq e (ssname s (setq j (1+ j)))) (setq lst nil) (while (/= (cdr (assoc 0 (entget (setq e (entnext e))))) "SEQEND" ) (if (and (eq (cdr (assoc 0 (setq ent (entget e)))) "ATTRIB") (or (eq (cdr (assoc 2 ent)) "DRAWINGNO.") (eq (cdr (assoc 2 ent)) "REV") ) (snvalid (cdr (assoc 1 ent))) ) (setq lst (cons (cdr (assoc 1 ent)) lst)) ) ) (if (eq 2 (length lst)) (if (and (setq nm (strcat (car lst) "_" (cadr lst))) (not (member nm (layoutlist)) ) ) (vla-put-name (vla-item outs l) nm) ) ) ) ) -1 ) ) ) ) (setvar 'ctab spc) (princ) ) Edited May 17, 2013 by Tharwat Quote
pBe Posted May 17, 2013 Posted May 17, 2013 @tharwat If your are going to use layoutlist (setq s (ssget "_X" [b](list[/b] '(0 . "INSERT")'(2 . "A1 Border")[b](cons 410 l)[/b]))) and (setvar 'ctab spc) If you happen to start in a paperspace tab that will cause an error ; IMO no need to go thru layoutlist and select the "A1 Border" per tab This is how i would approach this: (defun C:renlay (/ Layout ss n e ltn ltnlist nm Attlist) (vl-load-com) ;;; pBe 17MAy2013 ;;; (setq Layout (vla-get-layouts (vla-get-ActiveDocument (vlax-get-acad-object))) ) (if (setq ss (ssget "_x" '((0 . "INSERT") (2 . "A1 Border") (-4 . "<NOT") (410 . "Model") (-4 . "NOT>") ) ) ) (repeat (setq i (sslength ss)) (setq n 0 e (ssname ss (setq i (1- i))) ltn (cdr (assoc 410 (entget e))) ) (if (and (not (member ltn ltnlist)) (setq AttVal (mapcar '(lambda (k) (list (vla-get-tagstring k) (vla-get-textstring k)) ) (vl-remove-if-not '(lambda (j) (member (vla-get-tagstring j) '("DRAWINGNO." "REV")) ) (vlax-invoke (vlax-ename->vla-object e) 'GetAttributes) ) ) ) ) (progn ;; In case the attribute sequence is out ot whack (setq ltnlist (cons ltn ltnlist) nm (Strcat (cadr (assoc "DRAWINGNO." Attval)) "_" (cadr (assoc "REV" Attval)) ) ) ;;; In case there are equal values ;;; (while (member nm (layoutlist)) (setq nm (strcat nm " (" (itoa (setq n (1+ n))) ")")) ) (vla-put-name (Vla-item Layout ltn) nm) ) ) ) ) (princ) ) Quote
pBe Posted May 17, 2013 Posted May 17, 2013 Good catch pBe with the dxf 410 . Thank you . Cheers dude Quote
JADT Posted May 17, 2013 Author Posted May 17, 2013 Guys, thank you for your time on this. tharwat - sorry i didn't reply was away from the machine last night-for once. pBe the RENLAY lisp worked perfectly I can now rest my fingers and rest easy that my pdf's will be named correctly. IF i remember to renlay them before i publish. JADT Quote
Tharwat Posted May 17, 2013 Posted May 17, 2013 thank you for your time on this. tharwat - sorry i didn't reply was away from the machine last night-for once. Did my code work for you ? Quote
JADT Posted May 17, 2013 Author Posted May 17, 2013 Hi Tharwat. it renamed the adjacent layout tab only (not the current one i was on - or the rest of them) but also put rev before drawingno. so named in reverse. pBe's amended code did the job. So between you it was spot on. Thanks. Quote
Tharwat Posted May 17, 2013 Posted May 17, 2013 Hi Tharwat.it renamed the adjacent layout tab only (not the current one i was on - or the rest of them) but also put rev before drawingno. so named in reverse. I see now , my mistake was to put the attributes value in a list without paying any consideration to the sequence of the location of the attributes which caused the renaming to be not in order , any way since that pBe 's routine worked as needed for you , Kudos to pBe for the nice work Good luck . Quote
JADT Posted July 23, 2013 Author Posted July 23, 2013 Hi pBe if you are reading this. Your code has been working perfectly for me since you built it, thanks again. unfortunately I have just hit a problem, that I hadn't encountered before. If you add a new layout tab/s and then run your RENLAY lisp it renames the existing tabs with a (1) suffix as below image If you have any time to take a look it would be appreciated. For now as it is only the odd tab I am renaming the new ones by hand. Quote
pBe Posted July 23, 2013 Posted July 23, 2013 Its a fail safe i embedded on the routine for such cases. The user have to ensure the "source" titleblocks doesnt have duplicate numbers prior to running RENLAY, From the result you can pinpoint which layout tab houses the duplicate TAG values Quote
dpenney Posted August 8, 2013 Posted August 8, 2013 @tharwat If your are going to use layoutlist (setq s (ssget "_X" [b](list[/b] '(0 . "INSERT")'(2 . "A1 Border")[b](cons 410 l)[/b]))) and (setvar 'ctab spc) If you happen to start in a paperspace tab that will cause an error ; IMO no need to go thru layoutlist and select the "A1 Border" per tab This is how i would approach this: (defun C:renlay (/ Layout ss n e ltn ltnlist nm Attlist) (vl-load-com) ;;; pBe 17MAy2013 ;;; (setq Layout (vla-get-layouts (vla-get-ActiveDocument (vlax-get-acad-object))) ) (if (setq ss (ssget "_x" '((0 . "INSERT") (2 . "A1 Border") (-4 . "<NOT") (410 . "Model") (-4 . "NOT>") ) ) ) (repeat (setq i (sslength ss)) (setq n 0 e (ssname ss (setq i (1- i))) ltn (cdr (assoc 410 (entget e))) ) (if (and (not (member ltn ltnlist)) (setq AttVal (mapcar '(lambda (k) (list (vla-get-tagstring k) (vla-get-textstring k)) ) (vl-remove-if-not '(lambda (j) (member (vla-get-tagstring j) '("DRAWINGNO." "REV")) ) (vlax-invoke (vlax-ename->vla-object e) 'GetAttributes) ) ) ) ) (progn ;; In case the attribute sequence is out ot whack (setq ltnlist (cons ltn ltnlist) nm (Strcat (cadr (assoc "DRAWINGNO." Attval)) "_" (cadr (assoc "REV" Attval)) ) ) ;;; In case there are equal values ;;; (while (member nm (layoutlist)) (setq nm (strcat nm " (" (itoa (setq n (1+ n))) ")")) ) (vla-put-name (Vla-item Layout ltn) nm) ) ) ) ) (princ) ) Hi, i was wondering if we could get this to work renaming the AutoCAD 2014 layout tabs, extracting information from the specific sheet Title Block Fields? The Title Block "block" on each sheet in Paperspace is "AnaeCo_Title" The Layout Tab would for example on sheet 1 incorporating an A1 drawing sheet, would read.... SHT 1 - A1 SHEET The Layout Tab would for example on sheet 2 incorporating an A2 drawing sheet, would read.... SHT 2 - A2 SHEET The Layout Tab would for example on sheet 3 incorporating an A2 drawing sheet, would read.... SHT 3 - A2 SHEET The Layout Tab would for example on sheet 4 incorporating an A3 drawing sheet, would read.... SHT 4 - A3 SHEET............and so on for each sheet tab. Where the tags would be (as shown in ): SHT - SHEET These would possible change for each sheet...regarding sheet number of course, but also possible sheet size. Can this lisp be used to suit the above? Still on learners permit for all this.... Cheers DP Quote
Lee Mac Posted August 8, 2013 Posted August 8, 2013 Try this quick code: ([color=BLUE]defun[/color] c:relay ( [color=BLUE]/[/color] a e i l n p s x ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] s ([color=BLUE]ssget[/color] [color=MAROON]"_X"[/color] '((0 . [color=MAROON]"INSERT"[/color]) (66 . 1) (2 . [color=MAROON]"AnaeCo_Title"[/color]) (410 . [color=MAROON]"~Model"[/color])))) ([color=BLUE]progn[/color] ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] i ([color=BLUE]sslength[/color] s)) ([color=BLUE]setq[/color] e ([color=BLUE]entnext[/color] ([color=BLUE]ssname[/color] s ([color=BLUE]setq[/color] i ([color=BLUE]1-[/color] i)))) x ([color=BLUE]entget[/color] e) a [color=BLUE]nil[/color] ) ([color=BLUE]while[/color] ([color=BLUE]=[/color] [color=MAROON]"ATTRIB"[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 0 x))) ([color=BLUE]setq[/color] a ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] ([color=BLUE]strcase[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 2 x))) ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 1 x))) a) e ([color=BLUE]entnext[/color] e) x ([color=BLUE]entget[/color] e) ) ) ([color=BLUE]setq[/color] l ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 410 ([color=BLUE]entget[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 330 x))))) a) l)) ) ([color=BLUE]vlax-for[/color] x ([color=BLUE]vla-get-layouts[/color] ([color=BLUE]vla-get-activedocument[/color] ([color=BLUE]vlax-get-acad-object[/color]))) ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]setq[/color] a ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] ([color=BLUE]vla-get-name[/color] x) l))) ([color=BLUE]setq[/color] n ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] [color=MAROON]"SHEET_NUM"[/color] a))) ([color=BLUE]setq[/color] p ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] [color=MAROON]"SIZE"[/color] a))) ) ([color=BLUE]vl-catch-all-apply[/color] '[color=BLUE]vla-put-name[/color] ([color=BLUE]list[/color] x ([color=BLUE]strcat[/color] [color=MAROON]"SHT "[/color] n [color=MAROON]" - "[/color] p [color=MAROON]" SHEET"[/color]))) ) ) ) ([color=BLUE]princ[/color] [color=MAROON]"\nNo \"AnaeCo_Title\" blocks found."[/color]) ) ([color=BLUE]princ[/color]) ) ([color=BLUE]vl-load-com[/color]) ([color=BLUE]princ[/color]) Quote
mdbdesign Posted August 8, 2013 Posted August 8, 2013 Try this quick code: ([color=BLUE]defun[/color] c:relay ( [color=BLUE]/[/color] a e i l n p s x ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] s ([color=BLUE]ssget[/color] [color=MAROON]"_X"[/color] '((0 . [color=MAROON]"INSERT"[/color]) (66 . 1) (2 . [color=MAROON]"AnaeCo_Title"[/color]) (410 . [color=MAROON]"~Model"[/color])))) ([color=BLUE]progn[/color] ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] i ([color=BLUE]sslength[/color] s)) ([color=BLUE]setq[/color] e ([color=BLUE]entnext[/color] ([color=BLUE]ssname[/color] s ([color=BLUE]setq[/color] i ([color=BLUE]1-[/color] i)))) x ([color=BLUE]entget[/color] e) a [color=BLUE]nil[/color] ) ([color=BLUE]while[/color] ([color=BLUE]=[/color] [color=MAROON]"ATTRIB"[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 0 x))) ([color=BLUE]setq[/color] a ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] ([color=BLUE]strcase[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 2 x))) ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 1 x))) a) e ([color=BLUE]entnext[/color] e) x ([color=BLUE]entget[/color] e) ) ) ([color=BLUE]setq[/color] l ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 410 ([color=BLUE]entget[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 330 x))))) a) l)) ) ([color=BLUE]vlax-for[/color] x ([color=BLUE]vla-get-layouts[/color] ([color=BLUE]vla-get-activedocument[/color] ([color=BLUE]vlax-get-acad-object[/color]))) ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]setq[/color] a ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] ([color=BLUE]vla-get-name[/color] x) l))) ([color=BLUE]setq[/color] n ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] [color=MAROON]"SHEET_NUM"[/color] a))) ([color=BLUE]setq[/color] p ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] [color=MAROON]"SIZE"[/color] a))) ) ([color=BLUE]vl-catch-all-apply[/color] '[color=BLUE]vla-put-name[/color] ([color=BLUE]list[/color] x ([color=BLUE]strcat[/color] [color=MAROON]"SHT "[/color] n [color=MAROON]" - "[/color] p [color=MAROON]" SHEET"[/color]))) ) ) ) ([color=BLUE]princ[/color] [color=MAROON]"\nNo \"AnaeCo_Title\" blocks found."[/color]) ) ([color=BLUE]princ[/color]) ) ([color=BLUE]vl-load-com[/color]) ([color=BLUE]princ[/color]) Lee, maybe some add in to Tabsort??? Quote
dpenney Posted August 9, 2013 Posted August 9, 2013 Try this quick code: ([color=BLUE]defun[/color] c:relay ( [color=BLUE]/[/color] a e i l n p s x ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] s ([color=BLUE]ssget[/color] [color=MAROON]"_X"[/color] '((0 . [color=MAROON]"INSERT"[/color]) (66 . 1) (2 . [color=MAROON]"AnaeCo_Title"[/color]) (410 . [color=MAROON]"~Model"[/color])))) ([color=BLUE]progn[/color] ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] i ([color=BLUE]sslength[/color] s)) ([color=BLUE]setq[/color] e ([color=BLUE]entnext[/color] ([color=BLUE]ssname[/color] s ([color=BLUE]setq[/color] i ([color=BLUE]1-[/color] i)))) x ([color=BLUE]entget[/color] e) a [color=BLUE]nil[/color] ) ([color=BLUE]while[/color] ([color=BLUE]=[/color] [color=MAROON]"ATTRIB"[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 0 x))) ([color=BLUE]setq[/color] a ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] ([color=BLUE]strcase[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 2 x))) ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 1 x))) a) e ([color=BLUE]entnext[/color] e) x ([color=BLUE]entget[/color] e) ) ) ([color=BLUE]setq[/color] l ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 410 ([color=BLUE]entget[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 330 x))))) a) l)) ) ([color=BLUE]vlax-for[/color] x ([color=BLUE]vla-get-layouts[/color] ([color=BLUE]vla-get-activedocument[/color] ([color=BLUE]vlax-get-acad-object[/color]))) ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]setq[/color] a ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] ([color=BLUE]vla-get-name[/color] x) l))) ([color=BLUE]setq[/color] n ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] [color=MAROON]"SHEET_NUM"[/color] a))) ([color=BLUE]setq[/color] p ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] [color=MAROON]"SIZE"[/color] a))) ) ([color=BLUE]vl-catch-all-apply[/color] '[color=BLUE]vla-put-name[/color] ([color=BLUE]list[/color] x ([color=BLUE]strcat[/color] [color=MAROON]"SHT "[/color] n [color=MAROON]" - "[/color] p [color=MAROON]" SHEET"[/color]))) ) ) ) ([color=BLUE]princ[/color] [color=MAROON]"\nNo \"AnaeCo_Title\" blocks found."[/color]) ) ([color=BLUE]princ[/color]) ) ([color=BLUE]vl-load-com[/color]) ([color=BLUE]princ[/color]) Brilliant! It worked a treat! However the above posters comment was quite valid, if the tabs are out of order can this lisp reorder them when updating the tab info? Cheers. DP Quote
Lee Mac Posted August 9, 2013 Posted August 9, 2013 Lee, maybe some add in to Tabsort??? Maybe Brilliant! It worked a treat! Excellent, you're welcome. However the above posters comment was quite valid, if the tabs are out of order can this lisp reorder them when updating the tab info? I believe mdbdesign was referring to my existing TabSort program - this program will enable you to sort the tabs as required. Quote
dpenney Posted August 10, 2013 Posted August 10, 2013 (edited) Maybe Excellent, you're welcome. I believe mdbdesign was referring to my existing TabSort program - this program will enable you to sort the tabs as required. Ahhh....gotcha. I must say you write some very fine 'stuff'...! Also, some very talented people in here. Cheers All DP Edited August 10, 2013 by dpenney Quote
Recommended Posts
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.