Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

alternatives to rrename.vlx

13 REPLIES 13
SOLVED
Reply
Message 1 of 14
jtm2020hyo
1219 Views, 13 Replies

alternatives to rrename.vlx

rrename.vlx does not work, at least for me. (AutoCAD 2020)

I tried to:

find: (.+)(MAC|MED|EIC|ED|MEB|MSC|ECA)

replace: $2-$1$2

 

PD: please tell me if I'm doing something bad 

 

https://www.cadforum.cz/cadforum_en/rename-on-steroids-complex-renaming-of-autocad-objects-tip9265

13 REPLIES 13
Message 2 of 14
_Tharwat
in reply to: jtm2020hyo

Here is my free tool to rename all types of Blocks.

https://autolispprograms.wordpress.com/rename-a-block/ 

 
 

Rename.PNG

Message 3 of 14
Ajilal.Vijayan
in reply to: jtm2020hyo

Can you give example of text, which you want to apply this regex expression ?

Looks like the find expression needs to be changed.

Message 4 of 14
jtm2020hyo
in reply to: Ajilal.Vijayan

yes.
here are a group of layer names, I have more than 1000 layer that need be renamed, all of those are recycled, so those have the same structure, I know a bit of regex thanks to "notepad++" but I can not work "rrename.vlx"

 

 

 

EQ_10$0$1.0 JTM EQ$0$JTM_ED
EQ_10$0$1.0 JTM EQ$0$JTM_EIC
EQ_10$0$1.0 JTM EQ$0$JTM_JTM LEYENDA EQ$0$MAD
EQ_10$0$1.0 JTM EQ$0$JTM_JTM-ECA
EQ_10$0$1.0 JTM EQ$0$JTM_JTM_10_JTM_10
EQ_10$0$1.0 JTM EQ$0$JTM_MAC
EQ_10$0$1.0 JTM EQ$0$JTM_MAD
EQ_10$0$1.0 JTM EQ$0$JTM_MEB
EQ_10$0$1.0 JTM EQ$0$JTM_MOB ADM COMPRADO
EQ_10$0$1.0 JTM EQ$0$JTM_MODIFICACIONES OCCIDENTE
EQ_10$0$1.0 JTM EQ$0$JTM_MSC
EQ_10-MSC

 

find: (.+)(MAC|MED|EIC|ED|MEB|MSC|ECA)

I need to match any layer that ends with mac, med, eic, ed, msc, eca.


replace: $2-$1$2
I need swap between $1 and $2

 

In notepad++ I should use \1 and \2, so maybe this VLX use another regex class?

 

final result should be:

.

.

.

MSC-EQ_10-

 

Message 5 of 14
jtm2020hyo
in reply to: _Tharwat


@_Tharwat wrote:

Here is my free tool to rename all types of Blocks.

https://autolispprograms.wordpress.com/rename-a-block/ 

 
 

Rename.PNG


thanks for sharing your app, but I need to rename layers.
anyway, thanks for your help

Message 6 of 14
Ajilal.Vijayan
in reply to: jtm2020hyo

try this expression

find : (.{0,5})(.+)(MAC|MED|EIC|ED|MEB|MSC|ECA)

replace : $3-$1-

Message 7 of 14
Sea-Haven
in reply to: jtm2020hyo

Need oldname , newname in a text file with a "," separator then very easy.

 

Alan,Alan-new

t,t-new

XYZ,POINTS

 

This may be helpful change file path.

(defun c:test ( / fo doc lay)
(setq fo (open "d:\\acadtemp\\layers.txt" "w"))
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for lays (vla-get-Layers doc)
  (princ "\n")
  (princ (setq lay (vla-get-name lays) ))
  (write-line (strcat lay ",-") fo)
)
(close fo)
)
(c:test)
Message 8 of 14
jtm2020hyo
in reply to: Ajilal.Vijayan


@Ajilal.Vijayan wrote:

try this expression

find : (.{0,5})(.+)(MAC|MED|EIC|ED|MEB|MSC|ECA)

replace : $3-$1-


 

thanks for your help friend.

 

I tried your suggestion, but I had no results.

 

