Jump to content

blkredef.lsp/scr not working in Acade 2010/2012


Recommended Posts

Posted

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

Posted (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 by pBe
Add lisp code
Posted

Works.....super.

 

Tanks,

 

PmxCAD

Posted
Works.....super.

 

Tanks,

 

PmxCAD

 

Good for you, Glad i could help :)

Posted

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

Posted

Works super....again.

 

Thanks,

PmxCAD

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...