谢谢你的“是”让我们有点不同。我对更深入的Lisp函数有点陌生。
我还添加了一个检查,看看它是否是一个全新的图纸,尚未保存,否则它试图保存文件随机。我相信我们会将其添加到我们的acad2014doc中。Lisp文件,以创建一种方法,确保人们正在审核和清除图形。
最后的Lisp程序最终变成了这样:
- ;; YesNo.lsp CAB 04.260.2008
- ;; Creates a DCL file on the fly for Yes/No Prompt
- ;; Arguments:
- ;; BoxTitle = Dialog Box Title
- ;; Question = Question to be displayed
- ;; Sample Call (YesNo " My Yes No" "Do you like creating programs in AutoLISP?")
- ;; Returns "Yes" or "No" from user or nil if the DCL failed
- (defun YesNo (BoxTitle Question / Dcl_Id% Result acadfn fn fid)
- (if
- (and (or (setq fn (findfile "YesNo.dcl"))
- (setq acadfn (findfile "ACAD.PAT")
- fn (strcat (substr acadfn 1 (- (strlen acadfn) ) "YesNo.dcl")))
- (setq fid (open fn "w"))
- )
- ;; create dcl file in same directory as ACAD.PAT
- (progn
- (foreach x
- (list
- "YesNo : dialog { key = "Title";"
- " spacer;"
- (strcat " : text { key = "Question" ; width = "
- (itoa (+ (strlen Question) 4))
- " ; alignment = centered; }")
- " spacer;"
- " : row { fixed_width = true; alignment = centered;"
- " : button { key = "Yes"; label = "&Yes"; is_default = true;}"
- " : button { key = "No"; label = "&No"; is_cancel = true;}"
- " }"
- "}"
- )
- (princ x fid)
- (write-line "" fid)
- )
- (close fid)
- )
- )
- (cond
- ((setq Dcl_Id% (load_dialog fn))
- (new_dialog "YesNo" Dcl_Id%)
- (set_tile "Title" BoxTitle)
- (set_tile "Question" Question)
- (action_tile "Yes" "(done_dialog 1)")
- (action_tile "No" "(done_dialog 0)")
- (setq Result (start_dialog))
- (unload_dialog Dcl_Id%) ; Unload Dialog
- (if (and Result (= Result 1)) "Yes" "No")
- )
- (t nil)
- )
- )
- (vl-load-com)
- (defun Create_Close_Reactor()
- (if(not close:reactor)
- (setq close:reactor
- (vlr-editor-reactor nil
- '((:vlr-beginClose . CloseReaction))))
- ); end if
- (princ)
- ); end of Create_Close_Reactor
- (defun CloseReaction(args reac / actDoc)
- (if (zerop (getvar 'dwgtitled))
- (null)
- (progn
- (setq reply (yesno "Closing" "Would you like to Audit and Purge your Drawing"))
- (IF (= reply "Yes")
- (progn
- (setq actDoc(vla-get-ActiveDocument
- (vlax-get-acad-object)))
- (vla-ZoomExtents(vlax-get-acad-object))
- (vla-AuditInfo (vla-get-ActiveDocument (vlax-get-object "AutoCAD.Application")) :Vlax-True)
- (repeat 3(vla-PurgeAll actDoc))
- (vla-Save actDoc)
- )
- (progon
- (setq actDoc(vla-get-ActiveDocument
- (vlax-get-acad-object)))
- (vla-ZoomExtents(vlax-get-acad-object))
- (vla-Save actDoc)
- )
- )
- )
- )
- (princ)
- ); end of CloseReaction
- (Create_Close_Reactor)
|