CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor and other Autodesk products [www.cadforum.cz]
Cesky English Deutsch
Login/Register:
 Visitors: 2836 
Plex.Earth connects AutoCAD and Google Earth

CAD tip CAD tip # 9265:

Question CAD 
 %  platform  category 
Q - question

RENAME on steroids - complex renaming of AutoCAD objects.

A - answer The AutoCAD command RENAME has only limited options for complex renaming of layers, blocks ot linetypes and you cannot use it to rename a series of layouts in DWG files.

Here comes the rRename LISP utility by CAD Studio. CADstudio rRename (see www.cadstudio.cz/download) is a free AutoCAD add-on tool, which allows to rename blocks, layers, layouts and linetypes with a simple find/replace or with regular expressions. Unlike the standard RENAME command you can use it to batch-rename layouts or to perform complex renaming schemes like swapping parts of a name, inserting substrings or adding counters (see examples).

Just load the RRENAME.VLX using APPLOAD or ACADDOC.LSP. Start renaming by entering the RRENAME command. It prompts for a type of object to rename:

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

Then enter the substring or regular expression to find and the substring or regular expression to replace. A standard text will just perform a search/replace renaming. The "*" character in the search string will be used as a wildcard (in fact as the ".+" regular expression). The "#" character in the replace string will be used as a counter (1,2,3...).

The regular expression strings can match object names in complex schemes. The renaming process will avoid objects like the "Model" layout, the layer "0" or the "ByLayer" linetype.

Regular Expressions allow to specify parentheses "(.+)" as stored groups in the search and refer them in the replace string as "$1", "$2", etc. (in the order). Read more about regular expressions in Wikipedia.

Renaming examples (do not type the double-quotes):

"" (empty string) --> "X"
prefix all characters in the names with "X"

"*" --> "New#"
rename all objects to New1, New2, New3, etc.

"(.+)" --> "Pre-$1-Post"
add "Pre-" as prefix and "-Post" as suffix to all names:
Layer1 --> Pre-Layer1-Post

"(.+)-(.+)" --> $2-$1
swap parts of names, like "Layer-Electro" to "Electro-Layer"

"(.{3})(.+)" --> $1-NEW-$2
add "-NEW-" after first 3 characters:
Layer1 --> Lay-NEW-er1

"(.+)([0-9]+)" --> $1-#-NEW
delete trailing numbers, renumber and add "-NEW":
Layer10 --> Layer-1-NEW
Layer15 --> Layer-2-NEW

Use the srxText utility for similar replacing of drawing texts.

ACAD
100% *  CAD 
26.5.2013    10563x  
Comments   Tell a friend
applies to: AutoCAD ·

See also:
Tip 11145:AutoCAD: Customization file load failed.
Tip 10903:How to import an Illustrator file (.AI) into AutoCAD (.DWG)?
Tip 10808:How to make transparent icons for my CUI ribbon in AutoCAD 2017.
Tip 10514:PDF published from AutoCAD 2016 has rectangles displayed around texts.
Tip 10097:Multiple applications with the same name in the "Open with" menu - which to choose?


Back   All CAD Tips All CAD tips&tricks

AutoCAD reports some xrefs as "Unresolved". « | » iLogic code for exploding a component pattern in Inventor.

Have we helped you? If you want to support the CAD Forum web service, consider buying one of our CAD applications, or our custom software development offerings, or donating via PayPal (see above). You may also add a link to your web - like this "fan" link: CAD Forum - tips, utilities, blocks for Autodesk products
CAD:    OS:    Categ: 
Text:  FAQ glossary   



Featuring:
Publish interactive 3D PDF models from AutoCAD, Inventor or Revit with Share3D More info


Please use these tips at your own risk.
CAD Studio (Xanadu) is not responsible for possible problems that may occur as a result of using any of these tips.
TOPlist