AutoCAD 2010/2011/2012

Reply
Distinguished Contributor
bkanthergolder
Posts: 155
Registered: ‎10-04-2012
Message 1 of 11 (189 Views)
Accepted Solution

RENAME command and dual sided wildcards *<word>* doesn't work

189 Views, 10 Replies
05-27-2014 07:00 PM

Any idea why this doesnt work.. I swear this syntax was fine pre 2010.

 

Renaming

 

PREFIX-VDS-stuff

SOMEOTHER-VDS-stuffso

 

to 

 

PREFIX-WST-stuff

SOMEOTHER-WST-stuffso

 

i.e

 

*VDS*

 

*WST*

 

ranemcommand1.png

Civil 3D 2014 (SP2)
Win 7 Pro x64 -DELL Precision Workstation T3500
Intel Xeon 3.3GHz (w3680) -24Gb Ram
NVIDIA Quadro 2000 (1GB)
ceethreedee.com
Product Support
Soyoung.H
Posts: 67
Registered: ‎12-22-2010
Message 2 of 11 (151 Views)

Re: RENAME command and dual sided wildcards *<word>* doesn't work

05-29-2014 02:42 AM in reply to: bkanthergolder

I've jsut tested in 2010, but it didn't work.

Hmm....are you sure did you use in 2010??

 



Soyoung.H
Distinguished Contributor
jeff.whitney
Posts: 140
Registered: ‎03-05-2008
Message 3 of 11 (143 Views)

Re: RENAME command and dual sided wildcards *<word>* doesn't work

05-29-2014 10:15 AM in reply to: bkanthergolder

Could it perhaps be the length of the string?

AutoCAD sometimes balks at long strings - I have used the wildcard in rename as well, in ACAD 2011

*Expert Elite*
Kent1Cooper
Posts: 5,268
Registered: ‎09-13-2004
Message 4 of 11 (135 Views)

Re: RENAME command and dual sided wildcards *<word>* doesn't work

05-29-2014 10:50 AM in reply to: bkanthergolder

bkanthergolder wrote:

Any idea why this doesnt work.. I swear this syntax was fine pre 2010.

....


I replied on the thread on whatever other Forum this question is on that it doesn't work in my ol' 2004.  However, I find in further trial that it does work with a * wildcard at the end, and it works with a limited wildcard situation [? wildcard(s), etc.] at the beginning.  It just doesn't work with the anything-goes-no-matter-how-many-characters * wildcard at the beginning [and therefore also not with that at both the beginning and the end].

Kent Cooper
Distinguished Contributor
bkanthergolder
Posts: 155
Registered: ‎10-04-2012
Message 5 of 11 (126 Views)

Re: RENAME command and dual sided wildcards *<word>* doesn't work

05-29-2014 08:45 PM in reply to: Kent1Cooper

Its stange because as you can see it selects the correct layers when typing a dual wildcard..

 

It just doesnt rename them...!! :smileysad:

 

I might have been using a custom tool now that i think about it.. shouldn't this be core functionality though i mean ****! it would take forever to have to rename layers on large proejcts!

 

Regards

Civil 3D 2014 (SP2)
Win 7 Pro x64 -DELL Precision Workstation T3500
Intel Xeon 3.3GHz (w3680) -24Gb Ram
NVIDIA Quadro 2000 (1GB)
ceethreedee.com
*Expert Elite*
Kent1Cooper
Posts: 5,268
Registered: ‎09-13-2004
Message 6 of 11 (119 Views)

Re: RENAME command and dual sided wildcards *<word>* doesn't work

05-30-2014 04:32 AM in reply to: bkanthergolder

bkanthergolder wrote:

.... shouldn't this be core functionality though i mean ****! it would take forever to have to rename layers on large proejcts!

....


But it would be easy to build into an AutoLISP routine, which could work through the Layer table, and for each name, check whether it contains the "old" substring [for that, the double-wildcard-ended check would work], and if so, replace that with the "new" substring using (vl-string-translate).  It could also be built to check whether the intended changed Layer name is one that already exists, keeping track of those it therefore couldn't change and notifying the User, and/or could either have the substrings built in or ask the User for them in a couple of different ways, and/or could handle more than one such operation in one shot using lists of old and new substrings, etc., etc.  Is that something worth pursuing?

Kent Cooper
Distinguished Contributor
jeff.whitney
Posts: 140
Registered: ‎03-05-2008
Message 7 of 11 (115 Views)

Re: RENAME command and dual sided wildcards *<word>* doesn't work

05-30-2014 08:15 AM in reply to: Kent1Cooper

You go first Kent!  :smileyvery-happy:

