Jump to content

NEED HELP IN RENAMING ONE BLOCK IN MULTIPLE CAD FILES


williamferenal

Recommended Posts

Hi All,

Apologies if this has been solved before but I have searched for hours and counting but to no success.

I currently a title block in multiple cad files that needs to be renamed. This title block is exported from REVIT so it has unique names on it as shown in the attachment.

There are parts of the block name that are consistent throughout the cad files so I suspect a wildcard search is needed. I just don't know how to do it.

Is there any lisp that I can use to rename the title blocks using a wildcard search?

I want them renamed to "TITLE BLOCK 1"

Any help would be much appreciated

Untitled.jpg

Link to comment
Share on other sites

It's a title block, so I presume you want to keep the attributes data, right?

 

Because just renaming a block without attributes; there I would just delete the block and insert a new one.

 

Maybe it's still the simplest solution.  Do all these blocks have the same attributes? Same attribute names?

Link to comment
Share on other sites

Just a quick search,  this shows how to filter a selection set to a block name

 

 

 

(if (setq ss (ssget '((0 . "INSERT") (2 . "block1,block2,block3") (410 . "Model"))))

 

 

and you can change model to a layout name if needed, without checking I think you should be able to do the block name as a wildcard ( '*' )

 

and I think you can use this line to rename it:

 

(command "rename" "b" OLD_NAME NEW_NAME)

 

 

I don't have anything put together to do all of this, someone might, but would this be enough to get you started? Get it working on a single drawing and then depending how many drawings you have can look at a script or batch process to do lots of them all at once

Link to comment
Share on other sites

Hi Emmanuel, thanks for the reply. The title block does not have any attributes to it. All the attributes, ie title of the drawing, dates, drawing numbers are on a separate Block.

Yes I have thought of what you suggested but I was kinda hoping to have something automated as it will require me to open around 100 drawings per package.

Link to comment
Share on other sites

Use LeeMacs  spectacular BFIND  (Batch Find)  Just open one of the drawings in the folder, then set it to do the whole folder without needing to open them.  It may take a minute or two, then will tell you what it did in a spreadsheet.

 

Thanks Lee!   :beer:

Edited by Dadgad
Link to comment
Share on other sites

and this mighty just work - check it out and then see where you need to go from there?

 

(defun c:renameblock ( / ss OLD_NAME NEW_NAME)
  (setq NEW_NAME "My New Name")
  (if (setq ss (ssget "X" '((0 . "INSERT") (2 . "*Name") (410 . "Layout1"))))  ;;note case sensitive
    (PROGN
      (setq OLD_NAME (cdr (assoc 2 (entget (ssname ss 0)))))
      (command "rename" "b" OLD_NAME NEW_NAME)
    )
  )
)

 

Link to comment
Share on other sites

26 minutes ago, Dadgad said:

Use LeeMacs  spectacular BFIND  (Batch Find)  Just open one of the drawings in the folder, then set it to do the whole folder without needing to open them.  It may take a minute or two, then will tell you what it did in a spreadsheet.

 

Thanks Lee!   :beer:

 

Will that change block name, I know it will replace attributes but didn't think it did the actual block - it is a great LISP though

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