Remove suffix's from Blocks names

Remove suffix's from Blocks names

gabrielUMFVH
Contributor Contributor
793 Views
4 Replies
Message 1 of 5

Remove suffix's from Blocks names

gabrielUMFVH
Contributor
Contributor

I keep receiving plans we very long layer and block names and the CAFM system we use only support 64 character blocks

For example a plan  I have at the moment all the blocks end with "-AL_72_01 Furniture _ Fittings Ground Floor", but can vary from plan to plan and sometime within the plans i,e, there may be 2 multiple suffixes of varying length.

 

DO anyone know a quick way, or has a handy lisp/code that would say rename Blocks and Layers by removing say "-AL*" where * is a wild card

 

0 Likes
794 Views
4 Replies
Replies (4)
Message 2 of 5

imadHabash
Mentor
Mentor

Hi,

I suggest to use RENAME command with Wild-Card Characters . also you can try this outsource plugin here

 

 

Imad Habash

EESignature

0 Likes
Message 3 of 5

gabrielUMFVH
Contributor
Contributor
Hi
RENAME doesn't appear to work for Suffixes, I use it to Rename for Prefixes
Unless I doing something wrong, the following doesn't work
[cid:image001.png@01D6FD3F.DA86C280]


0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant

@gabrielUMFVH wrote:
.... the following doesn't work
[cid:image001.png@01D6FD3F.DA86C280]

The "following" didn't come through.  Can you try again?

Kent Cooper, AIA
0 Likes
Message 5 of 5

Kent1Cooper
Consultant
Consultant

@gabrielUMFVH wrote:

....

DO anyone know a quick way, or has a handy lisp/code that would say rename Blocks and Layers by removing say "-AL*" where * is a wild card


Try this [minimally tested]:

(vl-load-com)
(defun C:BNT-AL ; = Block Name Truncate, removing "-AL" and following
  (/ blk old pos new inc newsuf)
  (while (setq blk (tblnext "block" (not blk)))
    (setq old (cdr (assoc 2 blk)))
    (if (setq pos (vl-string-search "-AL" old))
      (progn ; then
        (setq
          new (substr old 1 pos)
          inc 1
        ); setq
        (if (tblsearch "block" new); same truncated name already exists
          (progn ; then
            (setq newsuf (strcat new (itoa inc)))
            (while (tblsearch "block" newsuf)
              (setq newsuf (strcat new (itoa (setq inc (1+ inc)))))
            ); while
            (setq new newsuf)
          ); progn
        ); if
        (command "_.rename" "block" old new)
      ); progn
    ); if
  ); while
  (princ)
); defun

 

Kent Cooper, AIA
0 Likes