;|=============================================================|; ;| Strip.lsp by Michael Bulatovich, 11th Dec., 2000 |; ;| www.michaelbulatovich.ca |; ;| Strips off leading spaces in simple text entities. |; ;| |; ;|=============================================================|; (Defun C:strip (/ sset sslen counter tname tlist strng cntr check newstrng) (princ "To strip leading spaces from text......") (setq sset (ssget)) (setq sslen (sslength sset)) (if sset (setq counter 0) (progn (print "No items selected.") (quit)) ) ;set an entity counter, or quits (while (< counter sslen) (setq tname (ssname sset counter)) ;Gets the name of the first (next) entity in the set. (setq tlist (entget tname)) ;get it's data list (setq strng (cdr (assoc 1 tlist))) ;isolate the string (if (eq (substr strng 1 1) " ") ;if the first character is a space (setq cntr 1) ;set a counter ) (if cntr ;if the counter exists (progn (while cntr ;while the counter exists (setq check cntr) ;set check to counter (if (eq (substr strng check 1) " ") ;if the frirst character's a space (setq cntr (1+ cntr)) ;bump the counter (setq cntr nil) ;nil the counter to break the loop ) ;end if ) ;end while (setq newstrng (substr strng check)) ;retrieve the substring without spaces (setq tlist (subst (cons '1 newstrng) (assoc 1 tlist) tlist)) ;replace newlist for oldlist (entmod tlist) ;modify the entity ) ) (setq counter (1+ counter)) ;bump the entity counter ) ;end while ) ;end defun