*Expert Elite*
Kent1Cooper
Posts: 5,268
Registered: ‎09-13-2004
Message 8 of 11 (109 Views)

Re: RENAME command and dual sided wildcards *<word>* doesn't work

05-30-2014 10:55 AM in reply to: Kent1Cooper

Kent1Cooper wrote:
....

But it would be easy to build into an AutoLISP routine, which could work through the Layer table, and for each name, check whether it contains the "old" substring [for that, the double-wildcard-ended check would work], and if so, replace that with the "new" substring using (vl-string-translate).  It could also be built to check whether the intended changed Layer name is one that already exists, keeping track of those it therefore couldn't change and notifying the User, and/or could either have the substrings built in or ask the User for them in a couple of different ways, and/or could handle more than one such operation in one shot using lists of old and new substrings, etc., etc.  Is that something worth pursuing?


[Actually, using (vl-string-subst).]

The following is built as a function with arguments [see the Usage note], but could easily be altered to be a command, prompting the User to supply the old and new substring content.  It does not [yet] handle substitutions of more than one 'old'/'new pairing at a time.  Limited testing, and it could probably use an error handler, Undo begin/end wrapping, etc.

 

;;  LNSS function [= Layer Name Substring Substitution]
;;  To replace a specified substring with another in the names of
;;    all Layers whose names contain the 'old' substring.
;;  Usage:  (LNSS "THIS" "THAT") will replace "THIS" with "THAT" in

;;    all Layer names containing "THIS" anywhere in them, provided
;;    there is not already a Layer with the altered name.
;;  Reports a list of all Layer name(s) not changed because they
;;    are already in use.
;;  Not case-sensitive -- 'new' will be used in uppercase, regardless

;;    of how entered, and will replace 'old' in any case combination.
;;  Kent Cooper, 30 May 2014

 

(defun LNSS (old new / layinfo oldname newname laydata notchanged)
  (while
    (setq layinfo (tblnext "layer" (not layinfo))); step through Layers from beginning
    (if (wcmatch (setq oldname (strcase (cdr (assoc 2 layinfo)))) (strcat "*" (strcase old) "*")); name contains old substring
      (progn ; then
        (setq newname (vl-string-subst (strcase new) (strcase old) oldname)); edit Layer name
        (if (tblsearch "layer" newname); Layer already exists
          (setq notchanged (cons oldname notchanged)); then
          (progn ; else -- change it
            (setq laydata (entget (tblobjname "layer" oldname)))
            (entmod (subst (cons 2 newname) (assoc 2 laydata) laydata))
          ); progn
        ); if ['newname' Layer already exists or not]
      ); progn
    ); if [name contains 'old' or not]
  ); while
  (if notchanged
    (progn
      (prompt "\nLayer name(s) NOT changed: ")
      notchanged
    ); progn
  ); if
); defun

 

Usage for the OP's example:  (LNSS "VDS" "WST")

 

EDIT:  Oh, and by the way, if any Layer names contain the 'old' substring more than once, it will replace only the first occurrence [that's how (vl-string-subst) works].  If you want to get them all, run the function more than once.

Kent Cooper
*Expert Elite*
vladimir.michl
Posts: 237
Registered: ‎09-17-2006
Message 9 of 11 (95 Views)

Re: RENAME command and dual sided wildcards *<word>* doesn't work

06-01-2014 04:49 AM in reply to: Kent1Cooper

You can also use the RRENAME utility (regular-expression rename of any symbol table) from www.cadstudio.cz/freeware

 

Its find/replace parameters for the above mentioned layout example will be:

 

Find: (.+)-VDS-(.+)

Replace: $1-WST-$2

 

Vladimir Michl, www.cadstudio.cz  www.cadforum.cz


Distinguished Contributor
bkanthergolder
Posts: 155
Registered: ‎10-04-2012
Message 10 of 11 (87 Views)

Re: RENAME command and dual sided wildcards *<word>* doesn't work

06-01-2014 03:07 PM in reply to: vladimir.michl

Vladmir..

 

Thanks that does work.. strange syntax (the whole wildcard * is a (.+) S$

 

and i had to use $1-WST-$2. I know you typed dollars below.. The default font family on this forum makes them look like s'sss though.

 

Ohh.. and the routine will not change the active layer as well.. but easy fixed manually obviouslly.

 

Thanks again..

 

Brad

 

P.$

 

S$

Civil 3D 2014 (SP2)
Win 7 Pro x64 -DELL Precision Workstation T3500
Intel Xeon 3.3GHz (w3680) -24Gb Ram
NVIDIA Quadro 2000 (1GB)
ceethreedee.com

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community




Connect with AutoCAD

Twitter

Facebook

Blogs

Pinterest

Youtube