Bhull1985 Posted October 24, 2013 Share Posted October 24, 2013 (edited) Please take a look at the following lisp, that will, upon being loaded into a drawing and started, remove a block with a given name from the drawing and in place of it place another specified block, done via the insertion points of the blocks so that you don't have to manually place your new block - it just goes where the old one was. As long as their insertionpoints are the same this should work well for your purposes. Only thing would be to watch for the values of those tags, as currently this program allows for you to place the attribute value within the lisp and it will come with the block, but I have only done this with single-attribute blocks i.e. stamps. That said, if the block two tags are a nil value then this would do what you need it to I believe Naturally, you would need to replace my block names with the corresponding block names for you. The bolded portions are what you'd need to change before running this. (DEFUN C:RS (/ Blks ENT1 IP oldatt) ;;; Erases all blocks named "IFC stamp" and replaces with "BID_ONLY" ;;; (ax:EraseBlock doc "IFC stamp") ;;; routine works as expected (defun ax:EraseBlock (doc bn / layout i) (vl-load-com) (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) (vlax-for layout (vla-get-layouts doc) (vlax-for i (vla-get-block layout) (if (and (= (vla-get-objectname i) "AcDbBlockReference") (= (strcase (vla-get-name i)) (strcase bn)) ) (vla-Delete i) ) ) ) ) (setq IP (cdr (assoc 10 (entget (ssname (ssget "_X" '((2 . "[b]ISSUED FOR DESIGN[/b]"))) 0))))) (ax:EraseBlock doc "[b]ISSUED FOR DESIGN[/b]") (setq oldatt (getvar "ATTREQ")) (setq oldattd (getvar "ATTDIA")) (setvar "ATTREQ" 1) (setvar "ATTDIA" 0) ;(command "purge" "all" "*" "y");code to remove reference of old block before inserting new copy of same block with additional attrib (COMMAND "INSERT" "[b]Y:/XXX/Stamps/HAZOP.DWG[/b]" IP "" "" "" "[b]10/22/2013[/b]") (setvar "ATTREQ" oldatt) (setvar "ATTDIA" oldattd) ) if this doesn't update properly because the blocks are the same name and thusly the new reference doesn't take over the old one- simply add a purge command before the last insert. I'll go ahead and do that, and then comment it out. that way if it's needed you can remove the semicolon and it will run with the code, otherwise, leave it commented. this code was taken from jtbworld and modified for my purposes....hope it helps you too. Edited October 24, 2013 by Bhull1985 comments Quote Link to comment Share on other sites More sharing options...
rodrigo_sjc_sp Posted October 24, 2013 Author Share Posted October 24, 2013 Remak, if you did not want to help not needed. Do me a favor, if not as you want to help, do not answer the topic. thank you Quote Link to comment Share on other sites More sharing options...
Bhull1985 Posted October 24, 2013 Share Posted October 24, 2013 Remark helps more often then he doesn't help. Please take a look at the code provided above Edit: 36000 posts, of course a few are going to be fluff Quote Link to comment Share on other sites More sharing options...
ReMark Posted October 24, 2013 Share Posted October 24, 2013 (edited) Let's see, I helped keep this thread alive and you are mad at me. OK. You're entirely welcomed. Have a sparkling day. Edited October 24, 2013 by ReMark In all my time here I have never actually billed anyone for helping them. It was a joke. Quote Link to comment Share on other sites More sharing options...
rodrigo_sjc_sp Posted October 24, 2013 Author Share Posted October 24, 2013 I appreciate all the help, most decided to do otherwise without using attributes. Thank you. Quote Link to comment Share on other sites More sharing options...
Bhull1985 Posted October 24, 2013 Share Posted October 24, 2013 Welcome, I think.... Would that routine take care of your issue? Quote Link to comment Share on other sites More sharing options...
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.