[ ---- ===={ Subtract Text Digits from last}=====----------------------]
[Author: Ganesh Kumar, Copyright © 2012 -www.autolispgs.blogspot.in ]
[-------------------------------------------------------------------------]
(defun c:ltd(/ *error* adoc digits en textval slen textupdate Loop)
(vl-load-com)
(defun *error* (msg)
(if adoc (vla-endundomark adoc))
(if (not (member msg '("Function cancelled" "quit / exit abort")))
(princ (strcat "\n--->Error :"msg))
)
(princ)
)
(setq adoc(vla-get-activedocument (vlax-get-acad-object)))
(if (setq digits (getint "\nHow Many Digits to Less? :"))
(progn
(setq Loop T)
(while Loop
(cond
( (< digits 0)
(princ "\nNegative Values are not allowed! Try again.")
(setq digits (getint "\nHow Many Digits to Less? :"))
)
( (= digits 0)
(princ "\n0 Value are not allowed! Try again.")
(setq digits (getint "\nHow Many Digits to Less? :"))
)
(t (setq Loop nil))
)
)
(vla-startundomark adoc)
(if (setq sset (ssget '((0 . "TEXT,MTEXT"))))
(progn
(repeat (setq i (sslength sset))
(setq en (vlax-ename->vla-object (ssname sset (setq i(1- i)))))
(setq textval (vla-get-textstring en))
(setq slen (strlen textval))
(setq Textupdate (substr textval 1 (- slen digits)))
(if (vlax-write-enabled-p en)
(vlax-put-property en 'Textstring Textupdate)
)
)
(vla-regen adoc acAllViewports)
)
(*error* "Non Object (s) selected!")
)
)
)
(vla-endundomark adoc)
(vlax-release-object adoc)
(princ)
)
[Author: Ganesh Kumar, Copyright © 2012 -www.autolispgs.blogspot.in ]
[-------------------------------------------------------------------------]
(defun c:ltd(/ *error* adoc digits en textval slen textupdate Loop)
(vl-load-com)
(defun *error* (msg)
(if adoc (vla-endundomark adoc))
(if (not (member msg '("Function cancelled" "quit / exit abort")))
(princ (strcat "\n--->Error :"msg))
)
(princ)
)
(setq adoc(vla-get-activedocument (vlax-get-acad-object)))
(if (setq digits (getint "\nHow Many Digits to Less? :"))
(progn
(setq Loop T)
(while Loop
(cond
( (< digits 0)
(princ "\nNegative Values are not allowed! Try again.")
(setq digits (getint "\nHow Many Digits to Less? :"))
)
( (= digits 0)
(princ "\n0 Value are not allowed! Try again.")
(setq digits (getint "\nHow Many Digits to Less? :"))
)
(t (setq Loop nil))
)
)
(vla-startundomark adoc)
(if (setq sset (ssget '((0 . "TEXT,MTEXT"))))
(progn
(repeat (setq i (sslength sset))
(setq en (vlax-ename->vla-object (ssname sset (setq i(1- i)))))
(setq textval (vla-get-textstring en))
(setq slen (strlen textval))
(setq Textupdate (substr textval 1 (- slen digits)))
(if (vlax-write-enabled-p en)
(vlax-put-property en 'Textstring Textupdate)
)
)
(vla-regen adoc acAllViewports)
)
(*error* "Non Object (s) selected!")
)
)
)
(vla-endundomark adoc)
(vlax-release-object adoc)
(princ)
)