Jump to content

Blocks


B little

Recommended Posts

I have a previously converted Microstation drawing in Autocad 2011. In the conversion all blocks were given unique names. I would like to edit similar blocks globally. Many of the Microstation blocks look like the standard blocks I use. Does a Lisp routine exist that can select similar Microstation blocks and give them a single name?

Link to comment
Share on other sites

This may be one solution; call the PURGE command after to get rid of replaced blocks definitions.

;;; Replace Selected Blocks (17-IV-2012)
(defun c:RSB( / blockSource blockTarget nameBlock entBlock assocBlock )
(prompt "\nSelect source block: ")
(if (setq blockSource (ssget "_:S:E" '((0 . "INSERT"))))
 (progn
  (setq nameBlock (assoc 2 (entget (setq entBlock (ssname blockSource 0)))))
  (redraw entBlock 3)
  (prompt "\nSelect blocks to be replaced (press Enter to exit): ")
  (while (setq blockTarget (ssget "_:S:E" '((0 . "INSERT"))))
   (setq assocBlock (entget (ssname blockTarget 0)))
   (entmod (subst nameBlock
                  (assoc 2 assocBlock)
                  assocBlock))
  )
  (redraw entBlock 4)
 )
)
(princ)
)

There is no validation of source / target blocks similarity (that will be extremely difficult to do programmatically). Please use it with great care!

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