- (defun c:Q (/ en i mj mjz obj pt ss sshat )
- (vl-load-com)
- (if (null $th)
- (setq $th (getdist "\n输入字高:"))
- )
- (setq
- ss (ssget '((0 . "CIRCLE,LWPOLYLINE")))
- i -1
- mjz 0
- sshat (ssadd)
- )
- (command "copy" ss "" "non" '(0 0) "non" '(0 0))
- (while (setq en (ssname ss (setq i (1+ i))))
- (setq obj (vlax-ename->vla-object en))
- (setq mj (vla-get-area obj))
- (setq mjz (+ mj mjz))
- (command "region" en "")
- (setq pt (vlax-safearray->list
- (vlax-variant-value
- (vla-get-centroid (vlax-ename->vla-object (entlast)))
- )
- )
- sshat (ssadd (entlast) sshat)
- )
- (entmake
- (list '(0 . "TEXT")
- (cons 1 (strcat "S=" (rtos (/ mj 1000000) 2 2) "m2"))
- (cons 10 pt)
- (cons 11 pt)
- (cons 40 $th)
- (cons 62 20)
- (cons 72 1)
- (cons 73 2)
- )
- )
- )
- (entmake
- (list '(0 . "TEXT")
- (cons 1 (strcat "总面积=" (rtos (/ mjz 1000000) 2 2) "m2"))
- (cons 10 (getpoint "\n选取总面积插入点:"))
- (cons 40 $th)
- (cons 62 20)
- )
- )
- (command "ERASE" sshat "")
- (princ)
- )
|