TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: V-Man on March 07, 2006, 12:39:34 PM

Title: Extracting from List
Post by: V-Man 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")
Title: Re: Extracting from List
Post by: ElpanovEvgeniy 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")
)
Title: Re: Extracting from List
Post by: T.Willey 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))
)
Title: Re: Extracting from List
Post by: V-Man on March 07, 2006, 01:17:56 PM

Thanks guys for the direction.