本帖最后由 hlmdf 于 2012-4-16 11:56 编辑
不是很完整,用着先吧……
统计面积、对象个数:
- (defun c:TA(/ ss tarea obj k l)
- (setvar "cmdecho" 0)
- (if (setq ss (ssget))
- (progn
- (vl-load-com)
- (setq l (sslength ss) k 0 tarea 0 )
- (repeat l
- (setq ename (ssname ss k))
- (setq obj (vlax-ename->vla-object ename))
- (if (vlax-property-available-p obj "area")
- (setq tarea (+ (vlax-get-property obj 'area) tarea))
- )
- (setq k (1+ k))
- )
- (setq tarea (/ tarea 1000000))
- (princ (strcat "\n共选择 " (itoa l) " 个对象 | 总面积: " (rtos tarea 2 3)))
- )
- (princ "\n未选择对象")
- )
- (setvar "cmdecho" 1)
- (prin1)
- )
统计线段长度、数量:
- (defun c:TG(/ ss tlen obj k l)
- (setvar "cmdecho" 0)
- (if (setq ss (ssget))
- (progn
- (vl-load-com)
- (setq l (sslength ss) k 0 tlen 0 )
- (repeat l
- (setq ename (ssname ss k))
- (setq obj (vlax-ename->vla-object ename))
- (if (= (cdr (assoc 0 (entget ename))) "MLINE")
- (setq tlen (+ tlen (ml-length ename)))
- (setq tlen (+ tlen (vlax-curve-getdistatparam ename (vlax-curve-getendparam ename))))
- )
- (setq k (1+ k))
- )
- (princ (strcat "\n共选择 " (itoa l) " 个对象 | 总长度: " (rtos tlen 2 0)))
- )
- (princ "\n未选择对象")
- )
- (setvar "cmdecho" 1)
- (prin1)
- )
|