I understand that "(.{0,5})(.+)(MAC|MED|EIC|ED|MEB|MSC|ECA)" its equivalent to "(.+)(MAC|MED|EIC|ED|MEB|MSC|ECA)" , so probably "rrename.vlx" need to update to autocad 2020, or we are doing something bad.

 

here is the command prompt:

 

Command: (LOAD "C:/Users/jtm2019hyo/Google Drive/@Programing/@CAD/LSP-VLX/RENAME/REGEX/RRename - rename layouts, blocks, layers or linetypes using regular expressions (VLX Lisp for AutoCAD)/RRename.VLX")
RRename command loaded. (C)2014, CAD Studio - www.cadstudio.cz
______ CAD, PLM, GIS/FM custom application development ________ nil

Command: RRENAME

Rename [Blocks/Layers/lineTypes/layOuts] <layOuts>: *Cancel*

Rename [Blocks/Layers/lineTypes/layOuts] <layOuts>:

Use () and $1 for regular expressions, # as counter
Source substring or regex to find (e.g. '(.+)'): (.{0,5})(.+)(MAC|MED|EIC|ED|MEB|MSC|ECA)

Target substring or regex to replace (e.g. '$1_NEW'): $3-$1-

Performed 0 rRenames

Command:

 

 

 

Message 9 of 14
jtm2020hyo
in reply to: Sea-Haven


@Sea-Haven wrote:

Need oldname , newname in a text file with a "," separator then very easy.

 

Alan,Alan-new

t,t-new

XYZ,POINTS

 

This may be helpful change file path.

(defun c:test ( / fo doc lay)
(setq fo (open "d:\\acadtemp\\layers.txt" "w"))
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for lays (vla-get-Layers doc)
  (princ "\n")
  (princ (setq lay (vla-get-name lays) ))
  (write-line (strcat lay ",-") fo)
)
(close fo)
)
(c:test)

I tried to use that lisp but just export layer names to the text file. ("d:\\acadtemp\\layers.txt")

maybe I'm doing something bad?

Message 10 of 14
ronjonp
in reply to: jtm2020hyo

So should this layer:
"EQ_10$0$1.0 JTM EQ$0$JTM_JTM-ECA"

Be renamed to this?
"MSC-EQ_10-JTM_JTM-ECA"

 

I could not follow your example above.

Message 11 of 14
Ajilal.Vijayan
in reply to: jtm2020hyo

It seems that you are trying to rename the layouts.

But the example you provided are for layers like below.

How is your layouts named currently ?

Maybe the current layouts names not matching the regex expression.

EQ_10$0$1.0 JTM EQ$0$JTM_MAC
EQ_10$0$1.0 JTM EQ$0$JTM_MAD
EQ_10$0$1.0 JTM EQ$0$JTM_MEB
Message 12 of 14
jtm2020hyo
in reply to: ronjonp


@ronjonp wrote:

So should this layer:
"EQ_10$0$1.0 JTM EQ$0$JTM_JTM-ECA"

Be renamed to this?
"MSC-EQ_10-JTM_JTM-ECA"

 

I could not follow your example above.


No friend, I did not. but maybe I'm doing something bad.

here is the command prompt :  (Performed 0 rRenames)

Command: (LOAD "C:/Users/jtm2019hyo/Google Drive/@Programing/@CAD/LSP-VLX/RENAME/REGEX/RRename - rename layouts, blocks, layers or linetypes using regular expressions (VLX Lisp for AutoCAD)/RRename.VLX")
RRename command loaded. (C)2014, CAD Studio - www.cadstudio.cz
______ CAD, PLM, GIS/FM custom application development ________ nil

Command: RRENAME

Rename [Blocks/Layers/lineTypes/layOuts] <layOuts>: *Cancel*

Rename [Blocks/Layers/lineTypes/layOuts] <layOuts>:

Use () and $1 for regular expressions, # as counter
Source substring or regex to find (e.g. '(.+)'): (.{0,5})(.+)(MAC|MED|EIC|ED|MEB|MSC|ECA)

Target substring or regex to replace (e.g. '$1_NEW'): $3-$1-

Performed 0 rRenames

Command:
Message 13 of 14
ronjonp
in reply to: jtm2020hyo

