 - ;; tt(数字求和)
- (defun c:tt ()
- (defun get-Attibutes (s1 / lst x)
- (mapcar '(lambda (x) (setq lst (cons (vla-Get-TextString x) lst)))
- (vlax-safearray->list
- (vlax-variant-value
- (vla-GetAttributes (vlax-ename->vla-object s1))
- )
- )
- )
- lst
- )
- (defun dxf (code s1) (cdr (assoc code (entget s1))))
- (princ "\n选择: ")
- (setq ss (ssget '((0 . "*TEXT,DIMENSION,ATTRIB,ATTDEF,INSERT"))))
- (setq i -1)
- (setq mm 0.0)
- (while (setq s1 (ssname ss (setq i (1+ i))))
- (setq et (DXF 0 s1))
- (cond ((member et '("TEXT" "MTEXT"))
- (setq mm (+ (atof (DXF 1 s1)) mm))
- )
- ((and (member et '("ATTRIB" "ATTRIB"))
- (setq tx (distof (DXF 2 s1)))
- )
- (setq mm (+ tx mm))
- )
- ((= et "DIMENSION")
- (setq tx (DXF 1 s1))
- (if (and (/= tx "") (/= tx "<>"))
- (setq tx (atof tx))
- )
- (if (or (= tx "") (= tx "<>"))
- (setq tx (DXF 42 s1))
- )
- (setq mm (+ tx mm))
- )
- ((and (= et "INSERT") (= (DXF 66 s1) 1))
- (setq lst (get-Attibutes s1)
- lst (vl-remove-if-not '(lambda (x) (distof x)) lst)
- tx (apply '+ (mapcar 'distof lst))
- )
- (setq mm (+ tx mm))
- )
- )
- )
- (princ "\n总和: ")
- (princ (rtos mm 2 3))
- (princ)
- )
|