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

2 Comments:

At 10:09 AM, Anonymous Scott Wilcox said...

That's a fantastic routine! Thanks for sharing!

 
At 8:58 AM, Blogger 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

 

Post a Comment

Links to this post:

Create a Link

<< Home