Allan_LT Posted April 25, 2023 Posted April 25, 2023 Hi, Could someone point me in the direction where I could find a lisp routine that will allow me to change the revision number (attribute within a block). For example, if I had ten layouts in one drawing file and they all wanted to be changed from the current value to "AB" The block is called "A3 Title Block" and the attribute is "REVISION" I can't use FIELDS/ DWGPROPS as each layout (title block) could be a different revision number. Many thanks for any assistance. I have placed this query in the ACAD LT forum as I understand the lisp in LT does not offer all the functionality of the lisp in the full AutoCAD. Quote
SLW210 Posted April 25, 2023 Posted April 25, 2023 I believe only AutoCAD LT 2024 has LISP. It may help to post a .dwg with the block. I will move this to the LISP form, as this is LISP related. autolisp-visual-lisp Quote
Allan_LT Posted April 25, 2023 Author Posted April 25, 2023 blank template.dwg Yes, that's correct, it has just become available for ACAD LT 2024. I have attached a .dwg with a blank title block which includes the relevant attribute. Many thanks. Quote
mhupp Posted April 26, 2023 Posted April 26, 2023 (edited) Get express tools. and then gatte Command. -Edit The lisp way. The first lisp only works with AutoCAD using getpropertyvalue & setpropertyvalue so it doesn't have to check each attribute. but I can't check the code for errors. because it doesn't work with my version of BricsCAD. the 2nd lisp works with BricsCAD and other cad software. the 3rd lisp cycles though each layout and calls the first or 2nd lisp. ;;----------------------------------------------------------------------------;; ;; Update Revision on Title Block in current layout AUTOCAD ONLY (defun C:revup (/ ss blk atts x oTag nTag att) (if (and (= (getvar 'Tilemode) 0) (setq ss (ssget "X" (list '(0 . "INSERT") '(66 . 1) '(2 . "Title Block") (cons 410 (getvar 'ctab)))))) (progn (setq blk (ssname SS 0)) (setq oTag (getpropertyvalue blk "REVISION")) (if (= "" (setq nTag (getstring T (strcat "\nRevision <" oTag ">: ")))) (setq nTag oTag) ) (setpropertyvalue blk "REVISION" nTag) ) (prompt "\nTitle Block With Revision ATTRIBUTE not found") ) (princ) ) ;;----------------------------------------------------------------------------;; ;; Update Revision on Title Block in current layout (defun C:revup (/ ss blk atts x oTag nTag att) (CHECK) (if (and (= (getvar 'Tilemode) 0) (setq ss (ssget "X" (list '(0 . "INSERT") '(66 . 1) '(2 . "A3 Title Block"") (cons 410 (getvar 'ctab)))))) (progn (setq blk (vlax-ename->vla-object (ssname SS 0)) atts (vlax-safearray->list (vlax-variant-value (vla-getattributes blk))) ) (foreach x atts (if (= (vla-get-tagstring x) "REVISION") ; FIND TOOLS ATTRIBUTE (setq oTag (vla-get-textstring x)) ; save it's value ) ) (if (= "" (setq nTag (getstring T (strcat "\nTool Count <" oTag ">: ")))) (setq nTag oTag) ) (vl-some '(lambda (att) (if (= "REVISION" (strcase (vla-get-tagstring att))) (vla-put-textstring att nTag) ) ) (vlax-invoke blk 'getattributes) ) ) (prompt "\nTitle Block With Revision ATTRIBUTE not found") ) (princ) ) ;;----------------------------------------------------------------------------;; ;; cycle thought All Tabs and change revision. (defun C:revall (/ tab) (foreach tab (layoutlist) (setvar "ctab" tab) (C:Tool) ) (princ) ) Edited April 26, 2023 by mhupp Quote
BIGAL Posted April 26, 2023 Posted April 26, 2023 My attempt ; crusde version of update 1 attribute in a title block in multiple layoouts ; By AlanH April 2023 (defun c:wow ( / bname tagname newstr lay lays ss1 ) (setq bname "TITLE BLOCK") (setq tagname "REVISION") (setq newstr (getstring "\nEnter new text ")) (setq lays (layoutlist)) (Foreach lay lays (setq ss1 (ssget "x" (list (cons 0 "INSERT") (cons 2 bname)(cons 410 lay)))) (foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 0 )) 'getattributes) (if (= tagname (strcase (vla-get-tagstring att))) (vla-put-textstring att newstr) ) ; end if ) ; end foreach ) ; end foreach (princ) ) (c:wow) See pm I sent you Quote
Allan_LT Posted April 26, 2023 Author Posted April 26, 2023 Thanks, BIGAL. That worked a treat. Quote
Allan_LT Posted April 26, 2023 Author Posted April 26, 2023 Hi mhupp, I am using ACAD LT 2024 so don't have express tools. I tried your code and the one to change individual layouts worked perfect. so thank you. The "revall" throws up an error "; error: no function definition: C:TOOL" but BIGAL code worked for changing all layouts. Quote
ronjonp Posted April 26, 2023 Posted April 26, 2023 (edited) This can also be accomplished without code. Use QSELECT or FILTER. Then select all and make the change in the properties palette. Edited April 26, 2023 by ronjonp Quote
Allan_LT Posted April 26, 2023 Author Posted April 26, 2023 Thanks, Ronjonp. That is a valid point. Quote
SLW210 Posted April 27, 2023 Posted April 27, 2023 You might see if this LISP helps....Access Block Attributes Across Multiple File Tabs | CAD Tips (cadalyst.com) 2024LT has Sheet Sets, maybe look into using them. You mentioned "I can't use FIELDS/ DWGPROPS as each layout (title block) could be a different revision number." 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.