@Anonymous wrote:
so it would replace blocks on the draw, individual references and not globally from a list of blocks that i have already created that are stored on my computer
Here's a start, using two routines just for now. If they work together for you, they can be combined into one routine.
If your Blocks are all drawing files in a single folder, the following will call up a File Dialog Box which will be the list from which to select one of them:
(vl-load-com); in case needed
(defun C:GBFD (/ fname dname); = Get Block from File Dialog-box
(command
"_.INSERT"
(setq fname ; = File name -- will bring in as Block definition
(getfiled "Select drawing:" "X:/Your/Folder/Location/" "dwg" 0);<--EDIT drive & file path
); setq
); command
(command); cancel without actually Inserting one
(setq
dname (substr fname (+ (vl-string-position 92 fname 1 T) 2)); = Drawing name
bname (substr dname 1 (- (strlen dname) 4)); = Block name [dname with ".dwg" removed]
); setq
(setvar 'insname bname); set as default for Insert command
); defun
(prompt "\nType GBFD to Get a Block from a File Dialog-box in YourFolder.");<--EDIT
Run the GBFD command defined by that. It will import the selected drawing into the current drawing as a Block definition [but not actually Insert one], and will both store that Block name in the 'bname' variable and make it the current default Block name for the Insert command.
Then, run the BRS [= Block Replace by Selection] command from BlockReplace.lsp, available here. The first time you run it, it will offer Insert's default Block name [the one you just picked from the File Dialog Box] -- accept that default, and select as many existing Blocks [of any name] as you want, and they will all be turned into that Block, keeping their Layers, Scale factors, Rotation angles, etc. Thereafter, BRS will offer the Block name last used within itself, so if you bring in another using GBFD, you will [for now] need to type its name when the BRS command asks for a Block name. That can be made automatic in a combination routine if this pair of routines works for you otherwise.
Kent Cooper, AIA