MyLsp.lsp

 

 

 

;;;============================================================================;
;; 현재 도면에 로딩된 명령어/함수/변수 기록
;; edit by izzarder
;;;============================================================================;
(defun c:MyLsp (/ A B FILE GETKW LST N TEMP_FILE consp is-command is-function my-princ)
;;;----------------------------------------------------------------------------;
   (defun Is-command (a /)
      (and
         (equal "C:" (substr (xstrcase a) 1 2))
         (Is-function (eval (read a)))
      )
   )
;;;----------------------------------------------------------------------------;
   (defun consp (lst)
      (not (vl-list-length lst))
   )
;;;----------------------------------------------------------------------------;
   (defun Is-function (b /)
      (or
         (and
            (= 'LIST (type b))
            (not (consp b))
            (> (length b) 1)
            (or (= 'LIST (type (car b)))
               (not (car b))
            )
         )
         (= 'SUBR (type b))
         (= 'USUBR (type b))
         (= 'EXRXSUBR (type b))
      )
   )
;;;----------------------------------------------------------------------------;
   (defun My-princ (a / c)
      (if
         (setq c (type (eval (read a))))
         (setq c (vl-symbol-name c))
         (setq c "nil")
      )
      (setq c (strcat "(" c ")"))
      (if
         (= "C:" (substr a 1 2))
         (setq a (substr a 3))
      )
      (while (< (strlen a) 40)
         (setq a (strcat a " "))
      )
      (while (< (strlen c) 20)
         (setq c (strcat c " "))
      )
      (strcat a c)
   )
;;;----------------------------------------------------------------------------;
   (initget "Commands Functions Variables")
   (setq getkw (getkword "\n>> 선택 [Commands/Functions/Variables] <P> </P><VARIABLES>: "))
   (setq lst (acad_strlsort (atoms-family 1)))
   (setq Temp_File (vl-filename-mktemp nil nil ".txt"))
   (setq file (open Temp_File "w"))
   (cond
      (  (= getkw "Commands")
         (repeat (setq n (length lst))
            (setq a (xstrcase (nth (setq n (1- n)) lst)))
            (if (Is-command a)
               (write-line (My-princ a) FILE)
            )
         )
      )
      (  (= getkw "Functions")
         (repeat (setq n (length lst))
            (setq a (xstrcase (nth (setq n (1- n)) lst)))
            (if
               (and
                  (setq b (eval (read a)))
                  (Is-function b)
               )
               (write-line (My-princ a) FILE)
            )
         )
      )
      (  'T
         (repeat (setq n (length lst))
            (setq a (xstrcase (nth (setq n (1- n)) lst)))
            (setq b (eval (read a)))
            (if
               (and
                  (not (Is-function b))
                  (not (Is-command a))
               )
               (write-line (My-princ a) FILE)
            )
         )
      )
   )
   (close FILE)
   (startapp "notepad" Temp_File)
   (princ)
)

 

'Lisp & Tips > Lisp' 카테고리의 다른 글

시간과 관련된 함수  (0) 2016.12.04
vl-file-systime 의 사용법  (0) 2016.12.04
vla-get-selectionsets, vla-get-activeselectionset 활용법  (0) 2016.05.08
=, eq, equal  (0) 2016.04.02
블럭안의 치수만 지우기  (0) 2016.02.20