CAD标注统计插件
(defun c:bzcdqh()(setq cmd (getvar "cmdecho"))
(setvar "cmdecho" 0)
(if (progn
(princ "\n请选取标注:")
(setq ssa (ssget '((0 . "DIMENSION") )))
)
(progn
(setq cdz 0)
(setq i 0)
(setq n (sslength ssa))
(repeat n
(setq dxf (entget (ssname ssa i)))
(setq cdz (+ cdz (cdr (assoc 42 dxf))))
(setq i (1+ i))
)
(alert (strcat "共选取了" (itoa n) "个标注,总长度=" (rtos cdz 2 3)))
(princ (strcat "\n共选取了" (itoa n) "个标注,总长度=" (rtos cdz 2 3)))
)
)
(setvar "cmdecho" cmd)
(princ)
)
不过这个插件有个缺陷,只能获取标注的“测量单位”数据,不能获取“文字替代”的数据
不知高手帮忙修改一下,当获取“文字替代”的数据为空时,再获取“测量单位”数据,然后再求和,那就棒了。 试试,多谢分享了, 望继续改进,赞一个 本帖最后由 烟花丝雨 于 2024-1-25 11:26 编辑
(defun c:bzcdqh()
(setq cmd (getvar "cmdecho"))
(setvar "cmdecho" 0)
(if (progn
(princ "\n请选取标注:")
(setq ssa (ssget '((0 . "DIMENSION") )))
)
(progn
(setq cdz 0)
(setq i 0)
(setq n (sslength ssa))
(repeat n
(setq dxf (entget (ssname ssa i)))
(if (= (cdr (assoc 1 dxf)) "")
(setq cdz (+ cdz (cdr (assoc 42 dxf))))
(setq cdz (+ cdz (atof (cdr (assoc 1 dxf)))))
)
(setq i (1+ i))
)
(alert (strcat "共选取了" (itoa n) "个标注,总长度=" (rtos cdz 2 3)))
(princ (strcat "\n共选取了" (itoa n) "个标注,总长度=" (rtos cdz 2 3)))
)
)
(setvar "cmdecho" cmd)
(princ)
)
感谢分享:handshake 语法错误 ,用不了版主 好东西值得拥有 感谢楼主分享 烟花丝雨 发表于 2024-1-25 11:20
谢谢您的帮助,:handshake
页:
[1]