RRENAME lisp help!

RRENAME lisp help!

lzedCB
Advocate Advocate
590 Views
8 Replies
Message 1 of 9

RRENAME lisp help!

lzedCB
Advocate
Advocate

Hello, I'm trying to replace the all dots (".") by a "_" caractere in all blocks names using a LISP called RRENAME, like the image bellow:

 

lzed_cubo_1-1689092441471.png

 

I've tried to find in help file how to get this task done, but I can't find. Anyone can help me with the right expressions?

 

0 Likes
Accepted solutions (1)
591 Views
8 Replies
Replies (8)
Message 2 of 9

Kent1Cooper
Consultant
Consultant

Without seeing "a LISP called RRENAME," it's hard to say....

EDIT:  I found >it<.  With limited investigation, it seems a  .  is a wildcard representing any character in patterns, and even looking at the instructions text file's "regular expression" link, I didn't find any reference to an escape character or other means to have that taken literally instead of as a wildcard.  I suspect some way of doing that is going to be necessary, but I'm not versed in such things.

Kent Cooper, AIA
0 Likes
Message 3 of 9

lzedCB
Advocate
Advocate
0 Likes
Message 4 of 9

paullimapa
Mentor
Mentor

You can try out my free BlockApps that  includes DDBlkRen a block renaming function. You can review how to use with the included video tutorial demo:

https://apps.autodesk.com/ACD/en/Detail/Index?id=3309945226076337959&appLang=en&os=Win64


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 5 of 9

lzedCB
Advocate
Advocate

Seems amazing this your plugin, but I can't test it in C3D. It does not shows up in Addins tab! Thks

0 Likes
Message 6 of 9

paullimapa
Mentor
Mentor

In that case I’m not sure it’ll work in C3D


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 7 of 9

Kent1Cooper
Consultant
Consultant
Accepted solution

@lzedCB wrote:

.... I'm trying to replace the all dots (".") by a "_" caractere in all blocks names ....


For that particular task, this is enough [limited testing]:

 

(while
  (setq blk (tblnext "block" (not blk)))
  (setq bname (cdr (assoc 2 blk)))
  (if (and (not (assoc 1 blk)) (wcmatch bname "*`.*"))
    (command "_.rename" "block" bname (vl-string-translate "." "_" bname))
  )
)

 

EDIT:  Corrected something, removed an unneeded element, and added prevention of trying to rename an Xref [just in case].

Kent Cooper, AIA
0 Likes
Message 8 of 9

lzedCB
Advocate
Advocate
Thanks! That was simple and effective in this task!
0 Likes
Message 9 of 9

Moshe-A
Mentor
Mentor

@lzedCB  hi,

 

check this

 

enjoy

Moshe

 

 

 

 

(defun c:rrename (/ _elimPunto tbl bname)
 (setq _elimPunto (lambda (bn) (vl-string-translate "." "_" bn)))
  
 (while (setq tbl (tblnext "block" (not tbl)))
  (setq bname (cdr (assoc '2 tbl)))
	
  (if (vl-string-search "." bname)
   (command "._rename" "_block" bname (_elimPunto bname))
  )
 ); while

 (princ)
)

 

 

0 Likes