Author Topic: Multi Line Layer Name Editor  (Read 2718 times)

0 Members and 1 Guest are viewing this topic.

Shade

  • Guest
Multi Line Layer Name Editor
« on: March 09, 2007, 09:38:46 AM »
Does any one know of a good multi line layer name, editor lisp.
I would like to be able to strip the bound characters out of the layer name after a drawing has been bound.
Also I would like to shorten some of the layer names down to a more reasonable size.

Ie.
Given
06004$0$Floor_Plan_Existing$0$-$0$28Feb07$0$Walls

Result
Existing - Walls

Any help would be greatly appreciated..
Thanks
Shade

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Multi Line Layer Name Editor
« Reply #1 on: March 09, 2007, 10:40:06 AM »
Give this a try....


Code: [Select]
;;Written by MP
(defun KeepReversedNthPlus (n string delim / i code indexes)
  (setq i    0
code (ascii delim)
  )
  (while (setq i (vl-string-position code string i))
    (setq indexes (cons (setq i (1+ i)) indexes))
  )
  (cond
    ((null indexes) nil)
    ((< n (length indexes))
     (substr string (1+ (nth n indexes)))
    )
    (string)
  )
)
;;(KeepReversedNthPlus 0 "abc$def$ghi$jkl$mno" "$") --->> "mno"

(defun c:strip$ (/ name)
  (vlax-map-collection
    (vla-get-layers
      (vla-get-activedocument (vlax-get-acad-object))
    )
    '(lambda (x)
       (if (wcmatch (setq name (vla-get-name x)) "*$*")
(vl-catch-all-apply
   'vla-put-name
   (list x (KeepReversedNthPlus 0 name "$"))
)
       )
     )
  )
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Multi Line Layer Name Editor
« Reply #2 on: March 10, 2007, 08:36:21 PM »
Did this work for you?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

pmvliet

  • Guest
Re: Multi Line Layer Name Editor
« Reply #3 on: March 12, 2007, 01:48:20 AM »
I get this error, maybe it's not an error... It seemed to change some of the layer names, but not all of them.

I know Andrea had one floating around. I was gonna try and look for his when I found this thread..

Pieter

Quote
Command: strip$
#<VLA-OBJECT IAcadLayers 0c59f314>

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Multi Line Layer Name Editor
« Reply #4 on: March 12, 2007, 11:55:05 AM »
It's not an error...I just forgot to add a (princ) to the end of the routine for a "clean" exit. I'd imagine the layer names that did not change end with the same text ie $xref1$walls, $xref2$walls, $xref3$walls and duplicate layer names are not allowed.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Shade

  • Guest
Re: Multi Line Layer Name Editor
« Reply #5 on: March 12, 2007, 01:19:35 PM »
Did this work for you?

Yes, it did work thank you. The only thing as mentioned duplicate layer names had $0$ still present. Which I edited manually.

Thanks again for the help!
:)

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Multi Line Layer Name Editor
« Reply #6 on: March 12, 2007, 01:43:10 PM »
Glad it worked for you.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

pmvliet

  • Guest
Re: Multi Line Layer Name Editor
« Reply #7 on: March 12, 2007, 04:50:01 PM »
kewl & thanks!

Pieter