|
本帖最后由 zhb236623 于 2011-9-28 21:44 编辑
- (defun c:mj () ;;;mjtd.com
- (VL-LOAD-COM)
- (princ "\n ****本程序为求多个封闭物体的面积之和****")
- (princ "\n 请选择封闭物体(圆、多边形)....")
- (setq ss (ssget '((0 . "CIRCLE,LWPOLYLINE"))))
- (setq i 0
- ES 0
- )
- (repeat (sslength ss)
- (setq ent (ssname ss i))
- (setq obj (vlax-ename->vla-object ent))
- (setq s (vla-get-Area obj))
- (setq es (+ es s))
- (setq i (1+ i))
- )
- (princ (strcat "总面积为:" (rtos es)))
- (princ)
- )
复制代码 好用的话再发一个可以统计层面积的,基于CASS使用。这个在画房子的时候要先标注房屋层数才能使用。
“居民地—— ‘一般房屋 —— 多点砖房屋 ” 最后提示输入层数 类似这样子画出来的房子才能统计房屋面积。。- (defun c:cmj ()
- (VL-LOAD-COM)
- (princ "\n ****本程序为求多个封闭物体的面积之和****")
- (princ "\n 请选择封闭物体(圆、多边形)....")
- ;;(ssget '((0 . "TEXT")(8 . "JZP")))
- (setq ss (ssget '((0 . "CIRCLE,LWPOLYLINE")(8 . "JMD"))))
- (setq i 0
- ES 0
- )
- (repeat (sslength ss)
- (setq ent (ssname ss i))
- (setq obj (vlax-ename->vla-object ent))
- (setq s (vla-get-Area obj))
-
- (setq appname "south")
- (regapp (setq rname appname))
- (setq xxdata (entget ent (list rname)))
- (setq south_sx1 (cdr (assoc -3 xxdata))) ;;提取-3的后表
- (setq house_cen (cdr (assoc 1040 (cdr (car south_sx1))))) ;;获取楼房层数
- (setq single_area ( * s house_cen ))
-
- (setq es (+ es single_area))
- (setq i (1+ i))
- )
- (princ (strcat "总面积(单间单层面积*层数)为:" (rtos es)))
- (princ)
- )
复制代码 以下程序为统计每套房间面积,层数,单幢总面积的程序。最后只要把文件文件改为 aa.txt->aa.csv 直接改后缀名就可以看到结果。。。。- (defun c:cmj ()
- (VL-LOAD-COM)
- (princ "\n ****本程序为求多个封闭物体的面积之和****")
- (princ "\n 请选择封闭物体(圆、多边形)....")
- (setq ffn (getfiled "选取文件" "D:/temp/" "txt" 1))
- (setq ff (open ffn "w"))
- (princ "单层面积,层数,整幢面积" ff)
- (princ "\n" ff)
- (close ff)
- ;;(ssget '((0 . "TEXT")(8 . "JZP")))
- (setq ss (ssget '((0 . "CIRCLE,LWPOLYLINE")(8 . "JMD"))))
- (setq i 0
- ES 0
- )
- (repeat (sslength ss)
- (setq ent (ssname ss i))
- (setq obj (vlax-ename->vla-object ent))
- (setq s (vla-get-Area obj))
-
- (setq appname "south")
- (regapp (setq rname appname))
- (setq xxdata (entget ent (list rname)))
- (setq south_sx1 (cdr (assoc -3 xxdata))) ;;提取-3的后表
- (setq house_cen (cdr (assoc 1040 (cdr (car south_sx1))))) ;;获取楼房层数
- (setq single_area ( * s house_cen ))
-
- (setq es (+ es single_area))
- (setq ff (open ffn "a"))
- (princ s ff)
- (princ "," ff)
- (princ house_cen ff)
- (princ "," ff)
- (princ single_area ff)
- (princ "\n" ff)
- (close ff)
- (setq i (1+ i))
- )
- (princ (strcat "总面积(单间单层面积*层数)为:" (rtos es)))
- (princ)
- )
复制代码 |
|