DavidP Posted 10 hours ago Posted 10 hours ago (edited) MyBlocks.zip (defun c:foo ( / a1 a2 oldCMDECHO s r pt folderPath BlockNames oldEnt newEnt blk ) (setq oldCMDECHO (getvar "CMDECHO") a1 (getvar "ATTDIA") a2 (getvar "ATTREQ") pt (list 0.0 0.0) s 0.5 r 0.0) (setvar "CMDECHO" 0) (setvar "ATTDIA" 0) (setvar "ATTREQ" 0) (setq folderPath "C:/MyBlocks/" BlockNames (list "BLK1.dwg" "BLK2.dwg" "BLK3.dwg")) (setq oldEnt (entlast)) (foreach blk BlockNames (setq blk (strcat folderPath blk)) (command "_.-insert" blk pt s s r) (setq newEnt (entlast)) (if (and newEnt (/= oldEnt newEnt)) (entdel newEnt) ) ) (setvar "ATTDIA" a1) (setvar "ATTREQ" a2) (setvar "CMDECHO" oldCMDECHO) (princ "\nBlocks inserted successfully.") (princ) ) Edited 9 hours ago by DavidP Attach Blocks Quote
DavidP Posted 10 hours ago Author Posted 10 hours ago (edited) I have drawing with blocks some of which have be change by the drafters... I want to re-insert & redefine the blocks from a local folder. What I'm I missing? My blocks are Dynamic blocks. Edited 10 hours ago by DavidP Added additional info Quote
Koz Posted 4 hours ago Posted 4 hours ago you may try to change: (command "_.-insert" blk pt s s r) (setq newEnt (entlast)) (if (and newEnt (/= oldEnt newEnt)) (entdel newEnt) ) to (command "_.-insert" (strcat (vl-filename-base blk) "=" blk) pt) (while (> (getvar "CMDACTIVE") 0) (command "")) (entdel(entlast)) ; Delete the temp insert block This will force AutoCAD to update a block from a drawing. you will need to make sure the block name is same as the DWG's name. Since you are working wirth dynamic blocks, the safer way is to get the dynamic property values for each block reference before update it and apply the data back to blocks after the definition is updated, in case dynamic parameters may have been changed in definition. Quote
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.