Hello David,
here is the whole code:
(defun c:talign_ ()
(setq thandle (list)); text handle
(setq thandle_ (list)); text handle working list
(setq x_dist 0.0000)
(setq x_val 0.0000)
(setq work_set (ssadd))
(setq _set_ (ssadd)); create empty selection set
(setq x_val (- (nth 0 (nth 1 (entsel "\nPick a Line to align to : \n"))) 0))
(if
(= (setq Ent (entsel "\nSelect TEXT to align\n")) nil)
(progn
(setq pt1 (getpoint "\nNothing Selected! \nSelection Window: \nFirst Point \n"))
(terpri)
(setq pt2 (getcorner "second Point" pt1))
(terpri)
(setq _set_ (ssget "_W" pt1 pt2))
(terpri)
);end progn
(ssadd (car Ent) _set_); add object handle to empty selection set
);end if
(setq setlen (sslength _set_))
(setq counter 0)
(repeat setlen
(setq ent (ssname _set_ counter))
(setq sstr (entget ent))
(if ; TEXT
(= (cdr (assoc 0 sstr)) "TEXT")
(setq thandle
(append thandle
(list
(cdr (assoc -1 sstr))
)
)
)
); end if text
(setq counter (1+ counter))
);end von repeat setlen
(setq _set_ nil)
(setq thandle_ thandle)
(repeat (length thandle)
(setq sstr__ nil)
(setq sstr (entget (car thandle_)))
(if
(= "TEXT" (cdr (assoc 0 sstr)))
(progn
(setq x_point (nth 0 (cdr (assoc 10 sstr))))
(if (> x_point x_val) ;LEFT
(progn
(ssadd (car thandle_) work_set)
(command "_.justifytext" work_set "" "LEFT")
(ssdel (car thandle_) work_set)
(setq sstr__ (entget (car thandle_)))
(setq x_point (nth 0 (cdr (assoc 10 sstr__))))
(setq x_point_ (nth 0 (cdr (assoc 11 sstr__))))
(setq x_dist 0)
(setq x_dist (- x_val x_point))
(setq move_ (list x_dist 0.0))
(ssadd (car thandle_) work_set)
(command "_.move" work_set "" move_ "")
(ssdel (car thandle_) work_set)
(setq sstr__ nil)
)
)
(if (< x_point x_val) ;RIGHT
(progn
(ssadd (car thandle_) work_set)
(command "_.justifytext" work_set "" "Right")
(ssdel (car thandle_) work_set)
(setq sstr__ (entget (car thandle_)))
(setq x_point (nth 0 (cdr (assoc 10 sstr__))))
(setq x_point_ (nth 0 (cdr (assoc 11 sstr__))))
(setq x_dist 0)
(setq x_dist (- x_val x_point_))
(setq move_ (list x_dist 0.0))
(ssadd (car thandle_) work_set)
(command "_.move" work_set "" move_ "")
(ssdel (car thandle_) work_set)
(setq sstr__ nil)
)
);end von if
); end orogn
); end if
(setq thandle_ (cdr thandle_))
); end repeat len thandle
(setq thandle nil)
(setq thandle_ nil)
(setq work_set nil)
(setq _set_ nil)
(princ); silent end
)
After 4 or 5 times running this routine i get an ads error:
ADS ERROR: Exceeded maximum number of selection sets, even
running stuff like clearss.lsp doesn't fix this problem. The only
way is to restart autocad. My question: is there any way to clear
the memory or to reset the whole selection set variable, means
after resetting i start with selection set 0 again, without restarting autocad.
Regards,
Gernot Janschewski