(defun c:MU (/ txt1 txt2 cnt1 ent1 pec1 ss)
; Multiply value of numbers

(command "_.undo" "_end")
(command "_.undo" "_group")
(vl-load-com)
(setq txt1 (getreal "\nEnter value to multiply by. "))
(setq cnt1 0)
(if txt1
(progn
(if (not *pec1)
(setq *pec1 1)
)
(setq pec1 (getreal (strcat "\nHow many decimal places [" (itoa *pec1) "]? ")))
(if pec1
(setq *pec1 (fix pec1))
)
(setq ss (ssget '((0 . "TEXT"))))
(while (/= cnt1 (sslength ss))
(setq ent1 (MakeX (ssname ss cnt1)))
(setq txt2 (GetX ent1 'TextString))
(PutX ent1 'Textstring (AddStrNReal txt2 txt1 2 *pec1))
(setq cnt1 (1+ cnt1))
)
)
)
(prompt "\n May get rounded-off if new decimal is less then existing decimal places!!")
(command "_.undo" "_end")
(princ)
)

;----------------------------------------------------------------------------------------

(defun AddStrNReal (StrValue RealNum StrType DecPlace / cnt1 cnt2 txt4 txt5 txt6 txt7 op1 dec1)

(setq cnt1 0
cnt2 0
)
(while (not (<= 46 (ascii (substr StrValue 1 1)) 58))
(if txt4
(setq txt4 (strcat txt4 (substr StrValue 1 1)))
(setq txt4 (substr StrValue 1 1))
)
(setq StrValue (substr StrValue 2 (strlen StrValue)))
)

(while (= (substr StrValue 1 1) " ")
(if txt4
(setq txt4 (strcat txt4 (substr StrValue 1 1)))
(setq txt4 (substr StrValue 1 1))
)
(setq StrValue (substr StrValue 2 (strlen StrValue)))
)

(while (or ( (atoi txt6) 999)
(progn
(initget "Y N")
; (setq op1 (getkword "\nWould you like to add comma(s) [Y,]? "))
(setq op1 "N")
(if (= op1 "Y")
(progn
(setq txt7 txt6)
(while (and (/= dec1 ".") (= (strlen txt6) (+ cnt2 4))
(setq txt6 (strcat (substr txt6 1 (- (strlen txt6) (+ 3 cnt2))) "," (substr txt6 (- (strlen txt6) (+ 2 cnt2)) (strlen txt6))))
(setq cnt2 (+ cnt2 4))
)
(if (= dec1 ".")
(setq txt6 (strcat txt6 txt7))
)
)
)
)
)
(setq txt7
(if txt4
(strcat txt4 txt6 StrValue)
(strcat txt6 StrValue)
)
)

)

;-------------------------------------------------------------

(defun MakeX (entname)
(vlax-ename->vla-object entname)
)

(defun GetX (object prop)
(if (vlax-property-available-p object prop)
(vlax-get object prop)
)
)

(defun PutX (object prop val)
(if (vlax-property-available-p object prop T)
(vlax-put object prop val)
)
)

Advertisements