Author Topic: Extracting from List  (Read 2186 times)

0 Members and 1 Guest are viewing this topic.

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Extracting from List
« on: March 07, 2006, 12:39:34 PM »

Can someone point me in the right direction. I have this list and it contains drawing names. I would like to extract out
1 drawing name at a time and save it as a variable until all of the drawings in the given list is complete. The list of drawing names in
the list can long or short depending on how many drawing names there are in the list. From that then I can utilize that particular variable for future use.

Code: [Select]
("O_SR01.DWG" "O_SR02.DWG" "O_SR03.DWG" "O_SR04.DWG" "O_SR05.DWG" "O_SR06.DWG"
"O_SR07.dwg" "O_SR08.DWG" "O_SR09.DWG" "O_SR10.DWG" "O_SR11.DWG" "O_SR12.DWG"
"O_SR13.DWG" "O_SR14.DWG" "O_SR15.DWG" "O_SR16.DWG" "O_SR17.DWG" "O_SRB1.DWG"
"O_SRM1.DWG" "O_SRM2.DWG" "O_SRM3.DWG" "O_SRM4.DWG" "O_SRSB.DWG")
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Extracting from List
« Reply #1 on: March 07, 2006, 12:53:43 PM »
(setq lst '("O_SR01.DWG" "O_SR02.DWG" "O_SR03.DWG"
       "O_SR04.DWG" "O_SR05.DWG" "O_SR06.DWG"
       "O_SR07.dwg" "O_SR08.DWG" "O_SR09.DWG"
       "O_SR10.DWG" "O_SR11.DWG" "O_SR12.DWG"
       "O_SR13.DWG" "O_SR14.DWG" "O_SR15.DWG"
       "O_SR16.DWG" "O_SR17.DWG" "O_SRB1.DWG"
       "O_SRM1.DWG" "O_SRM2.DWG" "O_SRM3.DWG"
       "O_SRM4.DWG" "O_SRSB.DWG"
      )
) ;_  setq

(foreach x lst
 ;|
X -  utilize that particular variable for future use.

 |;
(princ x)
 
(princ "\n")
)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Extracting from List
« Reply #2 on: March 07, 2006, 12:55:19 PM »
One way.  In the code posted below, all the variables will be prefixed with "Dwg" and then a number assigned as to where they are in the list.

Code: [Select]
(setq Lst '("O_SR01.DWG" "O_SR02.DWG" "O_SR03.DWG" "O_SR04.DWG" "O_SR05.DWG" "O_SR06.DWG"
"O_SR07.dwg" "O_SR08.DWG" "O_SR09.DWG" "O_SR10.DWG" "O_SR11.DWG" "O_SR12.DWG"
"O_SR13.DWG" "O_SR14.DWG" "O_SR15.DWG" "O_SR16.DWG" "O_SR17.DWG" "O_SRB1.DWG"
"O_SRM1.DWG" "O_SRM2.DWG" "O_SRM3.DWG" "O_SRM4.DWG" "O_SRSB.DWG"))
(setq cnt 1)
(foreach i Lst
 (set (read (strcat "Dwg" (itoa cnt))) i)
 (setq cnt (1+ cnt))
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: Extracting from List
« Reply #3 on: March 07, 2006, 01:17:56 PM »

Thanks guys for the direction.
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023