(command "._-insert" (strcat blkname "=") "_y" nil "_regen") ;<--- cancels the script...
You noticed when the block is not found, blkredef will not evaluate the line above thus it continues to the next one. Until such time it does find the block then it cancels the script
Alternative:
Code:(defun BLKREDEF ( blkname / bn blkname cmde) (vl-load-com) (setq adoc (vla-get-activedocument (vlax-get-acad-object))) (if (and (tblsearch "block" (vl-filename-base blkname)) (setq bn (findfile blkname))) (progn (vlax-invoke (vlax-get (vla-get-ActiveLayout adoc) 'Block) 'InsertBlock '(0.0 0.0 0.0) bn ;<---full path name 1 1 1 0) (entdel (entlast)) (vla-regen aDoc acActiveViewport) (princ (strcat "\nBlock " (strcase (vl-filename-base blkname)) " redefined.")) ) (princ "Block not found.") ) (prin1) )UPDATE CODE:Code:(load "D:\\lisp\\blkredef.lsp") (BlkRedef "D:\\ThisFolder\\Blocks\\TEST.dwg") (BlkRedef "D:\\OtherFolder\\Blocks\\ELEMENT.dwg") (BlkRedef "D:\\AnotherFolder\\Blocks\\BMELDER.dwg") qsave
to include path...
Note the syntax ... ".dwg" and "\\"




Reply With Quote

Bookmarks