乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 8|回复: 8

[编程交流] 从AutoCAD导出尺寸

[复制链接]

1

主题

2

帖子

1

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 15:53:34 | 显示全部楼层 |阅读模式
嘿,我是这个论坛的新手=)希望得到一些指导。
 
有没有办法将尺寸从autoCAD导出到txt文件 165337w2du2pk2frzlpb22.jpg
我需要的程序,以获得红色的维度,并在txt文件中列出他们。
 
请友善一点,请记住,我对LISP完全陌生,除此之外几乎没有编程技能,但思想开放,愿意学习=)
回复

使用道具 举报

76

主题

312

帖子

254

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
390
发表于 2022-7-5 16:02:31 | 显示全部楼层
你好,安培,
 
这会让你开始。。。
 
  1. (defun C:GetDimLengths ( / AllDimensions CheckDimension n dimlist dimcontent filename fil )        ; Define the command name, localize the variables.
  2. (setq AllDimensions (ssget "_X" (list (cons 0 "Dimension"))))                                        ; Sets AllDimensions as a selection set of all Dimensions the the drawing.
  3. (setq n 0)                                                                                        ; Set loop counter 0.
  4. (setq dimlist '())                                                                                ; Set dimensionslist cleared.
  5. (repeat (sslength AllDimensions)                                                        ; Repeat for all in selectionset AllDimensions
  6.         (setq CheckDimension (entget (ssname AllDimensions n)))                                ; Gets the entity
  7.         (setq dimcontent (cdr (assoc 42 CheckDimension)))                                ; Reads the measured distance
  8.         (setq dimlist (cons dimcontent dimlist))                                        ; Adds this distance to a totallist
  9.         (setq n (+ 1 n))                                                                ; Up the counter for next dimension
  10. )                                                                                        ; End repeat
  11. (if (setq filename (getfiled "\nFile Location..." "DimensionExport" "txt" 11))                ; Make a new textfile with default name
  12.         (progn                                                                                ; When created do this.
  13.                 (setq fil (open filename "w"))                                                ; Open the new file
  14.                 (foreach x dimlist                                                        ; For all dimensions in the totallist
  15.                         (princ (strcat (rtos x 2) "\n") fil)                                ; Print them in them in the textfile
  16.                 )                                                                        ; Close 'foreach'
  17.                 (close fil)                                                                ; Close filewriter
  18.                 (startapp "notepad" filename)                                                ; Open created file with notepad
  19.                 (graphscr)                                                                ; Return to screen
  20.         )                                                                                ; Close 'do this'
  21. )                                                                                        ; End if
  22. (princ)                                                                                                ; Silent exit
  23. )                                                                                                ; End function

 
-“红色”是如何控制的?ByLayer还是set in the properties?
-需要对列表进行排序吗?
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-5 16:11:59 | 显示全部楼层
抚摸之后,好好努力。
 
仅供参考,没有必要分配空列表“dimlist”,因为cons函数会处理这样的事情。
回复

使用道具 举报

1

主题

2

帖子

1

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 16:18:28 | 显示全部楼层
谢谢你的快速回复,很好的评论。
到目前为止,红色文本仅在属性中更改,但如果更容易从图层中提取值,我可以修改CAD文件=)
我明天会试试。
回复

使用道具 举报

76

主题

312

帖子

254

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
390
发表于 2022-7-5 16:30:31 | 显示全部楼层
更改:
  1. (setq AllDimensions (ssget "_X" (list (cons 0 "Dimension"))))                                        ; Sets AllDimensions as a selection set of all Dimensions the the drawing.

 
为此,选择所有标注,其中属性设置为红色。
  1. (setq AllDimensions (ssget "_X" (list (cons 0 "Dimension")(cons 62 1))))                                        ; Sets AllDimensions as a selection set of all Dimensions the the drawing.

 
 
或者,当层名称已知时,选择所有维度
  1. (setq AllDimensions (ssget "_X" (list (cons 0 "Dimension")(cons 8 "YOURLAYERNAMEHERE"))))                                        ; Sets AllDimensions as a selection set of all Dimensions the the drawing.
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 16:37:01 | 显示全部楼层
如果要拾取尺寸并获取其第二层方法
 
  1. (setq obj (vlax-ename->vla-object (car (entsel "\nPick Dimension"))))
  2. (setq lay (vla-get-layer obj))
  3. (setq AllDimensions (ssget "_X" (list (cons 0 "Dimension")(cons 8 lay))))

 
  1. (setq obj (entget (car (entsel "\nPick Dimension "))))
  2. (setq lay (cdr (assoc 8 obj)))
  3. (setq AllDimensions (ssget "_X" (list (cons 0 "Dimension")(cons 8 lay))))
回复

使用道具 举报

16

主题

73

帖子

57

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
80
发表于 2022-7-5 16:40:00 | 显示全部楼层
 
帮助我,案例按窗口选择多个维度。
非常感谢。
回复

使用道具 举报

76

主题

312

帖子

254

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
390
发表于 2022-7-5 16:51:27 | 显示全部楼层
将X更改为L
回复

使用道具 举报

16

主题

73

帖子

57

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
80
发表于 2022-7-5 16:59:53 | 显示全部楼层
亲爱的Aftertouch。
 
  1. (defun C:GetDimLengths ( / AllDimensions CheckDimension n dimlist dimcontent filename fil )        ; Define the command name, localize the variables.
  2. ;(setq AllDimensions (ssget "_X" (list (cons 0 "Dimension"))))                                        ; Sets AllDimensions as a selection set of all Dimensions the the drawing.
  3. (setq obj (vlax-ename->vla-object (car (entsel "\nPick Dimension"))))
  4. (setq lay (vla-get-layer obj))
  5. [color="red"][i](setq AllDimensions (ssget "_L" (list (cons 0 "Dimension")(cons 8 lay))))[/i]
  6. [/color](setq n 0)                                                                                        ; Set loop counter 0.
  7. (setq dimlist '())                                                                                ; Set dimensionslist cleared.
  8. (repeat (sslength AllDimensions)                                                        ; Repeat for all in selectionset AllDimensions
  9.         (setq CheckDimension (entget (ssname AllDimensions n)))                                ; Gets the entity
  10.         (setq dimcontent (cdr (assoc 42 CheckDimension)))                                ; Reads the measured distance
  11.         (setq dimlist (cons dimcontent dimlist))                                        ; Adds this distance to a totallist
  12.         (setq n (+ 1 n))                                                                ; Up the counter for next dimension
  13. )                                                                                        ; End repeat
  14. (if (setq filename (getfiled "\nFile Location..." "DimensionExport" "txt" 11))                ; Make a new textfile with default name
  15.         (progn                                                                                ; When created do this.
  16.                 (setq fil (open filename "w"))                                                ; Open the new file
  17.                 (foreach x dimlist                                                        ; For all dimensions in the totallist
  18.                         (princ (strcat (rtos x 2) "\n") fil)                                ; Print them in them in the textfile
  19.                 )                                                                        ; Close 'foreach'
  20.                 (close fil)                                                                ; Close filewriter
  21.                 (startapp "notepad" filename)                                                ; Open created file with notepad
  22.                 (graphscr)                                                                ; Return to screen
  23.         )                                                                                ; Close 'do this'
  24. )                                                                                        ; End if
  25. (princ)                                                                                                ; Silent exit
  26. )                                                                                                ; End function

 
我将_X更改为_L,但不工作选择(不拾取)维度。
谢谢
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-13 21:08 , Processed in 1.312102 second(s), 73 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表