gamulj Posted May 20, 2015 Share Posted May 20, 2015 Hi to all! I'am building the title block (block with attributes) and I need a routine that will automatically read layout name, in multi layout dwg, and write it into block attribute „LAYOUT“ for every layout. Field with Ctab doesn't suits my needs... Is something like this possible? Thanks! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 20, 2015 Share Posted May 20, 2015 Yes it is possible . What is the name of your attributed title block ? Quote Link to comment Share on other sites More sharing options...
gamulj Posted May 20, 2015 Author Share Posted May 20, 2015 Yes it is possible . What is the name of your attributed title block ? Hi Tharwat! The name of block is TITLEBLOCK. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 20, 2015 Share Posted May 20, 2015 Here we go , try this program . (defun c:Test nil ;;------------------------------------;; ;; Tharwat 20.05.2015 ;; ;; Modify Title Blocks that have ;; ;; Tag name "LAYOUT" wiht its ;; ;; location is each Layout's Name ;; ;;------------------------------------;; (vlax-for x (vla-get-layouts (vla-get-ActiveDocument (vlax-get-acad-object))) (if (/= (vla-get-name x) "Model") (vlax-for b (vla-get-block x) (and (eq (vla-get-objectname b) "AcDbBlockReference") (eq (vla-get-effectivename b) "TILTEBLOCK") (vl-some '(lambda (a) (if (eq "LAYOUT" (strcase (vla-get-tagstring a))) (vla-put-textstring a (vla-get-name x)) ) ) (vlax-invoke b 'getattributes) ) ) ) ) ) (princ) )(vl-load-com) Quote Link to comment Share on other sites More sharing options...
gamulj Posted May 20, 2015 Author Share Posted May 20, 2015 I will try, Thanks! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 20, 2015 Share Posted May 20, 2015 I will try,Thanks! Okay , I will be waiting for your try and reply . Quote Link to comment Share on other sites More sharing options...
gamulj Posted May 20, 2015 Author Share Posted May 20, 2015 Works great! Is there a way to make lisp automatically recall on open/save or refresh? Thanks a million!!! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 20, 2015 Share Posted May 20, 2015 Works great! Thanks a million!!! Excellent . You are most welcome . Is there a way to make lisp automatically recall on open/save or refresh? You must be in need of running the program on many drawing files . mustn't you ? Open and save commands shouldn't work , so you need to a third party program to do processing on a list of drawing files . Quote Link to comment Share on other sites More sharing options...
gamulj Posted May 20, 2015 Author Share Posted May 20, 2015 Excellent . You are most welcome . You must be in need of running the program on many drawing files . mustn't you ? Open and save commands shouldn't work , so you need to a third party program to do processing on a list of drawing files . Exactly! You know some? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 20, 2015 Share Posted May 20, 2015 If you don't have that much of files to implement the program on , just add this (c:Test) to the program after the last parenthesis and add the lisp file to the briefcase of the appload command then just open the drawings you want to run the program in and the program should run automatically and do the job solely then just save and close the drawing to have the new changes saved . Quote Link to comment Share on other sites More sharing options...
gamulj Posted May 20, 2015 Author Share Posted May 20, 2015 If you don't have that much of files to implement the program on , just add this (c:Test) to the program after the last parenthesis and add the lisp file to the briefcase of the appload command then just open the drawings you want to run the program in and the program should run automatically and do the job solely then just save and close the drawing to have the new changes saved . Works perfectly:) Tharwat, you made my day! Thanks again! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 20, 2015 Share Posted May 20, 2015 Works perfectly:) Tharwat, you made my day! Thanks again! You are most welcome . Quote Link to comment Share on other sites More sharing options...
ramcharger318 Posted November 29, 2016 Share Posted November 29, 2016 Can this be modified to use in a field to get the current tab's name? The CTAB variable doesn't work with data extractions. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 29, 2016 Share Posted November 29, 2016 Can this be modified to use in a field to get the current tab's name? The CTAB variable doesn't work with data extractions. Try this mods. (defun c:Test (/ doc ) ;; Tharwat - 29.Nov.2016 ;; (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) (vlax-for x (vla-get-layouts doc) (if (/= (vla-get-name x) "Model") (vlax-for b (vla-get-block x) (and (eq (vla-get-objectname b) "AcDbBlockReference") (eq (vla-get-effectivename b) "TILTEBLOCK") (vl-some '(lambda (a) (and (eq "LAYOUT" (strcase (vla-get-tagstring a))) (progn (vla-put-textstring a "%<\\AcVar ctab>%") t) ) ) (vlax-invoke b 'getattributes) ) ) ) ) ) (vla-regen doc acAllViewports) (princ) )(vl-load-com) Quote Link to comment Share on other sites More sharing options...
ramcharger318 Posted November 29, 2016 Share Posted November 29, 2016 I'm not sure how to use it. I tried copying it into the diesel expression in the field, but it says invalid field code. I have part files that use the layout name in the part name, so that the name is automated. However, when a data extraction is done, it only uses that last saved tab. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 29, 2016 Share Posted November 29, 2016 Just be sure to copy all posted codes above to a new txt file and save it with an extension of .lsp then back to AutoCAD and type the command name: APPLOAD or AP then selected the lisp file, then finally type test to run the lisp routine and you should have the block name "TITLEBLOCK" modified with its related Layout name that is resides in. Quote Link to comment Share on other sites More sharing options...
ramcharger318 Posted November 29, 2016 Share Posted November 29, 2016 I'm trying to avoid user interaction. When the user/draftsperson creates a new part, I don't want to have to rely on that person to run the command. The part name attribute has the filename variable and CTAB variable plus an increasing number to identify the part. So if that part is in the VM file on the "3" tab the part would be VM-3-X, where the x is any number. Your code extracts the layout name without the use of the CTAB variable, and I would like to put that into a field in a attribute, maybe via a diesel expression. Quote Link to comment Share on other sites More sharing options...
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.