作为对旧代码的修改,我写道:
(defun c:DimUpdate ( / *error* _read dcfilename strfilename strlst ss dctag ptr dcflag str ) ;; © Lee Mac 2010 (setq dcfilename "DimUpdate.dcl" ;; DCL Filename Strfilename "DimUpdate.txt" ;; Data Filename ) (defun *error* ( msg ) (and dcTag (unload_dialog dcTag)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ)) (defun _read ( file / ofile lst nl ) (cond ( (setq ofile (open file "r")) (while (setq nl (read-line ofile)) (setq lst (cons nl lst))) (close ofile))) (reverse lst) ) (cond ( (not (setq Strfilename (findfile Strfilename))) (princ "\n** Data File not Found **")) ( (not (setq StrLst (_read Strfilename))) (princ "\n** Data File Empty **")) ( (not (setq ss (ssget "_:L" '((0 . "*DIMENSION")))))) ( (<= (setq dcTag (load_dialog dcfilename)) 0) (princ "\n** Dialog Definition Not Found **")) ( (not (new_dialog "dimupdate" dcTag)) (princ "\n** Dialog Could not be Loaded **")) (t (start_list "lst") (mapcar (function add_list) StrLst) (end_list) (set_tile "dcltitle" "Dimension Notes") (setq ptr (set_tile "lst" "0")) (action_tile "lst" "(setq ptr $value)") (setq dcFlag (start_dialog) dcTag (unload_dialog dcTag) Str (nth (atoi ptr) StrLst)) (if (= 1 dcFlag) ( (lambda ( i / ent ) (while (setq ent (ssname ss (setq i (1+ i)))) (entupd (cdr (assoc -1 (entmod (subst (cons 1 (strcat "<>" str)) (assoc 1 (entget ent)) (entget ent)) ) ) ) ) ) ) -1 ) (princ "\n*Cancel*") ) ) ) (princ))
到
dimupdate : dialog { key = "dctitle"; spacer; : list_box { label = "Notes:"; key = "lst"; alignment = centered; fixed_height = true; fixed_width = true; width = 50; height = 20; } spacer; ok_cancel;}
如果你愿意的话,我会把添加提示留给你——只要记住在修改的地方做标记/首字母。