[分享]數字加减的lsp
<P></P><P>ta.lsp 可把text文字裹的数目字加起来</P>
<P>td.lsp 把text文字的数目字减起来</P>
<P>例如: 21 +12 = 33</P>
<P>只要选取文字21及12,再选取任可的一个文字,它就可以便成答案33了.</P>
<P>如此类推.</P>
<P>请给我回覆O</P> O 大哥!咋是乱码呀? <P>老兄!你的TA.LSP咋解不了密呀?</P> (defun c:td (/ #1 #2 #3 #4 #5 #6 e)
(prompt "\nSelect the text to total area:")
(setq #1 (ssget))
(setq #2 (getstring T "\nType character in front of the number: "))
(if (= #2 "") (setq #2 " "))
(setq #2a (strlen #2))
(setq _total 0 con 0)
(IF #1
(repeat (sslength #1)
(setq #3(entget (ssname #1 con)))
(if (= (cdr (assoc 0 #3)) "TEXT")
(PROGN
(setq #4 (cdr (assoc 1 #3)))
(setq #4(substr #4 #2a))
(setq _total (+ _total (atof #4)))
(setq con (1+ con))
)
)
)
)
(prompt "\nSelect the text of deduct area:")
(setq #1 (ssget))
(setq #2a (strlen #2))
(setq _total1 0 con 0)
(IF #1
(repeat (sslength #1)
(setq #3(entget (ssname #1 con)))
(if (= (cdr (assoc 0 #3)) "TEXT")
(PROGN
(setq #4(cdr (assoc 1 #3)))
(setq #4(substr #4 #2a))
(setq _total1 (+ _total1 (atof #4)))
(setq con (1+ con))
)
)
)
)
(setq _total2 (- _total _total1))
(setvar "cmdecho" 0)
(setq #5 (CAR (ENTSEL "\nSelect a text change to total area:")))
(setq #6 (entget #5))
(setq #e (subst (cons 1 (strcat #2 (strcat (rtos _total2 2 3) " " "m")))
(assoc 1 #6) #6))
(princ (substr (cdr (assoc 1 #e)) #2a))
(entmod #e)
(princ)
(setq sqp (cdr (assoc 10 #e)))
(setq sqlen (strlen (cdr (assoc 1 #e))))
(setq sqth (cdr (assoc 40 #e)))
(setq sqp1 (polar sqp (dtr 0) (* (- sqlen 1.75) sqth)))
(setq sqp2 (polar sqp1 (dtr 90) (/ sqth 1.025)))
(setq sqth1 (/ sqth 1.200))
(command "text" sqp2 sqth1 "0" "2")
(princ))
;(defun c:td () (c:tot-d))
;(princ
;"\n\tC:TOT-d loaded.Start command with TD or TOT-D.")
;(princ)
(defun DTR (a)
(* pi (/ a 180.00)))
(defun c:ta ()
(setq #oldla (getvar "clayer"))
(prompt "\nSelect the text to total area:")
(setq #1 (ssget))
(setq #2 (getstring T "\nType character in front of the number: "))
(if (= #2 "") (setq #2 "1"))
(setq #2a (strlen #2))
(setq _total 0 con 0)
(IF #1
(repeat (sslength #1)
(setq #3(entget (ssname #1 con)))
(if (= (cdr (assoc 0 #3)) "TEXT")
(PROGN
(setq #3a (strlen (cdr (assoc 1 #3))))
(setq #3b (+ (- #3a #2a) 1))
(setq #4(cdr (assoc 1 #3)))
(setq #4(substr #4 #2a #3b))
(setq _total(+ _total (atof #4)))
(setq con (1+ con))
)
)
)
)
(setvar "cmdecho" 0)
(setq #5 (CAR (ENTSEL "\nSelect a text change to total area:")))
(setq #6 (entget #5))
(if (= #2 "1")
(progn
(setq #e (subst (cons 1 (strcat (rtos _total 2 3) "m"))
(assoc 1 #6) #6))
)
)
(if (> #2a 1)
(progn
(setq #e (subst (cons 1 (strcat #2 (strcat (rtos _total 2 3)" " "m")))
(assoc 1 #6) #6))
)
)
(princ (substr (cdr (assoc 1 #e)) #2a))
(entmod #e)
(setq sqp (cdr (assoc 10 #e)))
(setq sqlen (strlen (cdr (assoc 1 #e))))
(setq sqth (cdr (assoc 40 #e)))
(setq #la (cdr (assoc 8 #e)))
(setq sqp1 (polar sqp (dtr 0) (* (- sqlen 1.75) sqth)))
(setq sqp2 (polar sqp1 (dtr 90) (/ sqth 1.025)))
(setq sqth1 (/ sqth 1.200))
(command "layer" "s" #la "")
(command "text" sqp2 sqth1 "0" "2")
(command "layer" "s" #oldla "")
(princ))
<p>这种程序网上有好多呢</p><p>我现在就有一个这样的程序呢,也是从网上下载的</p><p></p> <font face="Verdana">谢谢楼上的分享,参考下,很感激</font> 謝謝樓上的分享,參考下,很感激
页:
[1]