(defun ini_btl( /	all_btl		k		btl_count)
  (setq all_btl (ssget "X" '((0 . "INSERT") (2 . "BTL_BTL"))))
  (if all_btl
    (progn
      (setq btl_count (sslength all_btl))
      (setq k 0)
      (while (< k btl_count)
	(setq btl_ent (ssname all_btl k))
	(mklst btl_ent)
	(setq k (+ k 1))
      )
    )
  )
)

(defun mklst(ent_name /	ent_nam		ent_sca		ent_filn	ent_uni		ent_num
			ent_shf		ent_sh		ent_vers	ent_mat		ent_dat
			ent_shr		entv		namv		scav		filnv	
			univ		numv		shfv		shv		versv
			matv		datv 		shrv)
  (setq ent_nam  (entnext ent_name)
	ent_sca  (entnext ent_nam)
	ent_filn (entnext ent_sca)
	ent_uni  (entnext ent_filn)
	ent_num  (entnext ent_uni)
	ent_shf  (entnext ent_num)
	ent_sh   (entnext ent_shf)
	ent_vers (entnext ent_sh)
	ent_mat  (entnext ent_vers)
	ent_dat  (entnext ent_mat)
	ent_shr  (entnext ent_dat)
	ent_fileno (entnext ent_shr)
	ent_machine (entnext ent_fileno)
  )
  (setq entv  (cdr (assoc 5 (entget ent_name)))
	namv  (cdr (assoc 1 (entget ent_nam)))
	scav  (cdr (assoc 1 (entget ent_sca)))
	filnv (cdr (assoc 1 (entget ent_filn)))
	univ  (cdr (assoc 1 (entget ent_uni)))
	numv  (cdr (assoc 1 (entget ent_num)))
	shfv  (cdr (assoc 1 (entget ent_shf)))
	shv   (cdr (assoc 1 (entget ent_sh)))
	versv (cdr (assoc 1 (entget ent_vers)))
	matv  (cdr (assoc 1 (entget ent_mat)))
	datv  (cdr (assoc 1 (entget ent_dat)))
	shrv  (cdr (assoc 1 (entget ent_sca)))
	filenov (cdr (assoc 1 (entget ent_fileno)))
	machinev (cdr (assoc 1 (entget ent_machine)))
  )
  (if (= 0 k) 
    (setq btl_1 (list entv namv scav filnv univ numv shfv shv versv matv datv shrv filenov machinev))
  )
  (if btl_sel
    (setq btl_sel (append btl_sel (list entv))
	  btl_num (append btl_num (list numv))
    )
    (setq btl_sel (list entv)
	  btl_num (list numv)
    )
  )
)

;------------------------------------------------------------------------------------;
(defun xh_get(item list / n)
  (setq counti nil)
  (setq n 0)
  (while (< n (length list))
	(if (= item (nth n list))
	  (setq counti n)
	)
	(setq n (+ n 1))
  )
  (setq counti counti)
)
;------------------------------------------------------------------------------------;
