Search This Blog

Tuesday, June 16, 2009

Block Insertion Swap Routine for AutoCAD

I was asked today if I knew of a way to swap out a single block for another block? I knew that the Express tools could do this, but a global block redefinition was not what we were looking for.

So I did a quick search in the AUGI lisp forums and found a routine posted by Miff that was close to doing what I needed. In reviewing the routine, I realized that it would be nice to allow single or multiple selection. I modified the routine slightly to remove the SSGET modifier for single selection (ssget "_:S") resulting in this code:

(if (and (setq ss (ssget ":S" '((0 . "INSERT"))))
becoming this code:

(if (and (setq ss (ssget '((0 . "INSERT"))))

Since I wanted all the staff to be able to utilize this routine, I added an autoloader to the company standard acaddoc.lsp file and placed the newly named "blkswap.lsp" file out in the network applications folder:

(autoload "blkswap" '("blkswap"))

You're welcome to download my modified version here:blkswap.lsp
Or grab Miff's original from the AUGI forums.
Thanks Miff!
Thanks to AUGI as well for providing such a fantastic resource.

Here is a short video detailing how to use the routine once it is available via autoload.
video

4 comments:

Scott Wilcox said...

That's a fantastic routine! Thanks for sharing!

Richard Binning said...

Thanks Scott,

I knew others would find it handy.
Its a good example of the benefit of being an AUGI member. While the routine as it existed on AUGI didn't do exactly what I wanted, it was close enough to be quickly modified to suit the needs at present.

~Richard

Rachel said...

looks like your modified routine is missing, can you repost it? Would be very much appreciated!

Richard Binning said...

Hi Rachel,

Sorry for the delay. I fixed the link and its working again.

Richard