jesus perez Posted December 16, 2024 Posted December 16, 2024 Hi everyone, I have looked for something similar here but have not succeeded. I have several drawings in a folder that I need to open one by one, delete a block, purge the block, and finally paste the new block version. The new block version is in another dwg, which I copied with the base point 0,0. The pasting is in the same coordinate, 0,0. All the blocks (the new version) and the old to be replaced have the same name and are located in the layout at 0,0 (not in the model). I do need to run the purge command after deleting so the block is pated with the new changes. I'm wondering if any of you have an LISP file that can help me automate this process. The inputs could be the Block name, the route of the new block version, and the folder route with the other drawings where the block will be replaced. Another option could be that the lisp is executed over the drawings opened in the current session, and the new block is taken from the active drawing where the command is executed. Quote
Emmanuel Delay Posted December 17, 2024 Posted December 17, 2024 I wrote a post about auto executing a command in batch. It should work on this problem as well 1 Quote
Steven P Posted December 17, 2024 Posted December 17, 2024 (edited) Lee Mac has a blocks delete LISP which I think you can modify to remove user interaction https://lee-mac.com/deleteblocks.html for Lee Macs code Below to remove the block, note the c:blockdelbatch is as an example, removing the block revtriangle (as part of a list that you can add to). You need Lee Macs LISP above. And then just insert the new block. Can use something like Lee Macs script writer to do the batch processing. (defun c:blockdelbatch (/ deletelst) (setq deletelst (list "revtriangle")) (blksdelbatch deletelst) ) (defun blksdelbatch ( lst / *error* del lst ) (defun *error* ( msg ) (LM:endundo (LM:acdoc)) (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")) (princ (strcat "\nError: " msg)) ) (princ) ) (cond ( t (LM:startundo (LM:acdoc)) (setq del (LM:DeleteBlocks (LM:acdoc) lst)) (vla-regen (LM:acdoc) acallviewports) (foreach block lst (if (member (strcase block) del) (princ (strcat "\nDeleted block " block ".")) (princ (strcat "\nUnable to delete block " block ".")) ) ) (LM:endundo (LM:acdoc)) ) ) (princ) ) Edit. Nearly forgot to say, if this is a simple single block, copy the bock to the clipboard and use (command "pasteclip" "0,0") Edited December 17, 2024 by Steven P 1 Quote
rlx Posted December 17, 2024 Posted December 17, 2024 I wrote this program like four years ago (just for fun / exercise) and maybe used it once or twice so as we say here on Mars : guaranteed to the doorstep If it works : , if it doesn't ... As usual never wrote a manual so have fun experimenting. RlxBlockSync.lsp 5 Quote
BIGAL Posted December 17, 2024 Posted December 17, 2024 (edited) What about wblock out the new block to a separate dwg name it the current block name, then insert that block dwg into your current dwg, you should get a "do you want to redefine block", may also need attsync on the block. Did this where we changed company address and updated older projects. Edited December 17, 2024 by BIGAL Quote
rlx Posted December 18, 2024 Posted December 18, 2024 Just wanted something more flexible , user friendly and sexier for me , myself and I 2 Quote
pkenewell Posted December 18, 2024 Posted December 18, 2024 This is a double post from the Autodesk Forums. I wonder if the OP has even looked back at this one with all the activity on the other post: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/looking-for-a-lisp-to-replace-a-block-with-another-version-of/td-p/13214305 1 Quote
rlx Posted December 18, 2024 Posted December 18, 2024 now you tell me I like this quote : “Life is not obliged to give us what we expect.” Sure , some users don't respond or don't give a like but unlike some users , I don't feel the need to respond to every thread or want to collect as many likes as I can for the sake of reputation points. Most of us are here just to give a helping hand to those who ask for it and expecting eternal glory or whatever only leads to disappointment. Having said this , I am gratefull for everybody who liked my post. It does give a feeling of appreciation. Even when OP is a No Show , others may still find your response useful. So when you do deal with a 'leacher' , just append his folder with "_No_Show" so next time you feel the urge to respond you can lower your expection for ever getting a response. 2 1 Quote
Steven P Posted December 18, 2024 Posted December 18, 2024 A like... see what I did there.... 1 1 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.