ghdhair100
Chief Gray
Joined: 15 Dec 2010
Posts: 2020
Read: 0 topics
Warns: 0/5 Location: England
|
Posted: Thu 11:37, 03 Mar 2011 Post subject: CAD统计长度 |
|
|
;;;===================
;;;面积和长度统计程序
;;;highflybird kunming
;;;===================
(prompt "命令为:AM")
(defun C:am (/ f ss l i SSarea totlen entlen
ename name obj text-S text-L insPt0 height
insPt1 insPt2 text-1 text-2 *APP *DOC *MSP
)
(vl-load-com)
(setq *APP (vlax-get-acad-object))
(setq *DOC (vla-get-activeDocument *APP))
(setq *MSP (vla-get-Modelspace *DOC))
(initget 1 "1 2 3")
(setq f (getkword "\n请输入你要统计的<1>面积<2>长度<3>两者:"))
(if
(and
(setq ss (ssget))
(setq insPt0 (getpoint "\n请输入文字插入点: "))
(setq height (getdist "\n请输入文字高度:"))
)
(progn
(setq l (sslength ss))
(setq i 0)
(setq SSarea 0)
(setq totlen 0)
(setq insPt1 (vlax-3d-point insPt0))
(setq insPt2 (polar insPt0 (* 1.5 Pi) (* 1.5 height)))
(setq insPt2 (vlax-3d-point insPt2))
(cond
( (= f "1")
(repeat l
(func-1)
(func-2)
(setq i (1+ i))
)
(setq text-S (strcat (convert1 SSarea 6) "平方米"));总面积为:小数后6位
(vla-addtext *MSP text-S insPt1 height)
)
( (= f "2")
(repeat l
(func-1)
(func-3)
(setq i (1+ i))
)
(setq text-L (strcat (convert1 totlen 3) "米")) ;总长度为:小数后3位
(vla-addtext *MSP text-L insPt2 height)
)
( (= f "3")
(repeat l
(func-1)
(func-2)
(func-3)
(setq i (1+ i))
)
(setq text-S (strcat (convert1 SSarea 6) "平方米"));总面积为:小数后6位
(setq text-L (strcat (convert1 totlen 3) "米")) ;总长度为:小数后3位
(vla-addtext *MSP text-S insPt1 height)
(vla-addtext *MSP text-L insPt2 height)
)
)
)
(alert "你没有选取物体或者输入正确的数据!")
)
(princ)
)
(defun func-1 ()
(setq ename (ssname ss i))
(setq obj (vlax-ename->vla-object ename))
(setq elist (entget ename))
(setq name (cdr (assoc 0 elist)))
)Many years ago there lived an Emperor who was so exceedingly fond of fine new clothes that he spent vast sums of money on dress. To him clothes meant more than anything else in the world. He took no interes
related links:
[link widoczny dla zalogowanych]
The post has been approved 0 times
|
|