pmxcad Posted February 4, 2012 Posted February 4, 2012 Hello, I found a lisp on the web to update blocks with a lisp en it is running via a script file. If the scrip is running, it searches for a new version of that block. If Autocad can`t find the file he going to the next block in the script. As Autocad find that block, he updates the block. Now comes the problem: after updating that block the script should go to the next block in the script but it stops. So if it`s founds nothing, it goes to to the next one, if it founds one and update that block.it stops. Has this lisp/script problem with this versions of Acad or is it an system varaible ore something else. Please help. Thanks, PmxCAD blkredef.scr blkredef.lsp Quote
pBe Posted February 5, 2012 Posted February 5, 2012 (edited) (command "._-insert" (strcat blkname "=") "_y" nil "_regen") ; 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: (defun BLKREDEF ( blkname / bn blkname cmde) (vl-load-com) (setq adoc (vla-get-activedocument (vlax-get-acad-object))) (if (and (tblsearch "block" [color=blue][b](vl-filename-base blkname)[/b][color=black])[/color] [/color] (setq bn (findfile [color=blue][b]blkname[/b][/color]))) (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 [color=blue][b](vl-filename-base blkname)[/b][/color]) " redefined.")) ) (princ "Block not found.") ) (prin1) ) (load "D:\\lisp\\blkredef.lsp") (BlkRedef [color=blue][b]"D:\\ThisFolder\\Blocks\\TEST.dwg"[/b])[/color] (BlkRedef [b][color=blue]"D:\\OtherFolder\\Blocks\\ELEMENT.dwg"[/color][/b]) (BlkRedef "[color=blue][b]D:\\AnotherFolder\\Blocks\\BMELDER.dwg"[/b][/color]) qsave UPDATE CODE: to include path... Note the syntax ... ".dwg" and "\\" Edited February 8, 2012 by pBe Add lisp code Quote
pBe Posted February 6, 2012 Posted February 6, 2012 Works.....super. Tanks, PmxCAD Good for you, Glad i could help Quote
pmxcad Posted February 7, 2012 Author Posted February 7, 2012 Hello again. It`s working perfect, but................a`m working with diffrent projects and diffrent blokcs map/directory, same blocks (names) but with other atributes so the first one in the search-pad is not always ok. Question, is it also possible to rebild the lisp so i can put the pad to the blocks directory/map, in the script file? Thanks Pmxcad Quote
pmxcad Posted February 11, 2012 Author Posted February 11, 2012 Works super....again. Thanks, PmxCAD 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.