Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Remove beginning part from bound in Xref Layer names

  1. #1
    Member Greywethr's Avatar
    Join Date
    2003-02
    Location
    Half-hour N. of Philly
    Posts
    35
    Login to Give a bone
    0

    Arrow Remove beginning part from bound in Xref Layer names

    For you AutoLisp geeks, this won't be much of a challenge, but since I'm just a CAD geek, my Lisp skills are weak, and I'll be impressed. When you bind xrefs, your layers get ugly if your BINDTYPE isn't set correctly. I am working on someone else's drawing, which was bound and has a few dozen layers that all start with "SITE_LAYOUT$0$" and I would rather not have to rename every single layer separately. All I want is to remove SITE_LAYOUT$0$ from the beginning of all layers that do start with it. I'm fairly certain that this can be accomplished with a macro or AutoLisp and anyone who can help me with this will receive my praise and gratitude.

  2. #2
    100 Club
    Join Date
    2000-11
    Posts
    169
    Login to Give a bone
    0

    Default Re: Remove beginning part from bound in Xref Layer names

    Shot me an email at mgodfrey@perteet.com and I will forward some help your way. I have a couple of great routines that can help you.

  3. #3
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,106
    Login to Give a bone
    0

    Default Re: Remove beginning part from bound in Xref Layer names

    Quote Originally Posted by cadman_meg
    Shot me an email at ... and I will forward some help your way. I have a couple of great routines that can help you.
    Why not post your great routines here?
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  4. #4
    AUGI Addict madcadder's Avatar
    Join Date
    2000-11
    Location
    Too far from the beach
    Posts
    1,054
    Login to Give a bone
    0

    Default Re: Remove beginning part from bound in Xref Layer names

    Untested...
    Attached Files Attached Files

  5. #5
    Active Member ElpanovEvgeniy's Avatar
    Join Date
    2006-09
    Location
    Russia, Moscow
    Posts
    54
    Login to Give a bone
    0

    Default Re: Remove beginning part from bound in Xref Layer names

    Code:
    (defun c:rl ()
      (vlax-map-collection
        (vla-get-layers
          (vla-get-ActiveDocument
            (vlax-get-acad-object)
          ) ;_  vla-get-ActiveDocument
        ) ;_  vla-get-layers
        (function
          (lambda (x / a1 a2)
            (if (setq a2 (vl-string-search "$0$" (setq a1 (vla-get-name x))))
              (vla-put-name x (substr a1 (+ a2 4)))
            ) ;_  if
          ) ;_  lambda
        ) ;_  function
      ) ;_  vlax-map-collection
    ) ;_  defun

  6. #6
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Remove beginning part from bound in Xref Layer names

    Nice work as always Evgeniy. The only problem is if the layer name exist, then it will error out. Maybe change you naming line to
    Code:
              (vl-catch-all-apply 'vla-put-name (list x (substr a1 (+ a2 4))))
    I think this will work, and it will leave the ones that it couldn't change, so that the use can do what needs to be done to them by hand.

  7. #7
    All AUGI, all the time
    Join Date
    2015-12
    Location
    Central Oregon
    Posts
    591
    Login to Give a bone
    0

    Default Re: Remove beginning part from bound in Xref Layer names

    Quote Originally Posted by T.Willey
    Nice work as always Evgeniy. The only problem is if the layer name exist, then it will error out. Maybe change you naming line to
    Code:
              (vl-catch-all-apply 'vla-put-name (list x (substr a1 (+ a2 4))))
    I think this will work, and it will leave the ones that it couldn't change, so that the use can do what needs to be done to them by hand.
    Better yet, check for an error being returned. If T, select the objects on said layer, place them on the existing layer and delete the layer. Of course that would mean cycling the blocks collection now, too.....or use the LayerMerge command.

  8. #8
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Remove beginning part from bound in Xref Layer names

    Quote Originally Posted by miff
    Better yet, check for an error being returned. If T, select the objects on said layer, place them on the existing layer and delete the layer. Of course that would mean cycling the blocks collection now, too.....or use the LayerMerge command.
    I was going for the simple answer. =D

  9. #9
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Remove beginning part from bound in Xref Layer names

    This is not only a layer problem, if there is block in the binded xref ( and of course there is ) you have problem in problem.
    And it is not only layers, it is textfonts, linefonts, dimensionstyles. . . .
    and are they equal or not ? ( that is the idea with bind as bind. )

    To rename a layer is easy, but if the layer already exist you must change the dxf code in all objects.

    Yes this is a challenge, and hard code to develop safe and correct, so I recommend you to next time
    bind as insert


    : ) Happy Computing !

    kennet

  10. #10
    Member Greywethr's Avatar
    Join Date
    2003-02
    Location
    Half-hour N. of Philly
    Posts
    35
    Login to Give a bone
    0

    Talking Re: Remove beginning part from bound in Xref Layer names

    Thank you all so very much for the quick answers. I did have to use the string:
    (vl-catch-all-apply 'vla-put-name (list x (substr a1 (+ a2 4))))
    to make it work, and it's very fast. This is exactly what I needed. To respond to kennet.sjoberg, if you read my original post, I was working on someone else's drawing, because believe me, I'd be much more ****** had it been my own fault this is such a mess. As for the blocks, it's very easily fixed in Excel when we do an extraction with a find/replace. We've been trying to keep the newbies from changing settings, but we get vendor drawings, and returned outsourced drawings from India, etc., so things happen. I appreciate the heads up anyway though.

    Now, I will soon have a lot of time on my hands and really want to become an AutoLisp guru. Where do I start? I'll have lots of quiet reading time, and can get some advice and help here at work, but only on an intermediate level. Can anyone point me in the right direction? Books? Free online courses or materials? Thanx in advance!

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 35
    Last Post: 2019-10-28, 05:34 AM
  2. Layer States and Xref Layer Names
    By dan.higgins in forum VBA/COM Interop
    Replies: 2
    Last Post: 2011-12-07, 02:19 PM
  3. Is there a way to Customize Layer States ie Ignore Xref names?
    By abuv_all in forum AutoCAD Customization
    Replies: 20
    Last Post: 2007-10-02, 04:40 PM
  4. copy an lman from an xref into another no matching layer names
    By Hammer.John.J in forum AutoCAD Tips & Tricks
    Replies: 1
    Last Post: 2006-09-16, 08:07 AM
  5. Update bound xref
    By mikeyoung in forum AutoCAD General
    Replies: 4
    Last Post: 2005-10-31, 04:01 PM

Posting Permissions

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