Give a simple before and after example of what you want accomplished .. and a stated above by @Ajilal.Vijayan are you renaming layouts or layers ??

Message 14 of 14
jtm2020hyo
in reply to: Ajilal.Vijayan


@Ajilal.Vijayan wrote:

It seems that you are trying to rename the layouts.

But the example you provided are for layers like below.

How is your layouts named currently ?

Maybe the current layouts names not matching the regex expression.

EQ_10$0$1.0 JTM EQ$0$JTM_MAC
EQ_10$0$1.0 JTM EQ$0$JTM_MAD
EQ_10$0$1.0 JTM EQ$0$JTM_MEB

Boys, I do not how to say this....

I did not notice that I was using LAYOUT options. now I used LAYER options and I renamed my layers. (LOL)

 

here my "Performed 40 rRenames" command prompt :

Command: (LOAD "C:/Users/jtm2019hyo/Google Drive/@Programing/@CAD/LSP-VLX/RENAME/REGEX/RRename - rename layouts, blocks, layers or linetypes using regular expressions (VLX Lisp for AutoCAD)/RRename.VLX")
RRename command loaded. (C)2014, CAD Studio - www.cadstudio.cz
______ CAD, PLM, GIS/FM custom application development ________ nil

Command: RRENAME

Rename [Blocks/Layers/lineTypes/layOuts] <layOuts>: L

Use () and $1 for regular expressions, # as counter
Source substring or regex to find (e.g. '(.+)'): (.+)(MAC|MED|EIC|ED|MEB|MSC|ECA)

