CafeJr Posted January 21, 2015 Posted January 21, 2015 Hi Guys, Someone knows a Lisp used to replace a internal block(s) of a folder with dwg many files. Eg: The specific folder has a "n" files with A3 formats blocks using the same attributes and tags, so, if it's necessary do a correction in a little detail in this format, it's necessary to replace it, one by one on all of these files. Thanks in advance... Quote
BIGAL Posted January 21, 2015 Posted January 21, 2015 To clarify you want to totally replace the block with another but keep atribute values or just update various attributes of the block. The 1st step is to post a dwg or maybe two before-after. Quote
ttray33y Posted January 21, 2015 Posted January 21, 2015 if you to keep all the attribute values, then its easy. 1.) Create a Wblock for your new block. 2.) Save it in a directory you commonly used (for your convenience). 3.) Add that directory path to your Support File Search Path in Autocad Options. 4.) Just be sure that the basepoint of your new block and your old block are the same. 5.) Create a script. 6.) Install script pro. 7.) Run script pro, select your drawings & script then run. Note: test this with 1 drawing first. CMDECHO 0 ATTREQ 0 -insert [color=red]YOUR_NEW_BLOCK_NAME[/color] 0,0,0 1.0 1.0 0.0 -blockreplace [color=red]YOUR_OLD_BLOCK_NAME[/color] [color=red]YOUR_NEW_BLOCK_NAME[/color] y erase l zoom e CMDECHO 1 ATTREQ 1 ; been doing this procedure for about 2 years now in 200-600 drawings. Quote
CafeJr Posted January 21, 2015 Author Posted January 21, 2015 To clarify you want to totally replace the block with another but keep atribute values or just update various attributes of the block. The 1st step is to post a dwg or maybe two before-after. Bigal, the best way it's keep the attribute values for all dwg files because every page has your specific title or a specific detail. After the alteration/correction block it will be replaced in all files in that folder with your previous information. Thanks... Quote
CafeJr Posted January 21, 2015 Author Posted January 21, 2015 if you to keep all the attribute values, then its easy.1.) Create a Wblock for your new block. 2.) Save it in a directory you commonly used (for your convenience). 3.) Add that directory path to your Support File Search Path in Autocad Options. 4.) Just be sure that the basepoint of your new block and your old block are the same. 5.) Create a script. 6.) Install script pro. 7.) Run script pro, select your drawings & script then run. Note: test this with 1 drawing first. been doing this procedure for about 2 years now in 200-600 drawings. Thanks ttray33y I'll try it!... Quote
ttray33y Posted January 21, 2015 Posted January 21, 2015 Thanks ttray33y I'll try it!... You're Welcome. Quote
abra-CAD-abra Posted January 21, 2015 Posted January 21, 2015 I use this, by Lee-Mac - Works every time! Thank you Lee. ;----------------------------------------------------------------------------------------------------------------- ;http://www.cadtutor.net/forum/archive/index.php/t-52973.html ;----------------------------------------------------------------------------------------- (defun ReDef (block / *error* oc spc doc block) (vl-load-com) ;; © Lee Mac 2010 (defun *error* (msg) (and oc (setvar 'CMDECHO oc)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **")) ) (princ) ) (setq spc (if (or (eq AcModelSpace (vla-get-ActiveSpace (setq doc (vla-get-ActiveDocument (vlax-get-acad-object) ) ) ) ) (eq :vlax-true (vla-get-MSpace doc)) ) (vla-get-ModelSpace doc) (vla-get-PaperSpace doc) ) ) (setq oc (getvar 'CMDECHO)) (setvar 'CMDECHO 0) (if (setq block (findfile block)) (progn (vla-delete (vla-insertblock spc (vlax-3D-point '(0. 0. 0.)) block 1. 1. 1. 0. ) ) (vl-cmdf "_.attsync" "_N" (vl-filename-base block)) ) ) (setvar 'CMDECHO oc) (princ) ) ;;Call like this: ;;(Redef "C:\\MyFolder\\MyBlock.dwg") Quote
ttray33y Posted January 21, 2015 Posted January 21, 2015 I also use the LISP above by Lee, however i think, it only works if your new and old block shares the same name. redefine and replace are 2 different term, i believe. Quote
abra-CAD-abra Posted January 21, 2015 Posted January 21, 2015 I also use the LISP above by Lee, however i think, it only works if your new and old block shares the same name.redefine and replace are 2 different term, i believe. My apologies, I didn't read the whole thread. Note to self: Always read the thread! Cheers, Quote
ttray33y Posted January 21, 2015 Posted January 21, 2015 My apologies, I didn't read the whole thread. Note to self: Always read the thread! Cheers, You dont have to apologies my friend, there was nothing wrong with the post you made, I only explain how Mr.Lee's LISP works. Quote
CafeJr Posted January 21, 2015 Author Posted January 21, 2015 Thanks to all, I'll use both of them!... Thanks again!!!... 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.