;;Remove specifed number of characters from the end of Text and MText objects
(defun c:RCF (/ adoc sstxt nchar n elst otxt ntxt nlst)
(vl-load-com)
(setq adoc (vla-get-activedocument (vlax-get-acad-object)))
(princ "Select Text Objects to Remove Characters From.")
(setq sstxt (ssget '((-4 . ""))))
(while (null (setq nchar (getint "\nSpecify Number of Characters to Remove from End of Text Objects: ")))
(princ "**Invalid Entry**")
)
(setq n 0)
(vla-StartUndoMark adoc)
(repeat (sslength sstxt)
(setq elst (entget (ssname sstxt n)))
(setq otxt (cdr (assoc 1 elst)))
(if (> (strlen otxt) nchar)
(progn
(setq ntxt (substr otxt 1 (- (strlen otxt) nchar)))
(setq nlst (subst (cons 1 ntxt) (assoc 1 elst) elst))
(entmod nlst)
)
(progn
(princ (strcat "\nExisting Text Object \"" otxt "\" Has Too Few Characters."))
(princ (strcat "\nText Object \"" otxt "\" Not Modified!!\n"))
)
)
(setq n (1+ n))
)
(vla-EndUndoMark adoc)
(princ)
)
(c:rcf)

Advertisements