乐筑天下

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

[编程交流] 导出块属性和

[复制链接]

1

主题

2

帖子

1

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 18:54:26 | 显示全部楼层 |阅读模式
李·麦克的myexport。lsp是用于导出块属性和坐标的奇妙lisp,但我需要添加一个附加步骤。
 
在将x和y坐标写入txt文件之前,我需要将用户输入的乘数应用于x和y坐标。
 
所以基本上我需要选择块,进行例行暂停,允许用户输入乘数,然后完成其任务。
 
到目前为止,我没有成功地修改李的例行程序,以达到这一目的。主要是因为我的AutoLISP不再那么流利了。(我相信我上一次学习AutoLISP是在20世纪90年代初)
 
提前谢谢。
-詹姆斯
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 19:19:38 | 显示全部楼层
欢迎来到CADTutor James。
 
试试这个mods。
 
  1. ;; My Export  -  Lee Mac
  2. ;; A generic data extraction program for attributed blocks.
  3. ;;
  4. ;; The 'ord' list can contain attribute tags or symbols representing block
  5. ;; insertion coordinates.
  6. ;;
  7. ;; e.g. ("TAG1" POINT-Y POINT-X "TAG2")
  8. ;;
  9. ;; will extract the value of attribute 'TAG1', followed by the Y & X-coordinates
  10. ;; of the block insertion point, followed by the value of attribute 'TAG2'.
  11. ;;
  12. ;; Point values will be formatted using the current values of the LUNITS & LUPREC
  13. ;; system variables.
  14. ;;
  15. ;; The filename, extension & data delimiter character are all specified at the
  16. ;; top of the program code.
  17. (defun c:myexport ( / *error* del des ent idx lst obj ord out sel mlt)
  18.    (defun *error* ( msg )
  19.        (if (= 'file (type des))
  20.            (close des)
  21.        )
  22.        (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
  23.            (princ (strcat "\nError: " msg))
  24.        )
  25.        (princ)
  26.    )
  27.    (setq ord '("POINT" POINT-X POINT-Y "ELEV" "DESC")
  28.          out  (LM:uniquefilename (strcat (getvar 'dwgprefix) (vl-filename-base (getvar 'dwgname))) ".txt")
  29.          del  "\t"
  30.    )
  31.    (if (and (setq sel (ssget '((0 . "INSERT") (66 . 1))))
  32.             (setq mlt (getdist "\nSpecify the Multiplying Factor :"));; added by Tharwat
  33.             )
  34.        (if (setq des (open out "w"))
  35.            (progn
  36.                (repeat (setq idx (sslength sel))
  37.                    (setq ent (ssname sel (setq idx (1- idx)))
  38.                          obj (vlax-ename->vla-object ent)
  39.                    )
  40.                    (setq lst
  41.                        (append
  42.                            (mapcar '(lambda ( a b ) (cons a (rtos (* b mlt)))) ;; modified by Tharwat
  43.                               '(point-x point-y point-z)
  44.                                (trans (cdr (assoc 10 (entget ent))) ent 0)
  45.                            )
  46.                            (mapcar '(lambda ( x ) (cons (strcase (vla-get-tagstring x)) (vla-get-textstring x)))
  47.                                (append
  48.                                    (vlax-invoke obj 'getattributes)
  49.                                    (vlax-invoke obj 'getconstantattributes)
  50.                                )
  51.                            )
  52.                        )
  53.                    )
  54.                    (if (setq lst (vl-remove 'nil (mapcar '(lambda ( x ) (cdr (assoc x lst))) ord)))
  55.                        (write-line (LM:lst->str lst del) des)
  56.                    )
  57.                )
  58.                (setq des (close des))
  59.            )
  60.            (princ (strcat "\nUnable to open file: "" out "" for writing."))
  61.        )
  62.    )
  63.    (princ)
  64. )               
  65. ;; List to String  -  Lee Mac
  66. ;; Concatenates each string in a list, separated by a given delimiter
  67. (defun LM:lst->str ( lst del )
  68.    (if (cdr lst)
  69.        (strcat (car lst) del (LM:lst->str (cdr lst) del))
  70.        (car lst)
  71.    )
  72. )
  73. ;; Unique Filename  -  Lee Mac
  74. ;; Returns a unique filename for a given path & file extension
  75. (defun LM:uniquefilename ( pth ext / fnm tmp )
  76.    (if (findfile (setq fnm (strcat pth ext)))
  77.        (progn
  78.            (setq tmp 1)
  79.            (while (findfile (setq fnm (strcat pth "(" (itoa (setq tmp (1+ tmp))) ")" ext))))
  80.        )
  81.    )
  82.    fnm
  83. )
  84. (vl-load-com) (princ)
回复

使用道具 举报

44

主题

542

帖子

502

银币

后起之秀

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

铜币
220
发表于 2022-7-5 19:29:41 | 显示全部楼层
 
如果myexport。lsp适用于您,然后您可以在Excel中将坐标乘以因子。
回复

使用道具 举报

1

主题

2

帖子

1

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 19:39:44 | 显示全部楼层
有机:我们可以使用多种变通解决方案。然而,“一键式”方法效率更高,更不容易出错。
 
塔尔沃特:效果非常好。非常感谢您的修改!
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 20:02:20 | 显示全部楼层
 
很好,不客气。
 
这一切都归功于李。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-12 13:50 , Processed in 0.523907 second(s), 62 queries .

© 2020-2025 乐筑天下

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