您好,刚刚注意到您的第一个帖子是2018年2月7日下午08:37
IMO没有回应可能与excel vba宏自动化有关??
在Excel工作表单元格中:
这是vba可以做到的,但本LISP论坛讨论不要求vba免费提供
但是如果你尝试一些代码来寻求帮助,我相信你会得到这里活跃成员的快速响应来解决你的问题
我更喜欢以“*.csv”格式输出纯文本,它通过AutoLisp打开和写入行函数很简单
它也可以在Excel中查看,比ActiveX方法更简单、更快。
除非您需要一些格式化的输出,否则您可以按照BIGAL的建议使用Excel API。
但这里有一个使用Lisp方法的快速替代解决方案。。
- [color="green"];limitations
- ;Each lot must be a closed LWPolyline
- ;Area text must contain "*[b] m2[/b]"
- ;Lot number must be numeric
- ;Assume each lot has ONLY (lot number text & area text) pairs
- [color="red"];all labels must be inside polygon[/color] [/color]
- (alert "Type "[b]TEST[/b]" in command line (without quote) to invoke.. ")
- (defun c:test ( / l i s ss ls lst en ob fn f wp )
- ;hanhphuc [color="red"]18[/color].04.2018
- (and
- (setq
- ss (ssget "X" (list '(0 . "LWPOLYLINE") '(-4 . "=") '(70 . 1)[color="red"] (cons 410 (getvar 'ctab))[/color]))) [color="green"];<- edit[/color]
- )
- (repeat (setq i (sslength ss))
- (setq en (ssname ss (setq i (1- i)))
- wp (mapcar ''((x)(trans (cdr x) en 1)) (vl-remove-if ''((x) (/= (car x) 10)) (entget en)))
- lst (cons (if (setq s (ssget "WP" wp ))
- (setq ls (vl-remove nil
- (mapcar ''((x)
- (setq ob (vlax-ename->vla-object x))
- (if
- (vlax-property-available-p ob 'TextString)
- (vlax-get ob 'TextString)
- )
- )
- (acet-ss-to-list s)
- )
- )
- ls (if [color="red"](and (=(length ls)2)[/color]
- (wcmatch (car ls) "* m2*")[color="red"])[/color]
- (reverse ls)
- ls
- )
- ls (subst (strcat (car ls) ",") (car ls) ls)
- ls [color="red"](if (wcmatch(cadr ls) "*,*")[/color] (subst (vl-string-subst "" "," (cadr ls)) (cadr ls) ls) ls)
- )
- )
- lst
- )
- )
- )
- (setq fn (strcat (getvar 'dwgprefix) "Area_example.csv"))
- (setq f (open fn "a"))
- (foreach x (cons "\nlot Number,Area"
- (vl-sort (vl-remove nil lst) ''((a b) (< (atoi (car a)) (atoi (car b)))))
- )
- (write-line
- (if (listp x)
- (apply 'strcat x)
- x
- )
- f
- )
- )
- (progn
- (if f
- (close f)
- )
- (command "startapp" "notepad" fn)
- [color="green"];(command "start" fn) ;if default Excel to open *csv [/color]
- )
- )
- (princ)
- )
- (vl-load-com)
- (C:TEST)
附言:如果您使用的是AC2016,那么命令:DATAEXTRACTION如何?但不是ac2007 |