RenderMan,我遇到了一个错误,没有打开临时文件下的csv文件。我刚刚修改了路径名,效果很好。以下是适用于我的代码:
- (defun c:BlockProp (/ *error* ss path acApp acDoc oShell file coord)
- ;; RenderMan, 2012
- (princ "\rBLOCKPROP ")
- (vl-load-com)
- (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 "_x" '((0 . "INSERT"))))
- (setq path C:\\Users\\ZAGM01373\\Documents\\Batman.csv") ;Please change this to your preferred file path and name
- (setq acApp (vlax-get-acad-object))
- (setq acDoc (vla-get-activedocument acApp))
- (setq oShell
- (vla-getinterfaceobject acApp "Shell.Application")))
- (progn
- (setq file (open path "w"))
- (write-line "BLOCK PROPERTIES" file)
- (write-line "" file)
- (write-line
- (strcat "Drawing:, , " (getvar 'dwgprefix) (getvar 'dwgname))
- file)
- (write-line
- (strcat "Date:, , "
- (menucmd "M=$(edtime,$(getvar,date),YYYY-MO-DD)"))
- file)
- (write-line "" file)
- (write-line "NAME, X, Y, Z, ROTATION" file)
- (vlax-for oBlock
- (setq ss (vla-get-activeselectionset acDoc))
- (write-line
- (strcat
- (vla-get-effectivename oBlock)
- ","
- (rtos
- (car (setq coord (vlax-get oBlock 'insertionpoint))))
- ","
- (rtos (cadr coord))
- ","
- (rtos (caddr coord))
- ","
- (rtos (vla-get-rotation oBlock)))
- file))
- (setq file (close file))
- (vlax-invoke oShell 'open path)
- (*error* nil))
- (*error* "No blocks found")))
|