TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: jlogan02 on August 31, 2022, 04:01:40 PM
-
Pulled this off the interwebs on cadtutor https://www.cadtutor.net/forum/topic/37911-layer-prefixes/ written by pBe.
I've tested this on a group of layers where I want to change just the prefix. It appears to work but my concern is my existing layer names have the same 4 letters in the body of the layer name. Is this bullet proof enough to not change that body text?
TBLK_TBLK_####
Result should be
TTBK_TBLK_####
(defun c:FixPrefix
( / OldPrefix NewPrefix ln
) NewPrefix "TTBK")
layer
layer
(vl
-string
-subst NewPrefix OldPrefix ln
)))) )
I knowwww...why did you name them that way in the first place!?!?!?
-
http://docs.autodesk.com/ACD/2014/ENU/index.html?url=files/GUID-D8EE91DC-D4DB-43E0-9AFE-5FA166C0896D.htm,topicNumber=d30e640068
(vl-string-subst "Obi-wan" "Ben" "Ben Kenobi Ben")
"Obi-wan Kenobi Ben"
Note that there are two occurrences of “Ben” in the string that was searched, but vl-string-subst replaces only the first occurrence.
formatted the code to look nicer
(defun c:FixPrefix
(/ OldPrefix NewPrefix ln
) NewPrefix "TTBK"
)
)
)
)
-
Roger that! Thanks mhupp