TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: CADaver on September 11, 2004, 06:01:13 PM
-
Is there a nifty VLA or (GET-sumptin) or something that will extract block names and layer names as a string without the xref name itself??
FROM
MainRack|W14X43
to
W14x43
-
Something like this ??
(setq xx "MainRack|W14X43")
(if (setq index (vl-string-search "|" xx))
(setq
prefix (substr xx 1 index)
suffix (substr xx (+ 2 index))
)
)
-
Sure, here ya go....
Usage: (setq str "MainRack|W14X43")
(setq newstr (strip2bar str))
(defun strip2bar (str / pos)
(setq pos (vl-string-search "|" str))
(if (not pos) (setq pos -1));set pos incase "|" not found
;increment pos by 2, 1 for 0 vs 1 based index, 1 for next character
(substr str (+ pos 2))
)
-
Arghhh! Beat out by Kerry.....no one's even here on Saturday/Sunday and I still get beat by a few minutes...... :/
-
Dont feel bad Jeff. I beat myself all the time.
Oops, too much information ??
-
:)
-
Arrrrggghhh... you won't believe how many times I went through the book and help files looking for vl-string-search and missed it every time.
Someday when I learn some of this lispy stuff, I might actually be useful.
Thanks a load guys, appreciate the help.
-
If you modify Jeff's code to the following you can search and extract any string. May come in handy when stripping the layer names in bound drawings.
(defun stripstr (str itm/ pos)
(setq pos (vl-string-search itm str))
(if (not pos) (setq pos -1));set pos incase item looking for not found not found
;increment pos by 2, 1 for 0 vs 1 based index, 1 for next character
(substr str (+ pos 2))
);
enjoy! :)