See the top rated post in this thread. Click here

Results 1 to 7 of 7

Thread: Wildcard Character * Not Allowing Renaming of Multiple Layers

  1. #1
    100 Club
    Join Date
    2005-04
    Posts
    107


    Angry Wildcard Character * Not Allowing Renaming of Multiple Layers

    In the RENAME dialog, I am using the *wildcard character to rename multiple layers.
    See Attached.
    But No Layers are renamed.
    What's the problem?

    Thanks
    Attached Files Attached Files

  2. #2
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    2,967


    Default Re: Wildcard Character * Not Allowing Renaming of Multiple Layers

    Quote Originally Posted by rbdome View Post
    In the RENAME dialog, I am using the *wildcard character to rename multiple layers.
    See Attached.
    But No Layers are renamed.
    What's the problem?

    Thanks
    I don't think you can use (2) wildcards, I've tried it before too and couldn't make it work.
    You many have to do it in pieces:

    Rename:
    "Lev2-~Anno*" to "Lev2-~An*"

    "Lev5 Deluxe Suite-~Anno*" to "Lev5 Deluxe Suite-~An*"

    And so on.
    Realizing that you seem to only have a couple changes per type, not real efficient.

    I agree it should work as you attempted, but it doesn't.
    Unless someone else has better advice.
    Ted
    ____________________________________________________________________ ________________
    Windows 7 Professional
    AutoCAD 2017 - REVIT 2017 - Inventor Professional 2015 (when I can)

  3. #3
    Certifiable AUGI Addict
    Join Date
    2015-10
    Location
    Tallahassee, FL
    Posts
    2,541


    Default Re: Wildcard Character * Not Allowing Renaming of Multiple Layers

    tedg's method is the best you could ever do using Rename.

    cadtag's alternative http://forums.augi.com/showthread.ph...=1#post1289182
    Tom Beauford P.S.M. - Civil 2018 on Windows 10 Enterprise
    Design Analysis - Leon County Public Works/Engineering
    2280 Miccosukee Rd. Tallahassee, FL 32308-5310
    Ph# (850)606-1516 Home Page

  4. #4
    Programming Moderator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,066


    1 members found this post helpful.

    Default Re: Wildcard Character * Not Allowing Renaming of Multiple Layers

    I've not downloaded the PDF (I prefer the contents included in the post, personally).

    That said, I *think* this old LISP routine might be of use; It is case-sensitive (just like WCMATCH), and can effectively replace sub-strings in the middle of a given Layer name:

    Code:
    (vl-load-com)
    
    (defun c:LAYREN () (c:LayerRename))
    (defun c:LayerRename
           (/ *error* old new acDoc oLayers i oldName newName)
    
      (defun *error* (msg)
        (if acDoc
          (vla-endundomark acDoc)
        )
        (cond ((not msg))                                                   ; Normal exit
              ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
              ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
        )
        (princ)
      )
    
      (if (and (setq old (getstring T "\nEnter string to replace: "))
               (setq new (getstring T "\nEnter replacement string: "))
          )
        (progn
          (vla-startundomark
            (setq acDoc (vla-get-activedocument (vlax-get-acad-object)))
          )
          (setq oLayers (vla-get-layers acDoc))
          (setq i 0)
          (vlax-for x oLayers
            (if (vl-string-search old (setq oldName (vla-get-name x)))
              (if
                (tblsearch "layer"
                           (setq newName (vl-string-subst new old oldName)) ; single replacement only
                )
                 (prompt
                   (strcat
                     "\nLayer \""
                     newName
                     "\" already exists. "
                     "Move all objects, then delete layer \""
                     oldName
                     "\" "
                   )
                 )
                 (progn
                   (vla-put-name x newName)
                   (setq i (1+ i))
                 )
              )
            )
          )
          (prompt
            (strcat "\n"
                    (itoa i)
                    " layer"
                    (if (= 1 i)
                      " "
                      "s "
                    )
                    "renamed. "
            )
          )
        )
      )
    
      (*error* nil)
    )
    Quick example from Command Line:

    Code:
    Command:
    Command: LAYREN
    Enter string to replace: ANNO
    Enter replacement string: AN
    46 layer renamed.
    Command:

    Cheers
    "Potential has a shelf life." - Margaret Atwood
    AutoCAD, and Civil 3D Certified Professional | Autodesk Authorized Developer
    Sincpac C3D ~ Autodesk Exchange Apps

  5. #5
    Active Member david-k's Avatar
    Join Date
    2015-12
    Location
    San Diego, CA
    Posts
    84


    Default Re: Wildcard Character * Not Allowing Renaming of Multiple Layers

    Quote Originally Posted by BlackBox View Post
    ...That said, I *think* this old LISP routine might be of use; It is case-sensitive (just like WCMATCH), and can effectively replace sub-strings in the middle of a given Layer name...
    Is this your code? I may want to keep it with me, as it may come in handy, and want to give proper credit .

  6. #6
    Programming Moderator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,066


    Default Re: Wildcard Character * Not Allowing Renaming of Multiple Layers

    Quote Originally Posted by david-k View Post
    Is this your code? I may want to keep it with me, as it may come in handy, and want to give proper credit .
    It is, yes - no need for attribution, and feel free to take from it what you like.


    Cheers
    "Potential has a shelf life." - Margaret Atwood
    AutoCAD, and Civil 3D Certified Professional | Autodesk Authorized Developer
    Sincpac C3D ~ Autodesk Exchange Apps

  7. #7
    Active Member david-k's Avatar
    Join Date
    2015-12
    Location
    San Diego, CA
    Posts
    84


    Default Re: Wildcard Character * Not Allowing Renaming of Multiple Layers


    Cheers!

Similar Threads

  1. 2007: RENAMING MULTIPLE LAYERS
    By cad2335 in forum AutoCAD General
    Replies: 6
    Last Post: 2015-03-18, 12:11 PM
  2. Renaming blocks with wildcard characters
    By Wanderer in forum AutoCAD Map 3D - General
    Replies: 11
    Last Post: 2010-03-15, 03:15 PM
  3. Wildcard layers in xrefedit
    By Ddameron in forum AMEP General
    Replies: 3
    Last Post: 2008-03-31, 08:57 PM
  4. Wildcard Key use in Renaming Blocks Lost
    By rbdome in forum AutoCAD General
    Replies: 1
    Last Post: 2007-09-25, 02:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •