考虑到您使用的是“哑”圆(不读取点编号、属性或对象数据等),为什么不直接将每个圆的坐标导出到ASCII文本文件(PNEZ?)中呢,然后作为点导入?
我认为这比试图在每个圆上执行Land Desktop命令(速度慢得出奇)要高效得多。
- (vl-load-com)
- (defun c:CTOA () (c:CircleToAscii))
- (defun c:CircleToAscii
- (/ *error* ss n i path acApp acDoc oShell file pt)
- (princ "\rCIRCLETOASCII ")
- (defun *error* (msg)
- (if oShell
- (vlax-release-object oShell)
- )
- (if file
- (close file)
- )
- (cond ((not msg)) ; Normal exit
- ((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit)
- ((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it
- )
- (princ)
- )
- (if (and (setq ss (ssget "_:L" '((0 . "CIRCLE"))))
- (setq n (sslength ss))
- (setq i 0)
- (setq path
- (strcat (vl-filename-directory (vl-filename-mktemp))
- "\"
- (vl-filename-base (getvar 'dwgname))
- "_"
- (menucmd "M=$(edtime,$(getvar,date),YYYY-MO-DD)")
- "_PNEZ"
- ".txt"
- )
- )
- (setq acApp (vlax-get-acad-object))
- (setq acDoc (vla-get-activedocument acApp))
- (princ "\nWorking, please wait...")
- (princ)
- (setq oShell
- (vla-getinterfaceobject acApp "Shell.Application")
- )
- )
- (progn
- (if (findfile path)
- (vl-file-delete path)
- )
- (setq file (open path "w"))
- (vlax-for x (setq ss (vla-get-activeselectionset acDoc))
- (write-line
- (strcat
- (itoa (setq i (1+ i)))
- ","
- (rtos (cadr (setq pt (vlax-get x 'center))))
- ","
- (rtos (car pt))
- ","
- (rtos (last pt))
- )
- file
- )
- )
- (setq file (close file))
- (vla-delete ss)
- (prompt (strcat "\n** " (itoa n) " circles processed ** "))
- (vlax-invoke oShell 'open path)
- (*error* nil)
- )
- (cond (acDoc
- (*error* "Unable to create "Shell.Application Object"")
- )
- (n (*error* "Unable to create temporary file"))
- ((*error* "No circles selected"))
- )
- )
- )
|