3
8
5
初来乍到
使用道具 举报
(defun c:pm();-------------------------(defun parsestr->lst (str / LST POS str) (while (setq pos (vl-string-search "," str)) (setq lst (cons (vl-string-left-trim " "(substr str 1 pos)) lst) str (substr str (+ pos 2)) ) ) (if (> (strlen str) 0) (setq lst (cons (vl-string-left-trim " " str) lst)) ) (reverse lst));-------------------------;(joinlst->str (list "1" "2" "3" "4" "5" "6"))(defun joinlst->str (lst / LST POS str) (setq str "") (while lst (setq x (car lst)) (if (setq lst(cdr lst)) (setq str (strcat str x ",")) (setq str (strcat str x)) ) ) str);-------------------------(defun subst-index(var n lst / i) (setq i -1) (mapcar '(lambda(x) (if (= n (setq i (1+ i))) var x)) lst));-----------DELETE A ITOM--------------;(delete-index 1 '((1 2 3) (4 5 6)(7 8 9)))(defun delete-index(n lst / i) (setq i -1) (vl-remove-if '(lambda(x) (= (setq i (1+ i)) n)) lst));-----------INSERT A ITOM--------------;(add-index "A" -1 '(0 1 2 3 4 5))(defun add-index(var n lst / len i newlst) (setq len (length lst)) (cond ((< n 0) (setq newlst (cons var lst)) ) ((>= n len) (setq newlst (reverse(cons var (reverse lst)))) ) (t (setq i -1 newlst nil) (foreach itom lst (if (= n (setq i (1+ i))) (setq newlst (cons itom newlst) newlst (cons var newlst) ) (setq newlst (cons itom newlst)) ) ) (setq newlst (reverse newlst)) ) ) newlst);-------------------------(defun LM:editbox ( str / han ) (and (< 0 (setq han (load_dialog "acad"))) (new_dialog "acad_txtedit" han) (set_tile "text_edit" str) (action_tile "text_edit" "(setq str $value)") (if (zerop (start_dialog)) (setq str nil)) ) (if (< 0 han) (unload_dialog han)) str);-------------------------(defun readpatfile(file / files fn PatternList pat x fn) (if (and (setq files(findfile file)) (setq fn (open files "r")) ) (progn (setq PatternList NIL pat nil) (while (setq x (read-line fn)) (cond ((wcmatch X "`**") (if pat (setq PatternList (cons (reverse pat) PatternList)) ) (setq pat nil pat (cons x pat) ) ) ((wcmatch X "#*#*#*#*") (setq pat(cons x pat)) ) (t nil) ) ) (setq PatternList (cons (reverse pat) PatternList)) (close fn) ) ) (reverse PatternList));-------------------------(defun show_list(key newlist) (start_list key) (mapcar 'add_list newlist) (end_list));-------------------------(defun act_open() (if (setq patfile(getfiled "SELECT A FILE(.PAT) TO OPEN" (get_tile "patfile") "pat" 2)) (progn (setq PatternList (readpatfile patfile)) (show_list "patnamelst" (mapcar 'car PatternList)) (show_list "patterninfo" nil)