明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 5231|回复: 19

快速统计圆孔数量

[复制链接]
发表于 2021-6-17 22:42:56 | 显示全部楼层 |阅读模式
本帖最后由 流氓兔 于 2021-6-17 22:55 编辑

快速统计圆孔数量,2种表达方式,模拟划线成表!

本帖子中包含更多资源

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

x
发表于 2021-6-18 08:28:19 | 显示全部楼层
错误: 输入的字符串有缺陷   兄弟有错误
回复 支持 1 反对 0

使用道具 举报

发表于 2022-5-12 17:42:22 | 显示全部楼层
bobodod 发表于 2022-5-12 17:20
确实用不了  白花了

论坛不是有不要币就可以下载的源码么,一样的功能,搜索一下就找到了
回复 支持 0 反对 1

使用道具 举报

发表于 2024-12-31 17:19:50 | 显示全部楼层
咏郡 发表于 2024-7-31 21:07
根据楼主的码改编的
不知道这种做法是否妥当,不收币吧楼主的码,收币吧楼主没得到
如真的不妥当请告 ...

大佬知道这是什么原因吗,求答复!
  1. (defun c:d8(/ all all1 ce cn cp cr cs ct h height hx leng_row leng_title li lii lst om os pp_int pp_txt pt px py sc si size ss tb_diamer tb_nno tb_type tx tx1 u width color_table)
  2.   (setq color_table ())
  3.   (princ "\n选择要进行统计的圆对象")
  4.   (setq ss (ssget (list (cons 0 "CIRCLE"))))
  5.   (setq pt (getpoint "\n选择输出基点:"))
  6.   (setq pp_int pt)
  7.   (setq si 0 tx 65 px (car pt) py (cadr pt) li '() lii 1)
  8.   (setq os (getvar "osmode") om (getvar "cmdecho"))
  9.   (command "osmode" 0 "osmode" 0 "_.ucs" "w")
  10.   (setq color_table (list))
  11.   (repeat (sslength ss)
  12.     (setq cs (ssname ss si) ce (entget cs));获取图元
  13.     (setq cp (cdr (assoc 10 ce)));获取坐标
  14.     (setq cr (cdr (assoc 40 ce)));半径
  15.     (if (setq lst (assoc cr li))
  16.       (setq ct (nth 1 lst) li (subst (list cr ct (1+ (nth 2 lst))) lst li))
  17.       (setq ct tx tx (1+ tx) li (cons (list cr ct 1) li));li =((5.26298 65 1)) 构建表 半径
  18.     )
  19.     (if (setq color_index_pair (assoc ct color_table))
  20.         (setq color_index (cdr color_index_pair))
  21.         ; 如果不存在,分配一个新的颜色索引,确保不超过颜色索引范围(这里假设最大为255),并添加到 color_table 关联表中
  22.         (progn
  23.             (setq color_index (if (< (length color_table) 255) (1+ (length color_table)) 1))
  24.             (setq color_table (append color_table (list (cons ct color_index))))
  25.         )
  26.     )
  27.     (setq dimtxt_height (getvar "DIMTXT"))
  28.     (setq dimscale_factor (getvar "DIMSCALE"))
  29.     (setq actual_text_height (* dimtxt_height dimscale_factor))   
  30.     (entmakex (list '(0 . "TEXT")'(100 . "AcDbEntity")
  31.                 (cons 62 color_index) '(100 . "AcDbText")
  32.                 (cons 10 (polar cp (/ pi 4) (+ cr 1)))
  33.                 (cons 40 actual_text_height)
  34.                 (cons 1 (chr ct))
  35.                 (cons 8 "DIM")
  36.                
  37.               ))
  38.    
  39.     (setq si (1+ si))
  40.     (setq color_index (if (< color_index 256) (1+ color_index) 1))
  41.   )  
  42.   
  43.   
  44.   (foreach l li
  45.     (setq cp (list px (+ py (* lii (+ actual_text_height 7)))) );text定位点
  46.     (setq cr (nth 0 l) ct (nth 1 l) cn (nth 2 l));CR直径 CT 65 A  66 B
  47.     (entmakex (list '(0 . "TEXT")'(100 . "AcDbEntity")
  48.                 (cons 62 3) '(100 . "AcDbText")
  49.                 (cons 8 "DIM")
  50.                 (cons 10 cp)
  51.                 (cons 40 actual_text_height)
  52.                 (cons 1 (strcat (chr ct) ":" (itoa cn) "-%%C" (rtos (* cr 2) 2 2)))
  53.                 '(50 . 0.0)
  54.                 (cons 41 0.7)
  55.                 '(51 . 0.0)
  56.                 '(71 . 0)
  57.                 '(72 . 0)
  58.                 (cons 11 cp)
  59.                 '(100 . "AcDbText")
  60.                 '(73 . 0)))
  61.     (setq lii (1+ lii))
  62.    
  63.   )
  64.   
  65.   
  66.   
  67.   
  68.   (setq height 4.)
  69.   (setq width 12.)
  70.   (setq size 3.)
  71.   (setq sc 0.5)
  72.   (setq tx1  (vl-list->string(list tx)))   
  73.   (setq  hx (- (car(vl-string->list tx1)) 65))
  74.   
  75.   (setq h hx)
  76.   (setq leng_title 1  leng_row h)
  77.    (by-row-down-line pp_int (* width (+ leng_title 3)) height (+ 2 leng_row) 3 0)
  78.   (by-colu-right-line pp_int (* height (+ 1 leng_row)) width (+ leng_title 4) 3 0)
  79.   (by-x-txt-rep '("标记" "数量" "孔径" "备注") pp_int width height 1 size sc)
  80.   
  81.   
  82.   
  83.   
  84.   
  85.   
  86.   (setq u 0)
  87.   (foreach l li
  88.     (setq u (1+ u))
  89.     (setq pp_txt (list (car pp_int) (- (cadr pp_int) (* height u))))
  90.     (setq tb_type (nth 1 l))
  91.    
  92.     (setq tx1  (vl-list->string(list tx)))
  93.    
  94.     (setq tb_NnO (nth 2 l))
  95.     (setq tb_diamer (nth 0 l))
  96.     (setq all (list (chr tb_type) (itoa tb_NnO)  (strcat "%%C"(rtos (* tb_diamer 2) 2 2))))
  97.     (setq all1 (append all))
  98.    
  99.     (by-x-txt-rep all (list (car pp_int) (cadr pp_txt)) width height 7 size sc)  
  100.   )
  101.   
  102.   
  103.   
  104.   
  105.   
  106.   (setvar "osmode" os)
  107.   (setvar "cmdecho" om)
  108.   (princ "\n统计完成!")
  109.   (princ)
  110. )

  111. ;横向文字循环排列
  112. (defun by-x-txt-rep(lst pp wid hei col size sc / hei_now i num pp_txt pp_x pp_y txt wid_now)
  113.   (setq num (length lst))
  114.   (setq i -1)
  115.   (repeat num
  116.     (setq i (1+ i))
  117.     (setq txt (nth i lst))
  118.     (setq wid_now (* (+ 0.5 i) wid))
  119.     (setq pp_x (+ (car pp) wid_now))
  120.     (setq pp_y (- (cadr pp) (* 0.5 hei)))
  121.     (setq pp_txt (list pp_x pp_y))
  122.     (if(and(/= txt "")(/= txt " "))
  123.       (entmakex (list '(0 . "TEXT")'(100 . "AcDbEntity")(cons 62 3) '(100 . "AcDbText") (cons 8 "DIM") (cons 10 pp_txt) (cons 40 size) (cons 1 txt) '(50 . 0.0) (cons 41 sc) '(51 . 0.0)'(71 . 0) '(72 . 4) (cons 11 pp_txt)'(100 . "AcDbText") '(73 . 0)))
  124.     )
  125.    
  126.   )
  127. )


  128. ;循环画竖线
  129. (defun by-colu-right-line(pp height colu num col wid / i pp_bottom pp_left pp_right pp_top x y)
  130.   (setq pp (list (+ (car pp) wid) (cadr pp)))
  131.   (setq i -1)
  132.   (repeat num
  133.     (setq i (1+ i))
  134.     (setq x (+ (car pp) (* i colu)))
  135.     (setq pp_top (list x (cadr pp)))
  136.     (setq pp_bottom (list x (- (cadr pp) height)))
  137.     (entmakex (list '(0 . "LINE") '(100 . "AcDbEntity")(cons 62 3) '(100 . "AcDbLine") (cons 8 "DIM") (cons 10 pp_top) (cons 11 pp_bottom)))
  138.   )
  139. )



  140. ;循环画横线
  141. (defun by-row-down-line(pp width row num col hei / i pp_left pp_right y)
  142.   (setq pp (list (car pp) (- (cadr pp) hei)))
  143.   (setq i -1)
  144.   (repeat num
  145.     (setq i (1+ i))
  146.     (setq y (- (cadr pp) (* i row) ))
  147.     (setq pp_left (list (car pp) y))
  148.     (setq pp_right (list (+ width (car pp)) y))
  149.     (entmakex (list '(0 . "LINE") '(100 . "AcDbEntity")(cons 62 3) '(100 . "AcDbLine") (cons 8 "DIM") (cons 10 pp_left) (cons 11 pp_right)))
  150.   )
  151. )   我自己调整了一下,但是用原有的也会报错

本帖子中包含更多资源

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

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-6-18 12:11:14 来自手机 | 显示全部楼层
664571221 发表于 2021-6-18 08:28
错误: 输入的字符串有缺陷   兄弟有错误

哪个有问题,我修改一下
发表于 2021-6-18 12:51:53 | 显示全部楼层
谢谢! 流氓兔 分享程序!!!!
发表于 2021-6-29 08:47:04 | 显示全部楼层
没有币啊,唉
发表于 2021-7-2 13:45:11 | 显示全部楼层
两个LSP全是缺陷,不可用
 楼主| 发表于 2021-7-3 23:04:36 | 显示全部楼层
追寻 发表于 2021-7-2 13:45
两个LSP全是缺陷,不可用

cad 2008没有问题哦,哪里有问题,提出来
发表于 2022-4-16 11:56:25 | 显示全部楼层
你这个要是字母后面能加个编号,那就完美了。
 楼主| 发表于 2022-4-16 21:05:15 | 显示全部楼层
刚开始 发表于 2022-4-16 11:56
你这个要是字母后面能加个编号,那就完美了。

都是源码了,自己加个
发表于 2022-4-24 09:29:20 | 显示全部楼层
正需要  如果加个  读取固定值孔 的压铆底孔注明是  压铆标准件规格就好了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-2-22 16:46 , Processed in 0.214343 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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