Efeezy Posted May 26, 2010 Share Posted May 26, 2010 DOES ANYONE HAVE A QUICK AND EASY WAY TO REPLACE A SELECTED BLOCK. ALSO IS THERE A WAY TO REPLACE MULTIPLE SLECTED BLOCKS AND REPLACE WITH A DIFFERENT BLOCK TYPICAL FOR ALL THE BLOCKS THAT ARE SELECTED? I HAVE A BIG A$$ PROJECT DUE FRIDAY AND NEED TO SWAP OUT ALOT OF BLOCKS NOW... Quote Link to comment Share on other sites More sharing options...
lpseifert Posted May 26, 2010 Share Posted May 26, 2010 Ouch... not so loud Have you tried the Express Tools' Blockreplace? Quote Link to comment Share on other sites More sharing options...
Efeezy Posted May 26, 2010 Author Share Posted May 26, 2010 LOL sorry about that. Yes, I have express tools. The Blockreplace command replaces all the blocks i just want to replace the block that I have manually selected. I pulled an old stript and trying to alter it but not sure if I can pull it off though. Quote Link to comment Share on other sites More sharing options...
Efeezy Posted May 26, 2010 Author Share Posted May 26, 2010 (edited) nope couldn't get the script to work I am a not good at writing or modifying lisp my bock i need to replace is smoke 1 with smoke rb ------------------------------------------ [b]([/b]defun c:rblk [b][color=fuchsia]([/color][/b]/ pre nb ss i en ed[b][color=fuchsia])[/color][/b][b][color=fuchsia]([/color][/b]while [b][color=navy]([/color][/b]or [b][color=maroon]([/color][/b]not pre[b][color=maroon])[/color][/b][b][color=maroon]([/color][/b]not [b][color=green]([/color][/b]snvalid pre[b][color=green])[/color][color=maroon])[/color][color=navy])[/color][/b][b][color=navy]([/color][/b]setq pre [b][color=maroon]([/color][/b]getstring [color=darkslategray]"\nExisting BLOCKs Name Prefix: "[/color][b][color=maroon])[/color][color=navy])[/color][color=fuchsia])[/color][/b][b][color=fuchsia]([/color][/b]while [b][color=navy]([/color][/b]not nb[b][color=navy])[/color][/b][b][color=navy]([/color][/b]setq nb [b][color=maroon]([/color][/b]getstring [color=darkslategray]"\nNew BLOCK Name: "[/color][b][color=maroon])[/color][color=navy])[/color][/b][b][color=navy]([/color][/b]cond [b][color=maroon]([/color][color=green]([/color][/b]not [b][color=blue]([/color][/b]snvalid nb[b][color=blue])[/color][color=green])[/color][/b][b][color=green]([/color][/b]setq nb nil[b][color=green])[/color][color=maroon])[/color][/b][b][color=maroon]([/color][color=green]([/color][/b]tblsearch [color=darkslategray]"BLOCK"[/color] nb[b][color=green])[/color][color=maroon])[/color][/b][b][color=maroon]([/color][color=green]([/color][/b]findfile [b][color=blue]([/color][/b]strcat nb [color=darkslategray]".DWG"[/color][b][color=blue])[/color][color=green])[/color][/b][b][color=green]([/color][/b]command [color=darkslategray]"_.INSERT"[/color] nb[b][color=green])[/color][/b][b][color=green]([/color][/b]command[b][color=green])[/color][color=maroon])[/color][/b][b][color=maroon]([/color][/b]T [b][color=green]([/color][/b]setq nb nil[b][color=green])[/color][color=maroon])[/color][color=navy])[/color][color=fuchsia])[/color][/b][b][color=fuchsia]([/color][/b]and [b][color=navy]([/color][/b]setq ss [b][color=maroon]([/color][/b]ssget [color=darkslategray]"X"[/color] [b][color=green]([/color][/b]list [b][color=blue]([/color][/b]cons 0 [color=darkslategray]"INSERT"[/color][b][color=blue])[/color][/b][b][color=blue]([/color][/b]cons 2 [b][color=red]([/color][/b]strcat pre [color=darkslategray]"*"[/color][b][color=red])[/color][color=blue])[/color][color=green])[/color][color=maroon])[/color][color=navy])[/color][/b][b][color=navy]([/color][/b]setq i [b][color=maroon]([/color][/b]sslength ss[b][color=maroon])[/color][color=navy])[/color][/b][b][color=navy]([/color][/b]while [b][color=maroon]([/color][/b]not [b][color=green]([/color][/b]minusp [b][color=blue]([/color][/b]setq i [b][color=red]([/color][/b]1- i[b][color=red])[/color][color=blue])[/color][color=green])[/color][color=maroon])[/color][/b][b][color=maroon]([/color][/b]setq en [b][color=green]([/color][/b]ssname ss i[b][color=green])[/color][/b] ed [b][color=green]([/color][/b]entget en[b][color=green])[/color][color=maroon])[/color][/b][b][color=maroon]([/color][/b]entmod [b][color=green]([/color][/b]subst [b][color=blue]([/color][/b]cons 2 nb[b][color=blue])[/color][/b] [b][color=blue]([/color][/b]assoc 2 ed[b][color=blue])[/color][/b] ed[b][color=green])[/color][color=maroon])[/color][/b][b][color=maroon]([/color][/b]entupd en[b][color=maroon])[/color][color=navy])[/color][color=fuchsia])[/color][/b][b][color=fuchsia]([/color][/b]prin1[b][color=fuchsia])[/color][color=black])[/color][/b] Edited January 10, 2012 by SLW210 Quote Link to comment Share on other sites More sharing options...
lpseifert Posted May 26, 2010 Share Posted May 26, 2010 I've had this in my archives for a long time, hope it works for you rblock.zip Quote Link to comment Share on other sites More sharing options...
manirpg Posted May 27, 2010 Share Posted May 27, 2010 :DGood one.........its working fine...Mr.Efeezy, Are u got solution? if yes complete the target before due..................Congrats...:D Quote Link to comment Share on other sites More sharing options...
gilsoto13 Posted May 28, 2010 Share Posted May 28, 2010 (edited) DOES ANYONE HAVE A QUICK AND EASY WAY TO REPLACE A SELECTED BLOCK. ALSO IS THERE A WAY TO REPLACE MULTIPLE SLECTED BLOCKS AND REPLACE WITH A DIFFERENT BLOCK TYPICAL FOR ALL THE BLOCKS THAT ARE SELECTED? I HAVE A BIG A$$ PROJECT DUE FRIDAY AND NEED TO SWAP OUT ALOT OF BLOCKS NOW... try Bre.lsp from Alan Thompson... It's works quite well.. See updated CODE Edited January 10, 2012 by SLW210 Removed Lisp File Quote Link to comment Share on other sites More sharing options...
alanjt Posted May 28, 2010 Share Posted May 28, 2010 try Bre.lsp from Alan Thompson... It's works quite well.. I forgot all about that one. Haven't used it since the project I wrote it for. Original link Quote Link to comment Share on other sites More sharing options...
qball Posted October 6, 2010 Share Posted October 6, 2010 bre is good! Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 6, 2010 Share Posted October 6, 2010 (edited) bre is good! Glad you like it. I wish I could remove that old version gilsoto posted, but here's an updated version: (defun c:BRE (/ *error* blk f ss temp) ;; Replace multiple instances of selected blocks (can be different) with selected block ;; Size and Rotation will be taken from original block and original will be deleted ;; Required subroutines: AT:GetSel ;; Alan J. Thompson, 02.09.10 (vl-load-com) (defun *error* (msg) (and f *AcadDoc* (vla-endundomark *AcadDoc*)) (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,"))) (princ (strcat "\nError: " msg)) ) ) (if (and (AT:GetSel entsel "\nSelect replacement block: " (lambda (x / e) (if (and (eq "INSERT" (cdr (assoc 0 (setq e (entget (car x)))))) (/= 4 (logand (cdr (assoc 70 (tblsearch "BLOCK" (cdr (assoc 2 e))))) 4)) (/= 4 (logand (cdr (assoc 70 (entget (tblobjname "LAYER" (cdr (assoc 8 e)))))) 4)) ) (setq blk (vlax-ename->vla-object (car x))) ) ) ) (princ "\nSelect blocks to be repalced: ") (setq ss (ssget "_:L" '((0 . "INSERT")))) ) (progn (setq f (not (vla-startundomark (cond (*AcadDoc*) ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) ) ) ) ) (vlax-for x (setq ss (vla-get-activeselectionset *AcadDoc*)) (setq temp (vla-copy blk)) (mapcar (function (lambda (p) (vl-catch-all-apply (function vlax-put-property) (list temp p (vlax-get-property x p)) ) ) ) '(Insertionpoint Rotation XEffectiveScaleFactor YEffectiveScaleFactor ZEffectiveScaleFactor ) ) (vla-delete x) ) (vla-delete ss) (*error* nil) ) ) (princ) ) (defun AT:GetSel (meth msg fnc / ent good) ;; meth - selection method (entsel, nentsel, nentselp) ;; msg - message to display (nil for default) ;; fnc - optional function to apply to selected object ;; Ex: (AT:GetSel entsel "\nSelect arc: " (lambda (x) (eq (cdr (assoc 0 (entget (car x)))) "ARC"))) ;; Alan J. Thompson, 05.25.10 (setvar 'errno 0) (while (not good) (setq ent (meth (cond (msg) ("\nSelect object: ") ) ) ) (cond ((vl-consp ent) (setq good (cond ((or (not fnc) (fnc ent)) ent) ((prompt "\nInvalid object!")) ) ) ) ((eq (type ent) 'STR) (setq good ent)) ((setq good (eq 52 (getvar 'errno))) nil) ((eq 7 (getvar 'errno)) (setq good (prompt "\nMissed, try again."))) ) ) ) Edited December 2, 2010 by alanjt Quote Link to comment Share on other sites More sharing options...
justindm Posted December 2, 2010 Share Posted December 2, 2010 I'm trying to run the above but get an error: "Error: no function definition: VLAX-ENAME->VLA-OBJECT" Some of the blocks I'm selecting have spaces, dashes and underscores...could that be a problem? Quote Link to comment Share on other sites More sharing options...
alanjt Posted December 2, 2010 Share Posted December 2, 2010 add (vl-load-com) to the code Quote Link to comment Share on other sites More sharing options...
alanjt Posted December 2, 2010 Share Posted December 2, 2010 Recopy the code, I added (vl-load-com). Quote Link to comment Share on other sites More sharing options...
justindm Posted December 2, 2010 Share Posted December 2, 2010 Perfecto!!!!!!!! You're so awesome. This is awesome. You're a life saver. Can't thank you enough. Quote Link to comment Share on other sites More sharing options...
alanjt Posted December 2, 2010 Share Posted December 2, 2010 Perfecto!!!!!!!! You're so awesome. This is awesome. You're a life saver. Can't thank you enough. Enjoy. .............. Quote Link to comment Share on other sites More sharing options...
yellowburros123 Posted January 3, 2012 Share Posted January 3, 2012 Thanks! Bre worked great Quote Link to comment Share on other sites More sharing options...
alanjt Posted January 3, 2012 Share Posted January 3, 2012 Thanks! Bre worked great You're welcome. Be sure to use the one I posted, not the very old version gilsoto posted. Quote Link to comment Share on other sites More sharing options...
Saqib_theleo Posted September 1, 2012 Share Posted September 1, 2012 Glad you like it. I wish I could remove that old version gilsoto posted, but here's an updated version: (defun c:BRE (/ *error* blk f ss temp) ;; Replace multiple instances of selected blocks (can be different) with selected block ;; Size and Rotation will be taken from original block and original will be deleted ;; Required subroutines: AT:GetSel ;; Alan J. Thompson, 02.09.10 (vl-load-com) (defun *error* (msg) (and f *AcadDoc* (vla-endundomark *AcadDoc*)) (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,"))) (princ (strcat "\nError: " msg)) ) ) (if (and (AT:GetSel entsel "\nSelect replacement block: " (lambda (x / e) (if (and (eq "INSERT" (cdr (assoc 0 (setq e (entget (car x)))))) (/= 4 (logand (cdr (assoc 70 (tblsearch "BLOCK" (cdr (assoc 2 e))))) 4)) (/= 4 (logand (cdr (assoc 70 (entget (tblobjname "LAYER" (cdr (assoc 8 e)))))) 4)) ) (setq blk (vlax-ename->vla-object (car x))) ) ) ) (princ "\nSelect blocks to be repalced: ") (setq ss (ssget "_:L" '((0 . "INSERT")))) ) (progn (setq f (not (vla-startundomark (cond (*AcadDoc*) ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) ) ) ) ) (vlax-for x (setq ss (vla-get-activeselectionset *AcadDoc*)) (setq temp (vla-copy blk)) (mapcar (function (lambda (p) (vl-catch-all-apply (function vlax-put-property) (list temp p (vlax-get-property x p)) ) ) ) '(Insertionpoint Rotation XEffectiveScaleFactor YEffectiveScaleFactor ZEffectiveScaleFactor ) ) (vla-delete x) ) (vla-delete ss) (*error* nil) ) ) (princ) ) (defun AT:GetSel (meth msg fnc / ent good) ;; meth - selection method (entsel, nentsel, nentselp) ;; msg - message to display (nil for default) ;; fnc - optional function to apply to selected object ;; Ex: (AT:GetSel entsel "\nSelect arc: " (lambda (x) (eq (cdr (assoc 0 (entget (car x)))) "ARC"))) ;; Alan J. Thompson, 05.25.10 (setvar 'errno 0) (while (not good) (setq ent (meth (cond (msg) ("\nSelect object: ") ) ) ) (cond ((vl-consp ent) (setq good (cond ((or (not fnc) (fnc ent)) ent) ((prompt "\nInvalid object!")) ) ) ) ((eq (type ent) 'STR) (setq good ent)) ((setq good (eq 52 (getvar 'errno))) nil) ((eq 7 (getvar 'errno)) (setq good (prompt "\nMissed, try again."))) ) ) ) Hi Alan J, I've been searching for a block replace Lisp for three days but couldn't find any good one. I found this lisp it is working nice, I wanted to ask is it possible to make this lisp a batch block replacement so that you don't need to open every drawing to change blocks. I have to replace old blocks from new blocks in more than 300 drawings. If it is possible plz tell. Thanks for your previous (BRE) Lisp too. Quote Link to comment Share on other sites More sharing options...
Traci Dennis Posted July 11, 2013 Share Posted July 11, 2013 Do you have a similar routine that wors with attributes? I often have to change (blocks with attributes) parts of my drawing from proposed to existing. The blocks are the same except for color and font style. Thanks Quote Link to comment Share on other sites More sharing options...
ReMark Posted July 11, 2013 Share Posted July 11, 2013 Take a look at Lee Mac's Batch Attribute Editor. http://lee-mac.com/batte.html 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.