Jump to content

insert block and make the force autocad updating TAGS


rodrigo_sjc_sp

Recommended Posts

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 by Bhull1985
comments
Link to comment
Share on other sites

  • Replies 25
  • Created
  • Last Reply

Top Posters In This Topic

  • rodrigo_sjc_sp

    13

  • ReMark

    8

  • Bhull1985

    3

  • Lee Mac

    2

Top Posters In This Topic

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

Link to comment
Share on other sites

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 :P

Link to comment
Share on other sites

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 by ReMark
In all my time here I have never actually billed anyone for helping them. It was a joke.
Link to comment
Share on other sites

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...