悬赏高手写个统计周长面积输出excel。
本帖最后由 xiaodao520 于 2012-7-3 10:03 编辑要求批量框选封闭图形周长面积输出excel中,并同时在图形中按编号顺序标出周长面积。
本帖最后由 langjs 于 2012-7-3 21:05 编辑
既然发消息给我那就编一个。使用时不保证100%正确。
;;; 框选封闭区域面积到excel by:langjs
;;; ==================
(defun c:qq (/ d ent f i lst m2 obj pt ss txt x y)
(defun maketext (txt pt) ; 生成文字子函数
(entmake (list '(0 . "TEXT") (cons 62 1) (cons 10 pt) (cons 40 10) (cons 1 txt) '(41 . 0.8)))
)
(setvar "cmdecho" 0)
(vl-load-com)
(setq ss (ssget) ent (entlast))
(command ".region" ss "")
(setq ss (ssadd)lst nil)
(while (setq ent (entnext ent))
(if (= (cdr (assoc 0 (entget ent))) "REGION")
(setq obj (vlax-ename->vla-object ent) pt (vlax-safearray->list (vlax-variant-value (vla-get-centroid obj)))
m2 (rtos (vla-get-area obj) 2 2) d (rtos (vla-get-perimeter obj) 2 2) lst (cons (list pt m2 d) lst)
)
)
)
(command ".undo" "")
(setq lst (vl-sort lst (function (lambda (x y)(< (car (car x)) (car (car y)))))))
(setq lst (vl-sort lst (function (lambda (x y)(> (cadr (car x)) (cadr (car y)))))))
(setq f (getfiled "指定输出文件路径" "" "xls" 1) f (open f "w"))
(write-line "编号\t周长(mm)\t面积(mm2)" f)
(setq i 1)
(foreach x lst
(setq pt (car x) m2 (cadr x) d (caddr x))
(maketext (strcat "A" (itoa i)) (list (car pt) (+ (cadr pt) 20)))
(maketext (strcat "L=" d "mm") pt)
(maketext (strcat "S=" m2 "mm2") (list (car pt) (- (cadr pt) 14)))
(write-line (strcat (strcat "A" (itoa i)) "\t" d "\t" m2) f)
(setq i (1+ i))
)
(close f)
(princ)
)
)
...图形中按编号顺序...
实务上就这么单纯?
若否则需更充分的示例,关系到排序演算...
Andyhon 发表于 2012-7-3 10:40 static/image/common/back.gif
...图形中按编号顺序...
实务上就这么单纯?
若否则需更充分的示例,关系到排序演算...
意思是给每个封闭图形编号并标注周长面积 好像有人整 过这个东西,是面积输出到excel。http://bbs.mjtd.com/forum.php?mod=viewthread&tid=92023 这样可以一步到位,期待! 期待高手一步到位。 xiaodao520 发表于 2012-7-3 10:45 static/image/common/back.gif
意思是给每个封闭图形编号并标注周长面积
自动,框选后能自动标注,并输出。 最好加上线段的长度功能 帮你顶顶哈~~~