明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1020|回复: 3

[函数] 统计文本,划线查找。理论上可以实现任意dxf 组码的统计。

[复制链接]
发表于 2021-2-16 16:46 | 显示全部楼层 |阅读模式
本帖最后由 vitalgg 于 2021-7-13 19:29 编辑

下载: @lisp.fas

命令行方式可以实现任意 dxf 组码的统计。

通用函数 (@:stat-entity stat-item ssfilter)
stat-item: 统计项目(dxf 组码比如图层 为8 );
ssfilter: 选择集过滤

  1. ;; 要统计单行文本在不同图层的个数
  2. (@:stat-entity 8  '((0 . "TEXT"))) ;;要统计单行文本在不同图层的个数
  3. (@:stat-entity 7  '((0 . "TEXT"))) ;;要统计单行文本的不同文字样式的个数
  4. (@:stat-entity 8  '((0 . "LINE"))) ;;统计所选中的直线在每个图层下的个数
  5. (@:stat-entity 8  '((0 . "insert"))) ;;统计所选中的图块在每个图层下的个数
  6. (@:stat-entity 62  '((0 . "line"))) ;;统计所选中的直线的不同颜色的个数,随层的为 nil,因为随层图元的没有这个组码。








  1. (@:add-menu "统计" "图块名" "(@:stat-block-by-name)")
  2. (@:add-menu "统计" "属性" "(@:menu-stat-block-by-attribute)")
  3. (@:add-menu "统计" "单行文本" "(@:menu-stat-text)")
  4. (@:add-menu "统计" "--" "--")
  5. (@:add-menu "统计" "输出结果" "(stat:print)")
  6. (@:add-menu "统计" "绘制结果" "(stat:draw)")
  7. ;;(@:add-menu "统计" "块属性" "(@:stat-block-by-attribute)")
  8. (defun @:stat-block-by-name ()
  9.   "统计选中块的块名及数量。"
  10.   (setq @:tmp-stat-result
  11.   (stat:stat
  12.    (mapcar (function
  13.       (lambda (x)
  14.        (block:get-effectivename x)))
  15.      (ss:ss-to-entlist (ssget '((0 . "insert"))))))))

  16. (defun @:stat-block-by-attribute (attribute-name block-name)
  17.   "统计选中的指定块名中的某一属性的值及数量。"
  18.   (setq @:tmp-stat-result
  19.   (stat:stat
  20.    (mapcar (function
  21.       (lambda (x)
  22.        (if (= block-name (block:get-effectivename x))
  23.            (cdr (assoc attribute-name (block:get-attributes x)))
  24.            )))
  25.      (ss:ss-to-entlist (ssget '((0 . "insert"))))))))

  26. (defun @:menu-stat-block-by-attribute (/ blk-name attribute-name)
  27.   (setq blk-name (getstring "请输入要统计的块名称:"))
  28.   (setq attribute-name (getstring "请输入要分类统计的块属性的名称:"))
  29.   (@:stat-block-by-attribute attribute-name blk-name))
  30.   
  31. (defun @:stat-entity (stat-item ssfilter)
  32.   "stat-item: 统计项目(dxf 组码比如图层 为8 ); ssfilter 选择集过滤"
  33.   (setq @:tmp-stat-result
  34.   (stat:stat
  35.    (mapcar (function
  36.       (lambda (x)
  37.        (cdr (assoc stat-item (entget x)))))
  38.      (ss:ss-to-entlist (ssget ssfilter))))))

  39. (defun @:menu-stat-text (/ ssfilter)
  40.   (setq strfilter (getstring "请输入文本通配符(示例 GBZ* ?BZ* LL*): "))
  41.   (if (/= "" strfilter)
  42.       (setq ssfilter (list  '(0 . "TEXT") (cons 1  strfilter)))
  43.       (setq ssfilter (list  '(0 . "TEXT"))))
  44.   (setq @:tmp-stat-result
  45.   (stat:stat
  46.    (mapcar (function
  47.       (lambda (x)
  48.        (cdr (assoc 1 (entget x)))))
  49.      (ss:ss-to-entlist (ssget ssfilter))))))
视频演示:
http://atlisp.cn/package-info?name=vitalmath&edition=stable



评分

参与人数 1明经币 +1 收起 理由
1028695446 + 1

查看全部评分

"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2021-2-20 12:47 | 显示全部楼层
求老大分享
 楼主| 发表于 2021-2-20 13:45 | 显示全部楼层
本帖最后由 vitalgg 于 2021-2-20 14:25 编辑

到 http://atlisp.cn 这个网站下载安装。然后安装 两个包就可以用了。函数依赖较多,没法形成单一文件。做统计的那个是 唯她数学工具,划线那个功能是 @文本 。
视频演示:
http://atlisp.cn/package-info?name=vitalmath&edition=stable
发表于 2021-3-9 11:12 | 显示全部楼层
谢谢楼主的分享
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-3 13:15 , Processed in 0.202272 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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