Lisp to replace block with another block

Lisp to replace block with another block

Manicbala
Enthusiast Enthusiast
23,546 Views
22 Replies
Message 1 of 23

Lisp to replace block with another block

Manicbala
Enthusiast
Enthusiast

Hi,

 

I have tried the below lisp to replace the block "RR" with "Level".


(defun C:QW4 ()

((C:-BLOCKREPLACE) "RR" "level" ""))

 

{{ Command: QW4
Initializing...
Select the block to be replaced or [?/= (select object)]: }}

 

After enter QW4 command, its prompting to select the block instead of replacing. Please resolve this.

 

Bala

Thanks
Bala
0 Likes
Accepted solutions (1)
23,547 Views
22 Replies
Replies (22)
Message 21 of 23

BL_Apex
Enthusiast
Enthusiast

So it appears that running INSERT and selecting the block from the folder it's saved in will prompt for "Redefine Block" but running -INSERT from the command line or LISP does not. Even though the block .dwg has been updated with a new definition and I'm specifically calling up that file location in the command line/LISP, AutoCAD is still inserting the old definition without asking if I'd like to replace the existing definition. I even tried copying the .dwg with the new block definition to a different file location and calling that up, but got the same result.

 

UPDATE: I figured it out. I realized what you were hinting at is that it needs to be formatted as:

(command "-insert" "BLOCKNAME=filelocation/BLOCKNAME.dwg" ...)

 

Thanks.

0 Likes
Message 22 of 23

Anonymous
Not applicable

Had a similar issue with replacing a block.  This piece of code helped me greatly.

 

0 Likes
Message 23 of 23

ChicagoLooper
Mentor
Mentor

BLOCKREPLACE Command..

 

Express Tools Tab=>Blocks Panel=>Replace Block Icon

 

1.png

 

 

Chicagolooper

EESignature

0 Likes