明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 935|回复: 7

[讨论] 分享一个统计房屋面积的程序,也看有没高手出手优化!

[复制链接]
发表于 2015-7-24 08:45 | 显示全部楼层 |阅读模式
本帖最后由 spp_wall 于 2015-7-24 08:55 编辑

现在程序 是预设图层  然后点选不同层数的建筑面积  通过图层来计算出不同层建筑的1层面积  最后进行层数计算!

看有没可能有批量的办法  不需点选  改成框选  然后自己识别每层建筑的面积(一般建筑都是闭合多段线 里面有文字 比如 砼、砼2这样的分类) 是否能通过识别文字外的闭合多断线来统计面积   然后汇总!

(defun bz()
  (setvar "cmdecho" 0)
  (setq pt (getpoint "\n选取点:"))
  (while pt
    (command "bpoly" pt "")
    (setq en (entlast))
    (if (/= en nil)
      (progn
        (command "area" "o" en)
        (setq aa (getvar "area"))
        (redraw en 3)
        (command "text" "s" "standard" pt  "1" "0" (rtos aa 2 2)))
      )
    (entdel en)
    (setq pt (getpoint "\n选取点:"))
    )
  (prin1)
  )

(defun tc()
  (sub_chk_layer)
   (prin1)
  )
(defun sub_chk_layer ()
(setq chklay (tblsearch "layer" "Z"))
  (if (null chklay)(command "layer" "n" "Z" "c" "4" "Z" ""))
    (setq chklay (tblsearch "layer" "Z2"))
  (if (null chklay)(command "layer" "n" "Z2" "c" "4" "Z2" ""))
  (setq chklay (tblsearch "layer" "Z3"))
  (if (null chklay)(command "layer" "n" "Z3" "c" "4" "Z3" ""))
(setq chklay (tblsearch "layer" "Z4"))
  (if (null chklay)(command "layer" "n" "Z4" "c" "4" "Z4" ""))
(setq chklay (tblsearch "layer" "Z5"))
  (if (null chklay)(command "layer" "n" "Z5" "c" "4" "Z5" ""))
   (setq chklay (tblsearch "layer" "Z6"))
  (if (null chklay)(command "layer" "n" "Z6" "c" "4" "Z6" ""))

  (setq chklay (tblsearch "layer" "C"))
  (if (null chklay)(command "layer" "n" "C" "c" "4" "C" ""))
    (setq chklay (tblsearch "layer" "C2"))
  (if (null chklay)(command "layer" "n" "C2" "c" "4" "C2" ""))
  (setq chklay (tblsearch "layer" "C3"))
  (if (null chklay)(command "layer" "n" "C3" "c" "4" "C3" ""))
(setq chklay (tblsearch "layer" "C4"))
  (if (null chklay)(command "layer" "n" "C4" "c" "4" "C4" ""))
(setq chklay (tblsearch "layer" "C5"))
  (if (null chklay)(command "layer" "n" "C5" "c" "4" "C5" ""))
   (setq chklay (tblsearch "layer" "C6"))
  (if (null chklay)(command "layer" "n" "C6" "c" "4" "C6" ""))


  (setq chklay (tblsearch "layer" "B"))
  (if (null chklay)(command "layer" "n" "B" "c" "4" "B" ""))
    (setq chklay (tblsearch "layer" "B2"))
  (if (null chklay)(command "layer" "n" "B2" "c" "4" "B2" ""))
  (setq chklay (tblsearch "layer" "B3"))
  (if (null chklay)(command "layer" "n" "B3" "c" "4" "B3" ""))
   (setq chklay (tblsearch "layer" "B4"))
  (if (null chklay)(command "layer" "n" "B4" "c" "4" "B4" ""))
   (setq chklay (tblsearch "layer" "B5"))
  (if (null chklay)(command "layer" "n" "B5" "c" "4" "B5" ""))
  (setq chklay (tblsearch "layer" "B6"))
  (if (null chklay)(command "layer" "n" "B6" "c" "4" "B6" ""))
  (setq chklay (tblsearch "layer" "B7"))
  (if (null chklay)(command "layer" "n" "B7" "c" "4" "B7" ""))
  (setq chklay (tblsearch "layer" "B8"))
  (if (null chklay)(command "layer" "n" "B8" "c" "4" "B8" ""))
   (setq chklay (tblsearch "layer" "B9"))
  (if (null chklay)(command "layer" "n" "B9" "c" "4" "B9" ""))

   (setq chklay (tblsearch "layer" "T"))
  (if (null chklay)(command "layer" "n" "T" "c" "4" "T" ""))
    (setq chklay (tblsearch "layer" "T2"))
  (if (null chklay)(command "layer" "n" "T2" "c" "4" "T2" ""))
   (setq chklay (tblsearch "layer" "T3"))
  (if (null chklay)(command "layer" "n" "T3" "c" "4" "T3" ""))
   (setq chklay (tblsearch "layer" "T4"))
  (if (null chklay)(command "layer" "n" "T4" "c" "4" "T4" ""))
   (setq chklay (tblsearch "layer" "T5"))
  (if (null chklay)(command "layer" "n" "T5" "c" "4" "T5" ""))
   (setq chklay (tblsearch "layer" "T6"))
  (if (null chklay)(command "layer" "n" "T6" "c" "4" "T6" ""))
   (setq chklay (tblsearch "layer" "T7"))
  (if (null chklay)(command "layer" "n" "T7" "c" "4" "T7" ""))
    (setq chklay (tblsearch "layer" "T8"))
  (if (null chklay)(command "layer" "n" "T8" "c" "4" "T8" ""))
   (setq chklay (tblsearch "layer" "T9"))
  (if (null chklay)(command "layer" "n" "T9" "c" "4" "T9" ""))
   (setq chklay (tblsearch "layer" "T10"))
  (if (null chklay)(command "layer" "n" "T10" "c" "4" "T10" ""))

   (setq chklay (tblsearch "layer" "D"))
  (if (null chklay)(command "layer" "n" "D" "c" "4" "D" ""))
  (setq chklay (tblsearch "layer" "D2"))
  (if (null chklay)(command "layer" "n" "D2" "c" "4" "D2" ""))
   (setq chklay (tblsearch "layer" "厂房1"))
  (if (null chklay)(command "layer" "n" "厂房1" "c" "4" "厂房1" ""))
   (setq chklay (tblsearch "layer" "厂房2"))
  (if (null chklay)(command "layer" "n" "厂房2" "c" "4" "厂房2" ""))
   (setq chklay (tblsearch "layer" "建"))
  (if (null chklay)(command "layer" "n" "建" "c" "4" "建" ""))
  (setq chklay (tblsearch "layer" "简易"))
  (if (null chklay)(command "layer" "n" "简易" "c" "4" "简易" ""))
  (setq chklay (tblsearch "layer" "砖房"))
  (if (null chklay)(command "layer" "n" "砖房" "c" "4" "砖房" ""))
(setq chklay (tblsearch "layer" "砖房2"))
  (if (null chklay)(command "layer" "n" "砖房2" "c" "4" "砖房2" ""))
)

