Lisp lệnh TCAL trong chủ đề “LISP cộng têxt toàn bộ bản vẽ thêm 1 hằng sô”
Thêm 1 chú nữa:
;; free lisp from cadviet.com ;;; this lisp was downloaded from https://www.cadviet.com/forum/index.php?showtopic=37567 ;;----------------------------------------------;; ;; Text calculation tool - Skywings ;; ;;----------------------------------------------;; ;;***SUB-FUNCTION*** (defun GET-TEXT () (princ "\nSelect NUMBERs : ") (while (null (setq Numbers (ssget '((0 . "*TEXT"))))) (princ "\n**NOTHING selected!**") ) ) (defun GET-DATA (/ ss-mt ss-t n) (setq ss-mt (ssadd) ss-t (ssadd) n 0 sw 0 ) (repeat (sslength Numbers) (setq ent (ssname Numbers n)) (if (= (cdr (assoc 0 (entget ent))) "MTEXT") (setq ss-mt (ssadd ent ss-mt)) (setq ss-t (ssadd ent ss-t)) ) (setq n (1+ n)) ) (if (/= (sslength ss-mt) 0) (setq Numbers (acet-explode ss-mt) sw 1 ) ) (setq n 0) (repeat (sslength ss-t) (setq ent (ssname ss-t n) Numbers (ssadd ent Numbers) n (1+ n) ) ) ) (defun GET-VALUE (name / sw) (princ (strcat "\nSelect " name " : ")) (cond ((= (cdr (assoc 0 (entget ename))) "MTEXT") (command ".explode" ename "") (setq value (read (cdr (assoc 1 (entget (entlast))))) sw 1 ) ) ((setq value (read (cdr (assoc 1 (entget ent)))))) ) (if (= sw 1) (command ".undo" 1) ) value ) (defun OPT () (if (null option) (setq option "Replace" save2 option ) ) (initget "Replace Create Do-nothing") (setq option (getkword (strcat "\nOptions: <" option "> " ) ) ) (if (null option) (setq option save2) (setq save2 option) ) (setq switch 1) ) (defun ACTION (option result / txt pnt) (cond ((= option "Replace") (while (null (setq txt (entsel "\nChoose TEXT to replace: "))) (princ "\n**NOTHING selected!**") ) (setq txt (entget (car txt)) txt (subst (cons 1 result) (assoc 1 txt) txt) ) (entmod txt) ) ((= option "Create") (setq pnt (getpoint "\nSpecify start point of text:")) (entmake (list (assoc 0 ent) (assoc 8 ent) (cons 1 result) (cons 10 (trans pnt 1 0)) (assoc 40 ent) (assoc 7 ent) (assoc 50 ent) ) ) ) ) ) (defun GET-ORDER () (princ (strcat "\nCurrent setting: Precision = " (rtos precision 2 0) " <" (rtos 0 2 precision) ">" ) ) (initget "Plus Subtract Multiply Divide Average maX-min ADd-by mUltiply-by preCision" ) (setq operation (getkword (strcat "\nOperations: : <" operation "> " ) ) ) (if (null operation) (setq operation save1) (setq save1 operation) ) ) ;;***MAIN FUNCTION***: (defun c:TCAL (/ Numbers DIVIDEND DIVISOR ENT ID INDEX MINUEND NUM-MAX NUM-MIN NUM-SET RESULT SUBTRAHEND SWITCH VALUE sw ) (princ "** Text calculation tool - Skywings **" ) (setvar "CMDECHO" 0) (setvar "QAFLAGS" 1) (if (null precision) (setq precision 2 save3 precision ) ) (if (null operation) (setq operation "Plus" save1 operation ) ) (GET-ORDER) (while (= operation "preCision") (initget 4) (setq precision (getint (strcat "\nSpecify new precision: <" (rtos precision 2 0) "> " ) ) ) (if (null precision) (setq precision save3) (setq save3 precision) ) (GET-ORDER) ) (cond ;; PLUS: ((= operation "Plus") (GET-TEXT) (setq switch 0) (while (/= Numbers nil) (GET-DATA) (setq index 0 result 0 ) (princ "\n>>Expression: ") (repeat (sslength Numbers) (setq ent (entget (ssname Numbers index)) value (read (cdr (assoc 1 ent))) index (1+ index) ) (if (numberp value) (progn (setq result (+ result value)) (if (/= index 1) (princ " + ") ) (princ (rtos value 2 precision)) ) ) ) (if (= sw 1) (command ".undo" 1)) (princ (strcat "\n>>RESULT = " (rtos result 2 precision))) (if (= switch 0) (OPT) ) (ACTION option (rtos result 2 precision)) (setq Numbers nil Numbers (ssget '((0 . "*TEXT"))) ) ) ) ;; MULTIPLY: ((= operation "Multiply") (GET-TEXT) (setq switch 0) (while (/= Numbers nil) (GET-DATA) (setq index 0 result 1 ) (princ "\n>>Expression: ") (repeat (sslength Numbers) (setq ent (entget (ssname Numbers index)) value (read (cdr (assoc 1 ent))) index (1+ index) ) (if (numberp value) (progn (setq result (* result value)) (if (/= index 1) (princ " * ") ) (princ (rtos value 2 precision)) ) ) ) (if (= sw 1) (command ".undo" 1) ) (princ (strcat "\n>>RESULT = " (rtos result 2 precision))) (if (= switch 0) (OPT) ) (ACTION option (rtos result 2 precision)) (setq Numbers nil Numbers (ssget '((0 . "*TEXT"))) ) ) ) ;; SUBTRACT: ((= operation "Subtract") (setq switch 0 sw 0 ) (while (null (setq ename (car (entsel (strcat "\nSelect MINUEND : ")))))) (setq minuend (GET-VALUE "MINUEND")) (while (null (numberp minuend)) (while (null (setq ename (car (entsel (strcat "\nSelect MINUEND : ")))))) (setq minuend (GET-VALUE "MINUEND")) ) (princ minuend) (redraw ename 3) (princ "\nSelect SUBTRAHENDs : ") (while (null (setq Numbers (ssget '((0 . "*TEXT"))))) (princ "\nSelect SUBTRAHENDs : ") ) (redraw ename 4) (while (/= ename nil) (GET-DATA) (setq index 0 result 0 minuend (float minuend) ) (princ (strcat "\n>>Expression: " (rtos minuend 2 precision) " - (" ) ) (repeat (sslength Numbers) (setq ent (entget (ssname Numbers index)) subtrahend (read (cdr (assoc 1 ent))) index (1+ index) ) (if (numberp subtrahend) (progn (setq result (+ result subtrahend)) (if (/= index 1) (princ " + ") ) (princ (rtos subtrahend 2 precision)) ) ) ) (princ ")") (if (= sw 1) (command ".undo" 1) ) (setq result (- minuend result)) (princ (strcat "\n>>RESULT = " (rtos result 2 precision))) (if (= switch 0) (OPT) ) (ACTION option (rtos result 2 precision)) (setq ename nil ename (car (entsel (strcat "\nSelect MINUEND : "))) ) (if (or (null ename) (null (numberp (setq minuend (GET-VALUE "MINUEND")))) ) (progn (setvar "QAFLAGS" 0) (vl-exit-with-error "") ) ) (princ minuend) (princ "\nSelect SUBTRAHENDs <TEXT>: ") (while (null (setq Numbers (ssget '((0 . "*TEXT"))))) (princ "\nSelect SUBTRAHENDs : ") ) ) ) ;; DIVIDE: ((= operation "Divide") (setq switch 0 sw 0 ) (while (null (setq ename (car (entsel (strcat "\nSelect DIVIDEND : ")))))) (setq dividend (GET-VALUE "DIVIDEND")) (while (null (numberp dividend)) (while (null (setq ename (car (entsel (strcat "\nSelect DIVIDEND : ")))))) (setq dividend (GET-VALUE "DIVIDEND")) ) (princ dividend) (redraw ename 3) (princ "\nSelect DIVISORs : ") (while (null (setq Numbers (ssget '((0 . "*TEXT"))))) (princ "\nSelect DIVISORs : ") ) (redraw ename 4) (while (/= ename nil) (GET-DATA) (setq index 0 result 1 dividend (float dividend) ) (princ (strcat "\n>>Expression: " (rtos dividend 2 precision) " / (" ) ) (repeat (sslength Numbers) (setq ent (entget (ssname Numbers index)) divisor (read (cdr (assoc 1 ent))) index (1+ index) ) (if (numberp divisor) (progn (setq result (* result divisor)) (if (/= index 1) (princ " * ") ) (princ (rtos divisor 2 precision)) ) ) ) (princ ")") (if (= sw 1) (command ".undo" 1) ) (setq result (/ dividend result)) (princ (strcat "\n>>RESULT = " (rtos result 2 precision))) (if (= switch 0) (OPT) ) (ACTION option (rtos result 2 precision)) (setq ename nil ename (car (entsel (strcat "\nSelect DIVIDEND : "))) ) (if (or (null ename) (null (numberp (setq dividend (GET-VALUE "DIVIDEND")))) ) (progn (setvar "QAFLAGS" 0) (vl-exit-with-error "") ) ) (princ dividend) (princ "\nSelect DIVISORs : ") (while (null (setq Numbers (ssget '((0 . "*TEXT"))))) (princ "\nSelect DIVISORs : ") ) ) ) ;; AVERAGE: ((= operation "Average") (GET-TEXT) (setq switch 0) (while (/= Numbers nil) (GET-DATA) (setq index 0 id 0 result 0 ) (princ "\n>>Expression: (") (repeat (sslength Numbers) (setq ent (entget (ssname Numbers index)) value (read (cdr (assoc 1 ent))) index (1+ index) ) (if (numberp value) (progn (setq result (+ result value) id (1+ id) ) (if (/= index 1) (princ " + ") ) (princ (rtos value 2 precision)) ) ) ) (if (= sw 1) (command ".undo" 1)) (setq result (rtos (/ (float result) id) 2 precision)) (princ (strcat ") / " (rtos id 2 0))) (princ (strcat "\n>>RESULT = " result)) (if (= switch 0) (OPT) ) (ACTION option result) (setq Numbers nil Numbers (ssget '((0 . "*TEXT"))) ) ) ) ;; MAX-MIN: ((= operation "maX-min") (GET-TEXT) (setq switch 0) (while (/= Numbers nil) (GET-DATA) (setq index 0 Num-set nil ) (repeat (sslength Numbers) (setq ent (entget (ssname Numbers index)) value (read (cdr (assoc 1 ent))) index (1+ index) ) (if (numberp value) (setq Num-set (cons value Num-set)) ) ) (setq Num-set (vl-sort Num-set '>) num-max (car Num-set) num-min (last Num-set) result (strcat "MAX = " (rtos num-max 2 precision) " MIN = " (rtos num-min 2 precision) ) ) (if (= sw 1) (command ".undo" 1)) (princ "\n>>Numbers set: ") (princ Num-set) (print) (princ result) (if (= switch 0) (OPT) ) (ACTION option result) (setq Numbers nil Numbers (ssget '((0 . "*TEXT"))) ) ) ) ;; ADD-BY...: ((= operation "ADd-by") (if (null number0) (setq number0 0.00 save4 number0 ) ) (setq number0 (getreal (strcat "Add by: <" (rtos number0 2 2) "> ")) index 0 ) (if (null number0) (setq number0 save4) (setq save4 number0) ) (GET-TEXT) (GET-DATA) (repeat (sslength Numbers) (setq ent (entget (ssname Numbers index)) value (read (cdr (assoc 1 ent))) index (1+ index) ) (if (numberp value) (setq value (+ (float value) number0) ent (subst (cons 1 (rtos value 2 precision)) (assoc 1 ent) ent ) ) ) (entmod ent) ) ) ;;MULTIPLY-BY...: ((= operation "mUltiply-by") (if (null number0) (setq number0 0.00 save4 number0 ) ) (setq number0 (getreal (strcat "Multiply by: <" (rtos number0 2 2) "> ")) index 0 ) (if (null number0) (setq number0 save4) (setq save4 number0) ) (GET-TEXT) (GET-DATA) (repeat (sslength Numbers) (setq ent (entget (ssname Numbers index)) value (read (cdr (assoc 1 ent))) index (1+ index) ) (if (numberp value) (setq value (* (float value) number0) ent (subst (cons 1 (rtos value 2 precision)) (assoc 1 ent) ent ) ) ) (entmod ent) ) ) ) (princ "<Exit>") (setvar "QAFLAGS" 0) (princ) )
Tcal dùng lựa chọn AD (add-by) nhập hằng số K là -K nếu muốn trừ, K nếu muốn cộng
Bạn ơi bạn có thể thêm tiền tố vào trước kết quả xuất ra không? ví dụ (+1) + (+1) = (+2) tương tự với các ký tự khác ví dụ (layer1: 1,2) + (3) = (layer1: 3,2).
Và thêm phần +,-,*,/ với số nhập từ bàn phím nữa thì quá tuyệt. Thanks:D
- Tải lisp
- 198615_tcal.lsp
Cách dùng
- Tải tệp 198615_tcal.lsp về máy.
- Trong AutoCAD gõ lệnh APPLOAD, chọn tệp vừa tải rồi bấm Load. Cũng có thể kéo thả tệp .lsp vào cửa sổ bản vẽ.
- Gõ lệnh TCAL để chạy lisp.
Mã nguồn 198615_tcal.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/10226-lisp-c%E1%BB%99ng-t%C3%AAxt-to%C3%A0n-b%E1%BB%99-b%E1%BA%A3n-v%E1%BA%BD-th%C3%AAm-1-h%E1%BA%B1ng-s%C3%B4/
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/index.php?showtopic=37567
;;----------------------------------------------;;
;; Text calculation tool - Skywings ;;
;;----------------------------------------------;;
;;***SUB-FUNCTION***
(defun GET-TEXT ()
(princ "\nSelect NUMBERs : ")
(while (null (setq Numbers (ssget '((0 . "*TEXT")))))
(princ "\n**NOTHING selected!**")
)
)
(defun GET-DATA (/ ss-mt ss-t n)
(setq ss-mt (ssadd)
ss-t (ssadd)
n 0
sw 0
)
(repeat (sslength Numbers)
(setq ent (ssname Numbers n))
(if (= (cdr (assoc 0 (entget ent))) "MTEXT")
(setq ss-mt (ssadd ent ss-mt))
(setq ss-t (ssadd ent ss-t))
)
(setq n (1+ n))
)
(if (/= (sslength ss-mt) 0)
(setq Numbers (acet-explode ss-mt)
sw 1
)
)
(setq n 0)
(repeat (sslength ss-t)
(setq ent (ssname ss-t n)
Numbers (ssadd ent Numbers)
n (1+ n)
)
)
)
(defun GET-VALUE (name / sw)
(princ (strcat "\nSelect " name " : "))
(cond
((= (cdr (assoc 0 (entget ename))) "MTEXT")
(command ".explode" ename "")
(setq value (read (cdr (assoc 1 (entget (entlast)))))
sw 1
)
)
((setq value (read (cdr (assoc 1 (entget ent))))))
)
(if (= sw 1)
(command ".undo" 1)
)
value
)
(defun OPT ()
(if (null option)
(setq option "Replace"
save2 option
)
)
(initget "Replace Create Do-nothing")
(setq
option
(getkword
(strcat "\nOptions: [Replace/Create/Do-nothing] <"
option
"> "
)
)
)
(if (null option)
(setq option save2)
(setq save2 option)
)
(setq switch 1)
)
(defun ACTION (option result / txt pnt)
(cond
((= option "Replace")
(while (null (setq txt (entsel "\nChoose TEXT to replace: ")))
(princ "\n**NOTHING selected!**")
)
(setq txt (entget (car txt))
txt (subst (cons 1 result) (assoc 1 txt) txt)
)
(entmod txt)
)
((= option "Create")
(setq pnt (getpoint "\nSpecify start point of text:"))
(entmake (list (assoc 0 ent)
(assoc 8 ent)
(cons 1 result)
(cons 10 (trans pnt 1 0))
(assoc 40 ent)
(assoc 7 ent)
(assoc 50 ent)
)
)
)
)
)
(defun GET-ORDER ()
(princ (strcat "\nCurrent setting: Precision = "
(rtos precision 2 0)
" <"
(rtos 0 2 precision)
">"
)
)
(initget
"Plus Subtract Multiply Divide Average maX-min ADd-by mUltiply-by preCision"
)
(setq operation
(getkword
(strcat
"\nOperations: [Plus/Subtract/Multiply/Divide/Average/maX-min/ADd-by/mUltiply-by/preCision]: <"
operation
"> "
)
)
)
(if (null operation)
(setq operation save1)
(setq save1 operation)
)
)
;;***MAIN FUNCTION***:
(defun c:TCAL (/ Numbers DIVIDEND DIVISOR ENT ID
INDEX MINUEND NUM-MAX NUM-MIN NUM-SET
RESULT SUBTRAHEND SWITCH VALUE
sw
)
(princ
"** Text calculation tool - Skywings **"
)
(setvar "CMDECHO" 0)
(setvar "QAFLAGS" 1)
(if (null precision)
(setq precision 2
save3 precision
)
)
(if (null operation)
(setq operation "Plus"
save1 operation
)
)
(GET-ORDER)
(while (= operation "preCision")
(initget 4)
(setq
precision (getint (strcat "\nSpecify new precision: <"
(rtos precision 2 0)
"> "
)
)
)
(if (null precision)
(setq precision save3)
(setq save3 precision)
)
(GET-ORDER)
)
(cond
;; PLUS:
((= operation "Plus")
(GET-TEXT)
(setq switch 0)
(while (/= Numbers nil)
(GET-DATA)
(setq index 0
result 0
)
(princ "\n>>Expression: ")
(repeat (sslength Numbers)
(setq ent (entget (ssname Numbers index))
value (read (cdr (assoc 1 ent)))
index (1+ index)
)
(if (numberp value)
(progn
(setq result (+ result value))
(if (/= index 1)
(princ " + ")
)
(princ (rtos value 2 precision))
)
)
)
(if (= sw 1) (command ".undo" 1))
(princ (strcat "\n>>RESULT = " (rtos result 2 precision)))
(if (= switch 0)
(OPT)
)
(ACTION option (rtos result 2 precision))
(setq Numbers nil
Numbers (ssget '((0 . "*TEXT")))
)
)
)
;; MULTIPLY:
((= operation "Multiply")
(GET-TEXT)
(setq switch 0)
(while (/= Numbers nil)
(GET-DATA)
(setq index 0
result 1
)
(princ "\n>>Expression: ")
(repeat (sslength Numbers)
(setq ent (entget (ssname Numbers index))
value (read (cdr (assoc 1 ent)))
index (1+ index)
)
(if (numberp value)
(progn
(setq result (* result value))
(if (/= index 1)
(princ " * ")
)
(princ (rtos value 2 precision))
)
)
)
(if (= sw 1)
(command ".undo" 1)
)
(princ (strcat "\n>>RESULT = " (rtos result 2 precision)))
(if (= switch 0)
(OPT)
)
(ACTION option (rtos result 2 precision))
(setq Numbers nil
Numbers (ssget '((0 . "*TEXT")))
)
)
)
;; SUBTRACT:
((= operation "Subtract")
(setq switch 0
sw 0
)
(while (null (setq ename (car (entsel (strcat "\nSelect MINUEND : "))))))
(setq minuend (GET-VALUE "MINUEND"))
(while (null (numberp minuend))
(while (null (setq ename (car (entsel (strcat "\nSelect MINUEND : "))))))
(setq minuend (GET-VALUE "MINUEND"))
)
(princ minuend)
(redraw ename 3)
(princ "\nSelect SUBTRAHENDs : ")
(while (null (setq Numbers (ssget '((0 . "*TEXT")))))
(princ "\nSelect SUBTRAHENDs : ")
)
(redraw ename 4)
(while (/= ename nil)
(GET-DATA)
(setq index 0
result 0
minuend (float minuend)
)
(princ (strcat "\n>>Expression: "
(rtos minuend 2 precision)
" - ("
)
)
(repeat (sslength Numbers)
(setq ent (entget (ssname Numbers index))
subtrahend (read (cdr (assoc 1 ent)))
index (1+ index)
)
(if (numberp subtrahend)
(progn
(setq result (+ result subtrahend))
(if (/= index 1)
(princ " + ")
)
(princ (rtos subtrahend 2 precision))
)
)
)
(princ ")")
(if (= sw 1)
(command ".undo" 1)
)
(setq result (- minuend result))
(princ (strcat "\n>>RESULT = " (rtos result 2 precision)))
(if (= switch 0)
(OPT)
)
(ACTION option (rtos result 2 precision))
(setq ename nil
ename (car (entsel (strcat "\nSelect MINUEND : ")))
)
(if
(or
(null ename)
(null (numberp (setq minuend (GET-VALUE "MINUEND"))))
)
(progn
(setvar "QAFLAGS" 0)
(vl-exit-with-error "")
)
)
(princ minuend)
(princ "\nSelect SUBTRAHENDs <TEXT>: ")
(while (null (setq Numbers (ssget '((0 . "*TEXT")))))
(princ "\nSelect SUBTRAHENDs : ")
)
)
)
;; DIVIDE:
((= operation "Divide")
(setq switch 0
sw 0
)
(while (null (setq ename (car (entsel (strcat "\nSelect DIVIDEND : "))))))
(setq dividend (GET-VALUE "DIVIDEND"))
(while (null (numberp dividend))
(while (null (setq ename (car (entsel (strcat "\nSelect DIVIDEND : "))))))
(setq dividend (GET-VALUE "DIVIDEND"))
)
(princ dividend)
(redraw ename 3)
(princ "\nSelect DIVISORs : ")
(while (null (setq Numbers (ssget '((0 . "*TEXT")))))
(princ "\nSelect DIVISORs : ")
)
(redraw ename 4)
(while (/= ename nil)
(GET-DATA)
(setq index 0
result 1
dividend (float dividend)
)
(princ (strcat "\n>>Expression: "
(rtos dividend 2 precision)
" / ("
)
)
(repeat (sslength Numbers)
(setq ent (entget (ssname Numbers index))
divisor (read (cdr (assoc 1 ent)))
index (1+ index)
)
(if (numberp divisor)
(progn
(setq result (* result divisor))
(if (/= index 1)
(princ " * ")
)
(princ (rtos divisor 2 precision))
)
)
)
(princ ")")
(if (= sw 1)
(command ".undo" 1)
)
(setq result (/ dividend result))
(princ (strcat "\n>>RESULT = " (rtos result 2 precision)))
(if (= switch 0)
(OPT)
)
(ACTION option (rtos result 2 precision))
(setq ename nil
ename (car (entsel (strcat "\nSelect DIVIDEND : ")))
)
(if
(or
(null ename)
(null (numberp (setq dividend (GET-VALUE "DIVIDEND"))))
)
(progn
(setvar "QAFLAGS" 0)
(vl-exit-with-error "")
)
)
(princ dividend)
(princ "\nSelect DIVISORs : ")
(while (null (setq Numbers (ssget '((0 . "*TEXT")))))
(princ "\nSelect DIVISORs : ")
)
)
)
;; AVERAGE:
((= operation "Average")
(GET-TEXT)
(setq switch 0)
(while (/= Numbers nil)
(GET-DATA)
(setq index 0
id 0
result 0
)
(princ "\n>>Expression: (")
(repeat (sslength Numbers)
(setq ent (entget (ssname Numbers index))
value (read (cdr (assoc 1 ent)))
index (1+ index)
)
(if (numberp value)
(progn
(setq result (+ result value)
id (1+ id)
)
(if (/= index 1)
(princ " + ")
)
(princ (rtos value 2 precision))
)
)
)
(if (= sw 1) (command ".undo" 1))
(setq result (rtos (/ (float result) id) 2 precision))
(princ (strcat ") / " (rtos id 2 0)))
(princ (strcat "\n>>RESULT = " result))
(if (= switch 0)
(OPT)
)
(ACTION option result)
(setq Numbers nil
Numbers (ssget '((0 . "*TEXT")))
)
)
)
;; MAX-MIN:
((= operation "maX-min")
(GET-TEXT)
(setq switch 0)
(while (/= Numbers nil)
(GET-DATA)
(setq index 0
Num-set nil
)
(repeat (sslength Numbers)
(setq ent (entget (ssname Numbers index))
value (read (cdr (assoc 1 ent)))
index (1+ index)
)
(if (numberp value)
(setq Num-set (cons value Num-set))
)
)
(setq Num-set (vl-sort Num-set '>)
num-max (car Num-set)
num-min (last Num-set)
result (strcat "MAX = "
(rtos num-max 2 precision)
" MIN = "
(rtos num-min 2 precision)
)
)
(if (= sw 1) (command ".undo" 1))
(princ "\n>>Numbers set: ")
(princ Num-set)
(print)
(princ result)
(if (= switch 0)
(OPT)
)
(ACTION option result)
(setq Numbers nil
Numbers (ssget '((0 . "*TEXT")))
)
)
)
;; ADD-BY...:
((= operation "ADd-by")
(if (null number0)
(setq number0 0.00
save4 number0
)
)
(setq number0 (getreal (strcat "Add by: <" (rtos number0 2 2) "> "))
index 0
)
(if (null number0)
(setq number0 save4)
(setq save4 number0)
)
(GET-TEXT)
(GET-DATA)
(repeat (sslength Numbers)
(setq ent (entget (ssname Numbers index))
value (read (cdr (assoc 1 ent)))
index (1+ index)
)
(if (numberp value)
(setq value (+ (float value) number0)
ent (subst (cons 1 (rtos value 2 precision))
(assoc 1 ent)
ent
)
)
)
(entmod ent)
)
)
;;MULTIPLY-BY...:
((= operation "mUltiply-by")
(if (null number0)
(setq number0 0.00
save4 number0
)
)
(setq number0 (getreal (strcat "Multiply by: <" (rtos number0 2 2) "> "))
index 0
)
(if (null number0)
(setq number0 save4)
(setq save4 number0)
)
(GET-TEXT)
(GET-DATA)
(repeat (sslength Numbers)
(setq ent (entget (ssname Numbers index))
value (read (cdr (assoc 1 ent)))
index (1+ index)
)
(if (numberp value)
(setq value (* (float value) number0)
ent (subst (cons 1 (rtos value 2 precision))
(assoc 1 ent)
ent
)
)
)
(entmod ent)
)
)
)
(princ "<Exit>")
(setvar "QAFLAGS" 0)
(princ)
)
Thảo luận gốc
Lisp được chia sẻ trong chủ đề LISP cộng têxt toàn bộ bản vẽ thêm 1 hằng sô. Xem đúng bài viết #198615 để đọc hướng dẫn và trao đổi thêm.