Target substring or regex to replace (e.g. '$1_NEW'): $2-$1
 ARQUITECTURA EST.HYO$0$ARQ_10$0$ARQ_JTM_10_E-VEREDA->ED-ARQUITECTURA EST.HYO$0$ARQ_10$0$ARQ_JTM_10_E-VERA ARQUITECTURA EST.HYO$0$ARQ_10$0$ARQ_JTM_10_CIRCUITO MEDIA TENSION->ED-ARQUITECTURA EST.HYO$0$ARQ_10$0$ARQ_JTM_10_CIRCUITO MIA TENSION ARQUITECTURA EST.HYO$0$ARQ_10$0$ARQ_JTM_10_pedro->ed-ARQUITECTURA EST.HYO$0$ARQ_10$0$ARQ_JTM_10_pro ARQUITECTURA EST.HYO$0$ARQ_10$0$ARQ_JTM EQ-10 COMPACT$0$CIRCUITO MEDIA TENSION->ED-ARQUITECTURA EST.HYO$0$ARQ_10$0$ARQ_JTM EQ-10 COMPACT$0$CIRCUITO MIA TENSION ARQUITECTURA EST.HYO$0$ARQ_10$0$ARQ_JTM EQ-10 COMPACT$0$ED->ED-ARQUITECTURA EST.HYO$0$ARQ_10$0$ARQ_JTM EQ-10 COMPACT$0$ ARQUITECTURA EST.HYO$0$ARQ_11$0$ARQ_JTM_11_E-VEREDA->ED-ARQUITECTURA EST.HYO$0$ARQ_11$0$ARQ_JTM_11_E-VERA EM_01$0$0.1 JTM EM$0$TOMAC-TABLERO->MAC-EM_01$0$0.1 JTM EM$0$TO-TABLERO EM_02$0$0.1 JTM EM$0$TOMAC-TABLERO->MAC-EM_02$0$0.1 JTM EM$0$TO-TABLERO EM_03$0$0.1 JTM EM$0$TOMAC-TABLERO->MAC-EM_03$0$0.1 JTM EM$0$TO-TABLERO EM_10$0$1.0 JTM EM$0$EIC->EIC-EM_10$0$1.0 JTM EM$0$ EM_10$0$1.0 JTM EM$0$D-salida electromecanicas->eca-EM_10$0$1.0 JTM EM$0$D-salida electromnicas EM_11$0$1.1 JTM EM$0$D-salida electromecanicas->eca-EM_11$0$1.1 JTM EM$0$D-salida electromnicas EM_10_SE_GE$0$1.0 JTM S.E. Y G.E$0$CIRCUITO MEDIA TENSION->ED-EM_10_SE_GE$0$1.0 JTM S.E. Y G.E$0$CIRCUITO MIA TENSION EM_10_SE_GE$0$1.0 JTM S.E. Y G.E$0$07415_TRABAJO_MT1$0$2_MEDIA_TENSION->ED-EM_10_SE_GE$0$1.0 JTM S.E. Y G.E$0$07415_TRABAJO_MT1$0$2_MIA_TENSION EM_10_SE_GE$0$1.0 JTM S.E. Y G.E$0$EIC->EIC-EM_10_SE_GE$0$1.0 JTM S.E. Y G.E$0$ EM_10_SE_GE$0$1.0 JTM S.E. Y G.E$0$$0$CIRCUITO MEDIA TENSION->ED-EM_10_SE_GE$0$1.0 JTM S.E. Y G.E$0$$0$CIRCUITO MIA TENSION EM_20$0$2.0 JTM EM$0$EIC->EIC-EM_20$0$2.0 JTM EM$0$ EM_20$0$2.0 JTM EM$0$MAC->MAC-EM_20$0$2.0 JTM EM$0$ EM_20$0$2.0 JTM EM$0$D-salida electromecanicas->eca-EM_20$0$2.0 JTM EM$0$D-salida electromnicas EQ_10$0$1.0 JTM EQ$0$JTM_MAC->MAC-EQ_10$0$1.0 JTM EQ$0$JTM_ EQ_10$0$1.0 JTM EQ$0$JTM_MSC->MSC-EQ_10$0$1.0 JTM EQ$0$JTM_ EQ_10$0$1.0 JTM EQ$0$JTM_EIC->EIC-EQ_10$0$1.0 JTM EQ$0$JTM_ EQ_10$0$1.0 JTM EQ$0$JTM_MEB->MEB-EQ_10$0$1.0 JTM EQ$0$JTM_ EQ_10$0$1.0 JTM EQ$0$JTM_ED->ED-EQ_10$0$1.0 JTM EQ$0$JTM_ EQ_10$0$1.0 JTM EQ$0$JTM_$0$ED->ED-EQ_10$0$1.0 JTM EQ$0$JTM_$0$ EQ_10$0$1.0 JTM EQ$0$JTM_JTM-ECA->ECA-EQ_10$0$1.0 JTM EQ$0$JTM_JTM- EQ_11$0$1.1 JTM EQ$0$JTM_MAC->MAC-EQ_11$0$1.1 JTM EQ$0$JTM_ EQ_11$0$1.1 JTM EQ$0$JTM_MSC->MSC-EQ_11$0$1.1 JTM EQ$0$JTM_ EQ_11$0$1.1 JTM EQ$0$JTM_EIC->EIC-EQ_11$0$1.1 JTM EQ$0$JTM_ EQ_11$0$1.1 JTM EQ$0$JTM_MEB->MEB-EQ_11$0$1.1 JTM EQ$0$JTM_ EQ_11$0$1.1 JTM EQ$0$JTM_JTM-ECA->ECA-EQ_11$0$1.1 JTM EQ$0$JTM_JTM- EQ_20$0$2.0 JTM EQ$0$JTM_EIC->EIC-EQ_20$0$2.0 JTM EQ$0$JTM_ EQ_20$0$2.0 JTM EQ$0$JTM_MSC->MSC-EQ_20$0$2.0 JTM EQ$0$JTM_ EQ_20$0$2.0 JTM EQ$0$JTM_MAC->MAC-EQ_20$0$2.0 JTM EQ$0$JTM_ EQ_20$0$2.0 JTM EQ$0$JTM_MEB->MEB-EQ_20$0$2.0 JTM EQ$0$JTM_ EQ_30$0$3.0 JTM EQ$0$JTM_MSC->MSC-EQ_30$0$3.0 JTM EQ$0$JTM_ EQ_30$0$3.0 JTM EQ$0$JTM_MAC->MAC-EQ_30$0$3.0 JTM EQ$0$JTM_ EQ_40$0$4.0 JTM EQ$0$JTM_MSC->MSC-EQ_40$0$4.0 JTM EQ$0$JTM_ EQ_10-MSC->MSC-EQ_10- JTM-MAC->MAC-JTM-
Performed 40 rRenames

Command:

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost