Author Topic: Extracting XREF strings after the "|"  (Read 3204 times)

0 Members and 1 Guest are viewing this topic.

CADaver

  • Guest
Extracting XREF strings after the "|"
« 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

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Extracting XREF strings after the "|"
« Reply #1 on: September 11, 2004, 06:20:18 PM »
Something like this ??
Code: [Select]

(setq xx "MainRack|W14X43")

(if (setq index (vl-string-search "|" xx))
 (setq
   prefix (substr xx 1 index)
   suffix (substr xx (+ 2 index))
 )
)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Extracting XREF strings after the "|"
« Reply #2 on: September 11, 2004, 06:24:30 PM »
Sure, here ya go....
Usage: (setq str "MainRack|W14X43")
           (setq newstr (strip2bar str))
Code: [Select]

(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))
  )

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Extracting XREF strings after the "|"
« Reply #3 on: September 11, 2004, 06:26:47 PM »
Arghhh! Beat out by Kerry.....no one's even here on Saturday/Sunday and I still get beat by a few minutes...... :/

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Extracting XREF strings after the "|"
« Reply #4 on: September 11, 2004, 06:34:00 PM »
Dont feel bad Jeff.  I beat myself all the time.  

Oops, too much information ??
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Ron Heigh

  • Guest
Extracting XREF strings after the "|"
« Reply #5 on: September 11, 2004, 06:51:07 PM »
:)

CADaver

  • Guest
Extracting XREF strings after the "|"
« Reply #6 on: September 11, 2004, 07:28:15 PM »
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.

SPDCad

  • Bull Frog
  • Posts: 453
Extracting XREF strings after the "|"
« Reply #7 on: September 11, 2004, 09:52:12 PM »
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! :)
AutoCAD 2010, w/ OpenDCL

visit: http://reachme.at/spd_designs