xiaxiang
发表于 2012-7-3 14:23:40
1.过滤选中实体
2.判断实体是否封闭,若是则列表
3.实体按照形心坐标,将列表重排序
4.求出周长面积列表,逐一写到形心,并逐一按行入表
5.完成
可逐一完成,当做程序写作练习
xiaodao520
发表于 2012-7-3 14:26:22
本帖最后由 xiaodao520 于 2012-7-3 14:26 编辑
xiaxiang 发表于 2012-7-3 14:23 http://bbs.mjtd.com/static/image/common/back.gif
1.过滤选中实体
2.判断实体是否封闭,若是则列表
3.实体按照形心坐标,将列表重排序
不会写,要是会写也就不用悬赏了。
lpl
发表于 2012-7-3 16:11:37
打酱油路过,
革天明
发表于 2012-7-3 17:07:42
表示有难度
xiaodao520
发表于 2012-7-3 18:28:48
对大师级的高手,估计是小KS
flytoday
发表于 2012-7-3 21:55:52
哥给加个标注字高设置吧
xiaodao520
发表于 2012-7-3 23:27:56
langs哥,帮帮flytoday加个标注字高设置,我代表他和我谢谢你了,
flytoday
发表于 2012-7-3 23:33:42
大师如果还能增加个有缺口也能计算面积就非常好
hao3ren
发表于 2012-7-4 00:01:02
;;; 框选封闭区域面积到excel by:langjs
;;; ==================
(defun c:qq (/ d ent f i lst m2 obj pt ss txt x y)
(setq TextHeight (getdist "\n输入标注文字高度:"))
(defun maketext (txt pt) ; 生成文字子函数
(entmake (list '(0 . "TEXT") (cons 62 1) (cons 10 pt) (cons 40 TextHeight) (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)
)
)
xiaodao520
发表于 2012-7-4 00:16:03
hao3ren 发表于 2012-7-4 00:01 static/image/common/back.gif
;;; 框选封闭区域面积到excel by:langjs
;;; ==================
(defun c:qq (/ d ...
不错,增加了文字高度设置,只是文字行距需要调整下,否则字体设置大的时候,容易重叠在一块,大师在改改。