导出块属性和
李·麦克的myexport。lsp是用于导出块属性和坐标的奇妙lisp,但我需要添加一个附加步骤。在将x和y坐标写入txt文件之前,我需要将用户输入的乘数应用于x和y坐标。
所以基本上我需要选择块,进行例行暂停,允许用户输入乘数,然后完成其任务。
到目前为止,我没有成功地修改李的例行程序,以达到这一目的。主要是因为我的AutoLISP不再那么流利了。(我相信我上一次学习AutoLISP是在20世纪90年代初)
提前谢谢。
-詹姆斯 欢迎来到CADTutor James。
试试这个mods。
;; My Export-Lee Mac
;; A generic data extraction program for attributed blocks.
;;
;; The 'ord' list can contain attribute tags or symbols representing block
;; insertion coordinates.
;;
;; e.g. ("TAG1" POINT-Y POINT-X "TAG2")
;;
;; will extract the value of attribute 'TAG1', followed by the Y & X-coordinates
;; of the block insertion point, followed by the value of attribute 'TAG2'.
;;
;; Point values will be formatted using the current values of the LUNITS & LUPREC
;; system variables.
;;
;; The filename, extension & data delimiter character are all specified at the
;; top of the program code.
(defun c:myexport ( / *error* del des ent idx lst obj ord out sel mlt)
(defun *error* ( msg )
(if (= 'file (type des))
(close des)
)
(if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
(princ (strcat "\nError: " msg))
)
(princ)
)
(setq ord '("POINT" POINT-X POINT-Y "ELEV" "DESC")
out(LM:uniquefilename (strcat (getvar 'dwgprefix) (vl-filename-base (getvar 'dwgname))) ".txt")
del"\t"
)
(if (and (setq sel (ssget '((0 . "INSERT") (66 . 1))))
(setq mlt (getdist "\nSpecify the Multiplying Factor :"));; added by Tharwat
)
(if (setq des (open out "w"))
(progn
(repeat (setq idx (sslength sel))
(setq ent (ssname sel (setq idx (1- idx)))
obj (vlax-ename->vla-object ent)
)
(setq lst
(append
(mapcar '(lambda ( a b ) (cons a (rtos (* b mlt)))) ;; modified by Tharwat
'(point-x point-y point-z)
(trans (cdr (assoc 10 (entget ent))) ent 0)
)
(mapcar '(lambda ( x ) (cons (strcase (vla-get-tagstring x)) (vla-get-textstring x)))
(append
(vlax-invoke obj 'getattributes)
(vlax-invoke obj 'getconstantattributes)
)
)
)
)
(if (setq lst (vl-remove 'nil (mapcar '(lambda ( x ) (cdr (assoc x lst))) ord)))
(write-line (LM:lst->str lst del) des)
)
)
(setq des (close des))
)
(princ (strcat "\nUnable to open file: \"" out "\" for writing."))
)
)
(princ)
)
;; List to String-Lee Mac
;; Concatenates each string in a list, separated by a given delimiter
(defun LM:lst->str ( lst del )
(if (cdr lst)
(strcat (car lst) del (LM:lst->str (cdr lst) del))
(car lst)
)
)
;; Unique Filename-Lee Mac
;; Returns a unique filename for a given path & file extension
(defun LM:uniquefilename ( pth ext / fnm tmp )
(if (findfile (setq fnm (strcat pth ext)))
(progn
(setq tmp 1)
(while (findfile (setq fnm (strcat pth "(" (itoa (setq tmp (1+ tmp))) ")" ext))))
)
)
fnm
)
(vl-load-com) (princ)
如果myexport。lsp适用于您,然后您可以在Excel中将坐标乘以因子。 有机:我们可以使用多种变通解决方案。然而,“一键式”方法效率更高,更不容易出错。
塔尔沃特:效果非常好。非常感谢您的修改!
很好,不客气。
这一切都归功于李。
页:
[1]