(defun out ()
  (setvar "cmdecho" 0)
  (setq all 0)
  (setq ss (ssget "x" (list '(0 . "text,mtext") (cons 8  lay))))
  (setq        n 0 k 0)
  (if (/= ss nil)
    (progn
      (repeat (sslength ss)
        (setq en (ssname ss n))
        (setq en_data (entget  en))
        (setq aa (atof (cdr (assoc 1 en_data))))
        (mjljaa)
        (setq n (1+ n))
        )
      )
    (setq k 0 all 0)
    )
  (if (or (/= k 0) (/= all 0))
    (progn
      (if (or (= lay "T")(= lay "B") (= lay "C") (= lay "D")(= lay "建")(= lay "简易")(= lay "Z"))
        (alert (strcat lay "\房共有<"(itoa k)">栋房子参与了统计,建筑面积为:"(rtos all 2 2)"平方米"))
        (alert (strcat lay "\房共有<"(itoa k)">栋房子参与了统计,建筑面积为:"(rtos (* all (atoi (substr lay 2 2))) 2 2)"平方米"))
        )
    )
    )
  )

(defun mjljaa ()
  (setq all (+ all aa))
  (setq k (1+ k))
  )
(prompt"\n统计房屋面积<mj>")
(prin1)

(defun tj()
  (setq lay "T")
  (out)
  (setq lay "T2")
  (out)
  (setq lay "T3")
  (out)
  (setq lay "T4")
  (out)
  (setq lay "T5")
  (out)
  (setq lay "T6")
  (out)
  (setq lay "T7")
  (out)
  (setq lay "T8")
  (out)
  (setq lay "T0")
  (out)
  (setq lay "T10")

  (out)
  (setq lay "B")
  (out)
  (setq lay "B2")
  (out)
  (setq lay "B3")
  (out)
  (setq lay "B4")
  (out)
  (setq lay "B5")
  (out)
  (setq lay "B6")
  (out)
  (setq lay "B7")
  (out)
  (setq lay "B8")
  (out)
  (setq lay "B9")
  (out)
  (setq lay "C")
  (out)
  (setq lay "C2")
  (out)
  (setq lay "C3")
  (out)
  (setq lay "C4")
  (out)
  (setq lay "C5")
  (out)
  (setq lay "Z")
  (out)
  (setq lay "Z2")
  (out)
  (setq lay "Z3")
  (out)
  (setq lay "Z4")
  (out)
  (setq lay "Z5")
  (out)
  (setq lay "Z6")
  (out)
  (setq lay "建")
  (out)
  (setq lay "简易")
  (out)


  )
(defun c:tjcq()
(PRINC "\n第一步:输入TC,有没有发现图层里面多了很多图层
第二步:先选择图层,A2房,就先选择A2层,输入BZ,在A2房内任处位置点击鼠标左键,如果数字标不出来,说明没有闭合。
第三步:输入TJ,根据图层来统计不同层数的建筑面积,注意是建筑面积,(一层占地X1,二层占地x2,类推)\n(其中C:厂房 T:砼 Z:砖 B其他)原作者:lxh410224 \n")


  (initget " tc bz tj")
  (setq mingl (getkword "预设图层(tc),标注面积(bz),统计面积(tj):"))
  (cond ((= mingl "tc") (tc))
        ((= mingl "bz") (bz))
        ((= mingl "tj") (tj))
        )
  )

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2015-7-24 09:46 | 显示全部楼层
那么多图层,不嫌乱呀?为什么不用拓展数据保存建筑层数呢?

发表于 2015-7-24 10:02 | 显示全部楼层
类似这样?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
 楼主| 发表于 2015-7-24 10:52 | 显示全部楼层
本帖最后由 spp_wall 于 2015-7-24 10:58 编辑
fan_zh 发表于 2015-7-24 10:02
类似这样?

是的!!!  能否共享下!  有源码最好了  因为房屋的类型还有其他!
 楼主| 发表于 2015-7-24 10:52 | 显示全部楼层
本帖最后由 spp_wall 于 2015-7-24 10:56 编辑
77077 发表于 2015-7-24 09:46
那么多图层,不嫌乱呀?为什么不用拓展数据保存建筑层数呢?
图层其实也没那么多  只是写了比较多  防止不够

这些数据 应该是测量软件 CASS生成的  我是设计的  一般不怎么用CASS
发表于 2015-7-24 11:48 | 显示全部楼层

试着自己写写吧,提示,

1.选择多边形
2.获得多边形坐标点(有现成函数的)
3.利用坐标点生成选择集
4.获得选择集中的文字内容
5.循环
 楼主| 发表于 2015-7-25 00:36 来自手机 | 显示全部楼层
fan_zh 发表于 2015-7-24 11:48
试着自己写写吧,提示,

1.选择多边形

太深了,而且自己很久没接触了,lisp基本都忘记了
发表于 2015-7-27 09:55 | 显示全部楼层
fan_zh 发表于 2015-7-24 10:02
类似这样?

看起来不错!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-4-20 23:15 , Processed in 0.327513 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表