||||r14에서는 멀티 브레이크(여러선을 선택하여) 한번에 똑같은 간격으로
한번에 잘라주는 명령어가 됬엇는데요.
2002에서는 어떡해야할지 모르겟네요.
2포인트 브레이크로 한개 밖에 자를수없으니.. 갑갑합니다.
14에서쓰던 리습 올겨봅니다.
이걸 2002에 어떡케해야 쓸수있을지(특히 브레이크)
알려주시면 감사하겟습니다. 될수있음 상세하게 부탁드립니다.

; Next available MSG number is    86
; MODULE_ID ACADR14_LSP_
;;;    ACADR14.LSP Version 14.1 for Release 14
;;;
;;;    Copyright (C) 1994 - 1997 by Autodesk, Inc.
;;;
;;;    Permission to use, copy, modify, and distribute this software
;;;    for any purpose and without fee is hereby granted, provided
;;;    that the above copyright notice appears in all copies and
;;;    that both that copyright notice and the limited warranty and
;;;    restricted rights notice below appear in all supporting
;;;    documentation.
;;;
;;;    AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
;;;    AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
;;;    MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC.
;;;    DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
;;;    UNINTERRUPTED OR ERROR FREE.
;;;
;;;    Use, duplication, or disclosure by the U.S. Government is subject to
;;;    restrictions set forth in FAR 52.227-19 (Commercial Computer
;;;    Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
;;;    (Rights in Technical Data and Computer Software), as applicable.
;;;
;;;.
;;;
;;;    Note:
;;;            This file is loaded automatically by AutoCAD every time
;;;            a drawing is opened.  It establishes an autoloader and
;;;            other utility functions.
;;;
;;;    Globalization Note:  
;;;            We do not support autoloading applications by the native
;;;            language command call (e.g. with the leading underscore
;;;            mechanism.)


;;;===== Raster Image Support for Clipboard Paste Special =====
;;
;; IMAGEFILE
;;
;; Allow the IMAGE command to accept an image file name without
;; presenting the file dialog, even if filedia is on.
;; Example: (imagefile "c:/images/house.bmp")
;;
(defun imagefile (filename / filedia-save cmdecho-save)
  (setq filedia-save (getvar "FILEDIA"))
  (setq cmdecho-save (getvar "CMDECHO"))
  (setvar "FILEDIA" 0)
  (setvar "CMDECHO" 0)
  (command "_.-image" "_attach" filename)
  (setvar "FILEDIA" filedia-save)
  (setvar "CMDECHO" cmdecho-save)
  (princ)
)

;;;=== General Utility Functions ===

;   R12 compatibility - In R12 (acad_helpdlg) was an externally-defined
;   ADS function.  Now it's a simple AutoLISP function that calls the
;   built-in function (help).  It's only purpose is R12 compatibility.  
;   If you are calling it for anything else, you should almost certainly
;   be calling (help) instead.

(defun acad_helpdlg (helpfile topic)
  (help helpfile topic)
)


(defun *merr* (msg)
  (setq *error* m:err m:err nil)
  (princ)
)

(defun *merrmsg* (msg)
  (princ msg)
  (setq *error* m:err m:err nil)
  (princ)
)

;; Loads the indicated ARX app if it isn't already loaded
;; returns nil if no load was necessary, else returns the
;; app name if a load occurred.
(defun verify_arxapp_loaded (app)
  (if (not (loadedp app (arx)))
      (arxload app f)
  )
)

;; determines if a given application is loaded...
;; general purpose: can ostensibly be used for appsets (arx) or (ads) or....
;;
;; app is the filename of the application to check (extension is required)
;; appset is a list of applications, (such as (arx) or (ads)
;;
;; returns T or nil, depending on whether app is present in the appset
;; indicated.  Case is ignored in comparison, so "foo.arx" matches "FOO.ARX"
;; Also, if appset contains members that contain paths, app will right-match
;; against these members, so "bar.arx" matches "c:\\path\\bar.arx"; note that
;; "bar.arx" will *not* match "c:\\path\\foobar.arx."
(defun loadedp (app appset)
  (cond (appset  (or
                     ;; exactly equal? (ignoring case)
                     (= (strcase (car appset))
                        (strcase app))
                     ;; right-matching? (ignoring case, but assuming that
                     ;; it's a complete filename (with a backslash before it)
                                         (and
                                             (> (strlen (car appset)) (strlen app))
                             (= (strcase (substr (car appset)
                                                 (- (strlen (car appset))
                                                    (strlen app)
                                                 )
                                         )
                                )
                                (strcase (strcat "\\" app))
                             )
                                     )
                     ;; no match for this entry in appset, try next one....
                     (loadedp app (cdr appset)) )))
)


;;; ===== Single-line MText editor =====
(defun LispEd (contents / fname dcl state)
  (if (not (setq fname (getvar "program")))
     (setq fname "acad")
  )
  (strcat fname ".dcl")
  (setq dcl (load_dialog fname))
  (if (not (new_dialog "LispEd" dcl)) (exit))
  (set_tile "contents" contents)
  (mode_tile "contents" 2)
  (action_tile "contents" "(setq contents $value)")
  (action_tile "accept" "(done_dialog 1)")
  (action_tile "mtexted" "(done_dialog 2)" )
  (setq state (start_dialog))
  (unload_dialog dcl)
  (cond
    ((= state 1) contents)
    ((= state 2) -1)
    (t 0)
  )
)

;;; ===== Discontinued commands =====
(defun c:gifin ()
  (alert "\nThe GIFIN command is no longer supported.\nUse the IMAGE command to attach raster image files.\n")
  (princ)
)

(defun c:pcxin ()
  (alert "\nThe PCXIN command is no longer supported.\nUse the IMAGE command to attach raster image files.\n")
  (princ)
)

(defun c:tiffin ()
  (alert "\nThe TIFFIN command is no longer supported.\nUse the IMAGE command to attach raster image files.\n")
  (princ)
)

(defun c:ddemodes()
  (alert "The Object Properties toolbar incorporates DDEMODES functionality.  \nDDEMODES has been discontinued.  \n\nFor more information, select DDEMODES from the AutoCAD Help Index tab.")
  (princ)
)

;;; ===== AutoLoad =====

;;; Check list of loaded <apptype> applications ("ads" or "arx")
;;; for the name of a certain appplication <appname>.
;;; Returns T if <appname> is loaded.

(defun ai_AppLoaded (appname apptype)
   (apply 'or
      (mapcar
        '(lambda (j)
            (wcmatch
               (strcase j T)
               (strcase (strcat "*" appname "*") T)
            )  
         )
         (eval (list (read apptype)))
      )
   )
)

;;  
;;  Native Rx commands cannot be called with the "C:" syntax.  They must
;;  be called via (command).  Therefore they require their own autoload
;;  command.

(defun autonativeload (app cmdliste / qapp)
  (setq qapp (strcat "\"" app "\""))
  (setq initstring "\nInitializing...")
  (mapcar
   '(lambda (cmd / nom_cmd native_cmd)
      (progn
        (setq nom_cmd (strcat "C:" cmd))
        (setq native_cmd (strcat "\"_" cmd "\""))
        (if (not (eval (read nom_cmd)))
            (eval
             (read (strcat
                    "(defun " nom_cmd "()"
                    "(setq m:err *error* *error* *merrmsg*)"
                    "(if (ai_ffile " qapp ")"
                    "(progn (princ initstring)"
                    "(_autoarxload " qapp ") (command " native_cmd "))"
                    "(ai_nofile " qapp "))"
                    "(setq *error* m:err m:err nil))"
                    ))))))
   cmdliste)
  nil
)

(defun _autoqload (quoi app cmdliste / qapp symnam)
  (setq qapp (strcat "\"" app "\""))
  (setq initstring "\nInitializing...")
  (mapcar
   '(lambda (cmd / nom_cmd)
      (progn
        (setq nom_cmd (strcat "C:" cmd))
        (if (not (eval (read nom_cmd)))
            (eval
             (read (strcat
                    "(defun " nom_cmd "( / rtn)"
                    "(setq m:err *error* *error* *merrmsg*)"
                    "(if (ai_ffile " qapp ")"
                    "(progn (princ initstring)"
                    "(_auto" quoi "load " qapp ") (setq rtn (" nom_cmd ")))"
                    "(ai_nofile " qapp "))"
                    "(setq *error* m:err m:err nil)"
                    "rtn)"
                    ))))))
   cmdliste)
  nil
)

(defun autoload (app cmdliste)
  (_autoqload "" app cmdliste)
)

(defun autoxload (app cmdliste)
  (_autoqload "x" app cmdliste)
)

(defun autoarxload (app cmdliste)
  (_autoqload "arx" app cmdliste)
)

(defun autoarxacedload (app cmdliste / qapp symnam)
  (setq qapp (strcat "\"" app "\""))
  (setq initstring "\nInitializing...")
  (mapcar
   '(lambda (cmd / nom_cmd)
      (progn
        (setq nom_cmd (strcat "C:" cmd))
        (if (not (eval (read nom_cmd)))
            (eval
             (read (strcat
                    "(defun " nom_cmd "( / oldcmdecho)"
                    "(setq m:err *error* *error* *merrmsg*)"
                    "(if (ai_ffile " qapp ")"
                    "(progn (princ initstring)"
                    "(_autoarxload " qapp ")"
                    "(setq oldcmdecho (getvar \"CMDECHO\"))"
                    "(setvar \"CMDECHO\" 0)"
                    "(command " "\"_" cmd "\"" ")"
                    "(setvar \"CMDECHO\" oldcmdecho))"
                    "(ai_nofile " qapp "))"
                    "(setq *error* m:err m:err nil)"
                    "(princ))"
                    ))))))
   cmdliste)
  nil
)

(defun _autoload (app)
; (princ "Auto:(load ") (princ app) (princ ")") (terpri)
  (load app)
)

(defun _autoxload (app)
; (princ "Auto:(xload ") (princ app) (princ ")") (terpri)
  (if (= app "region") (ai_select))
  (xload app)
  (if (= app "region") (ai_amegrey "~"))
)

(defun _autoarxload (app)
; (princ "Auto:(arxload ") (princ app) (princ ")") (terpri)
  (arxload app)
)

(defun ai_ffile (app)
  (or (findfile (strcat app ".lsp"))
      (findfile (strcat app ".exp"))
      (findfile (strcat app ".exe"))
      (findfile (strcat app ".arx"))
      (findfile app)
  )
)

(defun ai_nofile (filename)
  (princ
    (strcat "\nThe file "
            filename
            "(.lsp/.exe/.arx) was not found in your search path folders."
    )
  )
  (princ "\nCheck the installation of the support files and try again.")
  (princ)
)


;;;===== AutoLoad LISP Applications =====
;  Set help for those apps with a command line interface

(autoload "appload" '("appload" "appload"))

(autoload "edge"  '("edge"))
(setfunhelp "C:edge" "" "edge")

(autoload "filter" '("filter " "filter"))

(autoload "3d" '("3d" "3d" "ai_box" "ai_pyramid" "ai_wedge" "ai_dome"
                 "ai_mesh" "ai_sphere" "ai_cone" "ai_torus" "ai_dish")
)
(setfunhelp "C:3d" "" "3d")
(setfunhelp "C:ai_box" "" "3d_box")
(setfunhelp "C:ai_pyramid" "" "3d_pyramid")
(setfunhelp "C:ai__wedge" "" "3d_wedge")
(setfunhelp "C:ai_dome" "" "3d_dome")
(setfunhelp "C:ai_mesh" "" "3d_mesh")
(setfunhelp "C:ai_sphere" "" "3d_sphere")
(setfunhelp "C:ai_cone" "" "3d_cone")
(setfunhelp "C:ai_torus" "" "3d_torus")
(setfunhelp "C:ai_dish" "" "3d_dish")

(autoload "ddinsert" '("ddinsert"))

(autoload "ddattdef" '("ddattdef"))

(autoload "ddattext" '("ddattext"))

(autoload "3darray" '("3darray"))
(setfunhelp "C:3darray" "" "3darray")

(autoload "ddmodify" '("ddmodify"))

(autoload "ddchprop" '("ddchprop"))

(autoload "ddview" '("ddview"))

(autoload "ddvpoint" '("ddvpoint"))

(autoload "mvsetup" '("mvsetup"))
(setfunhelp "C:mvsetup" "" "mvsetup")

(autoload "ddosnap" '("ddosnap"))

(autoload "ddptype" '("ddptype"))

(autoload "dducsp" '("dducsp"))

(autoload "ddunits" '("ddunits"))

(autoload "ddgrips" '("ddgrips"))

(autoload "ddselect" '("ddselect"))

(autoload "ddrename" '("ddrename"))

(autoload "ddcolor" '("ddcolor"))

(autoload "bmake" '("bmake"))

(autoload "attredef" '("attredef"))
(setfunhelp "C:attredef" "" "attredef")

(autoload "xplode" '("xp" "xplode"))
(setfunhelp "C:xplode" "" "xplode")

(autoload "tutorial" '("tutdemo" "tutclear"
                                       "tutdemo"
                                       "tutclear"))

;; CalComp Configuration Command
(autoload "plpccw" '("cconfig"))


;;;===== AutoXLoad ADS Applications =====

(autoxload "hpmplot" ' ("hpconfig" "hpconfig" ))


;;;=========AutoArxLoad OCE Driver ARX applications ===========

(autoarxload "oceconf" '("oceconfig" "oceconfig"))

;;;===== AutoArxLoad Arx Applications =====

(autoarxload "geomcal" '("cal" "cal"))

(autoarxload "geom3d" '("mirror3d" "rotate3d" "align"
                      "mirror3d" "rotate3d"
                                 "align"))


;;; ===== Double byte character handling functions =====

(defun is_lead_byte(code)
    (setq asia_cd (getvar "dwgcodepage"))
    (cond
        ( (or (= asia_cd "dos932")
              (= asia_cd "ANSI_932")
          )
          (or (and (<= 129 code) (<= code 159))
              (and (<= 224 code) (<= code 252))
          )
        )
        ( (or (= asia_cd "big5")
              (= asia_cd "ANSI_950")
          )
          (and (<= 161 code) (<= code 254))
        )
        ( (or (= asia_cd "johab")
              (= asia_cd "ANSI_1361")
          )
          (and (<= 132 code) (<= code 211))
        )
        ( (or (= asia_cd "ksc5601")
              (= asia_cd "ANSI_949")
          )
          (and (<= 161 code) (<= code 253))
        )
    )
)

;;; ====================================================


;;;
;;;  FITSTR2LEN
;;;
;;;  Truncates the given string to the given length.
;;;  This function should be used to fit symbol table names, that
;;;  may turn into \U+ sequences into a given size to be displayed
;;;  inside a dialog box.
;;;
;;;  Ex: the following string:
;;;
;;;      "This is a long string that will not fit into a 32 character static text box."
;;;
;;;      would display as a 32 character long string as follows:
;;;
;;;      "This is a long...tatic text box."
;;;

(defun fitstr2len (str1 maxlen)

    ;;; initialize internals
    (setq tmpstr str1)
    (setq len (strlen tmpstr))

    (if (> len maxlen)
         (progn
            (setq maxlen2 (/ maxlen 2))
            (if (> maxlen (* maxlen2 2))
                 (setq maxlen2 (- maxlen2 1))
            )
            (if (is_lead_byte (substr tmpstr (- maxlen2 2) 1))
                 (setq tmpstr1 (substr tmpstr 1 (- maxlen2 3)))
                 (setq tmpstr1 (substr tmpstr 1 (- maxlen2 2)))
            )
            (if (is_lead_byte (substr tmpstr (- len (- maxlen2 1)) 1))
                 (setq tmpstr2 (substr tmpstr (- len (- maxlen2 3))))
                 (setq tmpstr2 (substr tmpstr (- len (- maxlen2 2))))
            )
            (setq str2 (strcat tmpstr1 "..." tmpstr2))
         ) ;;; progn
         (setq str2 (strcat tmpstr))
    ) ;;; if
) ;;; defun


;;;
;;;  If the first object in a selection set has an attached URL
;;;  Then launch browser and point to the URL.
;;;  Called by the Grips Cursor Menu
;;;

(defun C:gotourl ( / ssurl url i)
   (setq m:err *error* *error* *merrmsg* i 0)

; if some objects are not already pickfirst selected,
; then allow objects to be selected

  (if (not (setq ssurl (ssget "I")))
      (setq ssurl (ssget))
  )

; if geturl LISP command not found then load arx application

  (if (/= (type geturl) 'EXRXSUBR)
    (arxload "dwfout")
  )
  
;  Search list for first object with an URL
  (while (and (= url nil) (< i (sslength ssurl)))
    (setq url (geturl (ssname ssurl i))
          i (1+ i))
  )

; If an URL has be found, open browser and point to URL
  (if (= url nil)
    (alert "No Universal Resource Locator associated with the object.")
    (command "_.browser" url)
  )

  (setq *error* m:err m:err nil)
  (princ)

)

;; Used by the import dialog to silently load a 3ds file
(defun import3ds (filename / filedia_old render)
  ;; Load Render if not loaded
  (setq render (findfile "render.arx"))
  (if render
    (verify_arxapp_loaded render)
    (quit)
  )

  ;; Save current filedia & cmdecho setting.
  (setq filedia-save (getvar "FILEDIA"))
  (setq cmdecho-save (getvar "CMDECHO"))
  (setvar "FILEDIA" 0)
  (setvar "CMDECHO" 0)

  ;; Call 3DSIN and pass in filename.
  (c:3dsin 1 filename)

  ;; Reset filedia & cmdecho
  (setvar "FILEDIA" filedia-save)
  (setvar "CMDECHO" cmdecho-save)
  (princ)
)

;; Silent load.
(princ)

;; The following line loads the AutoLISP routines for AutoCAD Release 14.
;; Altering this line will affect the application's internet functionality.
(load "inet")
;; The following line conditionally loads AutoLISP routines for AutoCAD Release 14
;; Altering this line will affect bonus functionality
(load "bonus.lsp" "")


;;;===== SUPPORT for LISP =====

(setvar "ucsicon" 0)
(defun *error* (st)
    (terpri)
    (princ "\nerror: ")
    (princ st)
    (princ)
)

(defun brkl (/ cel ss ss2 ss4 E CC k mp kp mp0 mp1 kp0 kp1 pk1 pk2 pk3 pk0)
  (setq ss (ssget "C" pt1 pt3))
  (RMV)
  (RMVE)
  (SETQ CEC (GETVAR "CECOLOR"))
  (SETQ ss2 (SSGET PT2))
  (setq ss4 (ssget (polar pt2 (+ ang1 (dtr 180)) d2)))
  (SETQ E (ENTGET (SSNAME ss2 0)))
  (SETQ CC (CDR (ASSOC 62 E)))
  (SETQ cel (CDR (ASSOC 8 E)))
  (ssdel (ssname ss2 0) ss)
  (ssdel (ssname ss4 0) ss)
  (setvar "cmdecho" 0)
  (command "break" (ssname ss2 0) pt1 pt2)
  (command "break" (ssname ss4 0) pt3 (polar pt3 ang d1))
  (setq mp0 (cdr (assoc 10 (entget (ssname ss 0))))
        kp0 (cdr (assoc 11 (entget (ssname ss 0)))))
  (setq mp1 (cdr (assoc 10 (entget (ssname ss 1))))
        kp1 (cdr (assoc 11 (entget (ssname ss 1)))))
  (setq pk0 (inters mp0 kp0 pt1 pt3)
        pk1 (inters mp1 kp1 pt1 pt3))
  (setq pk0 (polar pk0 (+ ang (dtr 180)) 90)
        pk1 (polar pk1 (+ ang (dtr 180)) 90))
  (setq pk2 (polar pk0 ang (+ d1 180))
        pk3 (polar pk1 ang (+ d1 180)))
  (command "break" (ssname ss 0) pk0 pk2)
  (command "break" (ssname ss 1) pk1 pk3)
  (SETLAY cel)
  (COMMAND "COLOR" "BYLAYER" "")
  (command "LINE" pt1 pt3 "")
  (command "LINE" pt2 (polar pt3 ang d1) "")
  (command "LINE" pk0 pk1 "")
  (command "LINE" pk2 pk3 "")
  (COMMAND "COLOR" cec)
  (RTNLAY)
  (setvar "BLIPMODE" 0)
  (setvar "cmdecho" 0)
)

(defun brks (/ ss sse e cc cel ls no)
  (setq ss   (ssget "C" pt3 pt4))
  (RMV)
  (SETQ SSE (SSGET PT2))
  (SETQ E   (ENTGET (SSNAME SSE 0)))
  (SETQ CC  (CDR (ASSOC 62 E)))
  (setq cel (cdr (assoc 8 e)))
  (SETLAY cel)
  (COMMAND "COLOR" "BYLAYER" "")
  (command "LINE" pt1 pt3 "")
  (command "color" d1:col)
  (command "COPY" "L" "" pt1 pt2)
  (command "TRIM" "L" "P" "")
  (repeat ls
    (setq no (1+ no))
    (command (list (ssname ss no) pt4))
  )
  (command "")
  (RTNLAY)
  (setvar "cmdecho" 0)
  (setvar "blipmode" 0)
)

(defun CHGTERR (s)
    (if (/= s "Function cancelled")
        (princ (strcat "\nError: " s))
    )
    (setq p nil)
    (setq *error* olderr)
    (princ)
)

(defun dtr (a)
  (* pi (/ a 180.0)))

(defun rtd (a)
  (/ (* a 180.0) pi))

(defun RMT (/ k e ll)
  (setq k 0)
  (repeat (sslength ss)
    (setq e (entget (ssname ss k)))
    (setq ll (cdr (assoc 0 e)))
    (if (/= ll "TEXT")
      (ssdel (ssname ss k) ss) (setq k (1+ k)))
  )
)

(defun SLTY (ltype)
  (setvar "cmdecho" 0)
  (command "linetype" "s" ltype "")
  (setvar "cmdecho" 1)
  (princ (strcat ltype " is now the current linetype."))
  (princ)
)

(defun SLAY (lay)
  (setvar "cmdecho" 0)
  (command "layer" "m" lay "")
  (setvar "cmdecho" 1)
  (princ (strcat lay " is now the current layer."))
  (setvar "cmdecho" 0)
  (princ)
)

(defun SCOL (col)
  (setvar "cmdecho" 0)
  (command "color" col)
  (setvar "cmdecho" 1)
  (princ (strcat col " is now the current color."))
  (princ)
)

  (princ ".")

(DeFun SETLAY (NEWLAY)
  (setvar "cmdecho" 0)
  (SetQ OLDLAY (GetVar "CLAYER"))
  (Command "LAYER" "M" NEWLAY "")
)

(DeFun RTNLAY ()
  (Command "LAYER" "S" OLDLAY "")
  (setvar "cmdecho" 1)
  (setvar "blipmode" 1)
  (setvar "highlight" 1)
  (princ)
)
(DeFun SETLAY2 (NEWLAY)
  (setvar "cmdecho" 0)
  (SetQ OLDLAY (GetVar "CLAYER"))
  (Command "LAYER" "S" NEWLAY "")
)

(defun SELB ()
  (setq B (getstring "Select Block: "))
  (ssget "x" (list (cons 2 B)))
)
(defun SELCO ()
  (setq CO (getint "Number of Color: "))
  (ssget "x" (list (cons 62 CO)))
)
(defun SELL ()
  (setq LA (getstring "Layer Name: "))
  (ssget "x" (list (cons 8 LA)))
)
(defun SELLT ()
  (setq LT (getstring "Linetype Name: "))
  (ssget "x" (list (cons 6 LT)))
)
(defun RMD (/ k e ll)
    (setq k 0)
    (repeat (sslength ss)
            (setq e (entget (ssname ss k)))
            (setq ll (cdr (assoc 0 e)))
            (if (/= ll "DIMENSION")
                (ssdel (ssname ss k) ss)
                (setq k (1+ k))
            )
    )
)
(defun RMV (/ k e ll)
  (setq k 0)
  (repeat (sslength ss)
          (setq e (entget (ssname ss k)))
          (setq ll (cdr (assoc 8 e)))
          (if (or (= ll "CENTER")
                  (= ll "CEN")
              )
              (ssdel (ssname ss k) ss)
              (setq k (1+ k))
          )
  )
  (setq ls (sslength ss) no -1)
)

(defun RMVE (/ k e ll)
  (setq k 0)
  (repeat (sslength ss)
          (setq e (entget (ssname ss k)))
          (setq ll (cdr (assoc 0 e)))
          (if (/= ll "LINE")
              (ssdel (ssname ss k) ss)
              (setq k (1+ k))
          )
  )
  (setq ls (sslength ss) no -1)
)

(defun stysearch (style_n / n x s)
  (setq style_n (strcase style_n))
  (setq n 0)
  (setq x (tblnext "style" T))
  (while x
    (setq n (1+ n)
          s (fld_st 2 x)
    )
    (if (= s style_n)
      (setq x nil)
      (setq x (tblnext "style" nil))
    )
  )
  (if (or (= n 0) (/= s style_n)) nil s)
)

(defun udist (bit kwd msg def bpt / inp)
  (if def
    (setq msg (strcat "\n" msg " <" (rtos def) ">: ")
          bit (* 2 (fix (/ bit 2)))
    )
    (setq msg (strcat "\n" msg ": "))
  )
  (initget bit kwd)
  (setq inp
    (if bpt
       (getdist msg bpt)
       (getdist msg)
    )
  )
  (if inp inp def)
)

(defun upoint (bit kwd msg def bpt / inp)
   (if def
      (setq pts (strcat (rtos (car def)) "," (rtos (cadr def))
                        (if (and (caddr def) (= 0 (getvar "flatland")))
                            (strcat "," (rtos (caddr def)))
                            ""
                         )
                 )
             msg (strcat "\n" msg " <" pts ">: ")
             bit (* 2 (fix (/ bit 2)))
       )
       (setq msg (strcat "\n" msg ": "))
    )
    (initget bit kwd)
    (setq inp (if bpt
                  (getpoint msg bpt)
                  (getpoint msg)
              )
    )
    (if inp inp def)
)

;;;===== ONEKEY =====

(defun C:Z()      
       (command "zoom" "window") (prin1)
)
(defun C:ZA()
       (command "zoom" "all") (prin1)
)
(defun c:ZE()
       (command "zoom" "extents") (prin1)
)
(defun c:ZD()
    (command "zoom" "dynamic")(prin1)
)
(defun C:ZS()
       (command "zoom" "previous")(prin1)
)
(defun c:S()
       (command "stretch" "c") (prin1)
)
(defun c:DDF()
       (command "DDLMODES") (prin1)
)
(DEFUN C:CI()      
       (COMMAND "CIRCLE") (PRIN1)
)
(DEFUN C:MI()
       (COMMAND "MIRRTEXT" "0" "MIRROR") (PRIN1)
)
(DEFUN C:RR()
       (COMMAND "ROTATE") (PRIN1)
)
(DEFUN C:PO()
       (COMMAND "POLYGON") (PRIN1)
)
(DEFUN C:RE()
       (COMMAND "REGEN") (PRIN1)
)
(DEFUN C:F()
       (COMMAND "FILLET") (PRIN1)
)
(DEFUN C:FF()
       (COMMAND "FILLET" "C") (PRIN1)
)
(DEFUN C:HA()
       (COMMAND "HATCH") (PRIN1)
)
(DEFUN C:E()
       (COMMAND "ERASE") (PRIN1)
)
(DEFUN C:SC()
       (COMMAND "SCALE") (PRIN1)
)
(DEFUN C:I()
       (COMMAND "INSERT") (PRIN1)
)
(DEFUN C:ER()
       (COMMAND "EXPLODE") (PRIN1)
)
(DEFUN C:M()
       (COMMAND "MOVE") (PRIN1)
)
(DEFUN C:EX()      
       (COMMAND "EXTEND") (PRIN1)
)
(DEFUN C:CH()
       (COMMAND "CHANGE") (PRIN1)
)
(DEFUN C:LT()
       (COMMAND "LTSCALE") (PRIN1)
)
(DEFUN C:AA()
       (COMMAND "ARRAY") (PRIN1)
)
(DEFUN C:WB()
       (COMMAND "WBLOCK") (PRIN1)
)
(DEFUN C:T()
       (COMMAND "TRIM") (PRIN1)
)
(DEFUN C:MA()
       (COMMAND "menu" "acad.mnu") (PRIN1)
)
(DEFUN C:DI()
       (COMMAND "DIVIDE") (PRIN1)
)
(DEFUN C:ED()
       (COMMAND "DDEDIT") (PRIN1)
)
(DEFUN C:OI()
       (COMMAND "OSNAP" "INT") (PRIN1)
)
(DEFUN C:OM()
       (COMMAND "OSNAP" "MID") (PRIN1)
)
(DEFUN C:OS()
       (COMMAND "OSNAP" "INS") (PRIN1)
)
(DEFUN C:OC()        
       (COMMAND "OSNAP" "CEN") (PRIN1)
)
(DEFUN C:OE()
       (COMMAND "OSNAP" "END") (PRIN1)
)
(DEFUN C:OQ()
       (COMMAND "OSNAP" "QUA") (PRIN1)
)
(DEFUN C:ON()
       (COMMAND "OSNAP" "NODE") (PRIN1)
)
(DEFUN C:OO()
       (COMMAND "OSNAP" "NONE") (PRIN1)
)
(DEFUN C:O()
       (COMMAND "OFFSET") (PRIN1)
)
(DEFUN C:PE()
       (COMMAND "PEDIT") (PRIN1)
)
(DEFUN C:DS()
       (COMMAND "DIST") (PRIN1)
)
(DEFUN C:PA()
       (COMMAND "PURGE" "ALL") (PRIN1)
)
(DEFUN C:ST()
       (COMMAND "STYLE" "CGS") (PRIN1)
)
(DEFUN C:BL()
       (COMMAND "BLIPMODE" "OFF") (PRIN1)
)
(DEFUN C:Q()
       (COMMAND "QUIT") (PRIN1)
)
(DEFUN C:L()
       (COMMAND "LINE") (PRIN1)
)
(DEFUN C:EL()
       (COMMAND "ELLIPSE") (PRIN1)
)
(DEFUN C:PAN()
       (COMMAND "PAN") (PRIN1)
)
(DEFUN C:SK()
       (COMMAND "SKETCH") (PRIN1)
)        
(DEFUN C:SA()
       (COMMAND "SAVEAS") (PRIN1)
)        
(DEFUN C:DO()
       (COMMAND "DONUT") (PRIN1)
)        
(DEFUN C:LI()
       (COMMAND "LIST") (PRIN1)
)
(DEFUN C:PL()
       (COMMAND "PLOTCONFIGURATION") (PRIN1)
)
(DEFUN C:CF()
       (COMMAND "CHAMFER") (PRIN1)
)
(defun C:C()
       (setvar "cmdecho" 0)
       (princ " = MULTI COPY")
       (setq en (ssget))
       (COMMAND "COPY" en "" "M")
)
(DEFUN C:OOPS()
       (COMMAND "OOPS") (PRIN1)
)
(DEFUN C:LL()
       (COMMAND "LAYER" "LOCK" "A" "") (PRIN1)
)
(DEFUN C:LU()
       (COMMAND "LAYER" "UNLOCK" "*" "") (PRIN1)
)
(DEFUN C:LP()
       (COMMAND "LAYER" "LOCK" "P" "") (PRIN1)
)
(DEFUN C:LV()
       (COMMAND "LAYER" "LOCK" "V" "") (PRIN1)
)
(DEFUN C:LR()
       (COMMAND "LAYER" "LOCK" "R" "") (PRIN1)
)
(DEFUN C:LH()
       (COMMAND "LAYER" "LOCK" "H" "") (PRIN1)
)
(DEFUN C:LD()
       (COMMAND "LAYER" "LOCK" "D" "") (PRIN1)
)
(DEFUN C:LTE()
       (COMMAND "LAYER" "LOCK" "TE" "") (PRIN1)
)
(DEFUN C:LA()
       (COMMAND "LAYER" "LOCK" "A" "") (PRIN1)
)
(DEFUN C:LJ()
       (COMMAND "LAYER" "LOCK" "J" "") (PRIN1)
)
(DEFUN C:UP()
       (COMMAND "LAYER" "UNLOCK" "P" "") (PRIN1)
)
(DEFUN C:UV()
       (COMMAND "LAYER" "UNLOCK" "V" "") (PRIN1)
)
(DEFUN C:UH()
       (COMMAND "LAYER" "UNLOCK" "H" "") (PRIN1)
)
(DEFUN C:UJ()
       (COMMAND "LAYER" "UNLOCK" "J" "") (PRIN1)
)
(DEFUN C:UTE()
       (COMMAND "LAYER" "UNLOCK" "TE" "") (PRIN1)
)
(DEFUN C:US()
       (COMMAND "LAYER" "UNLOCK" "S" "") (PRIN1)
)
(DEFUN C:UR()
       (COMMAND "LAYER" "UNLOCK" "R" "") (PRIN1)
)
(DEFUN C:UH()
       (COMMAND "LAYER" "UNLOCK" "H" "") (PRIN1)
)
(DEFUN C:UD()
       (COMMAND "LAYER" "UNLOCK" "D" "") (PRIN1)
)
(DEFUN C:LU()
       (COMMAND "LAYER" "UNLOCK" "*" "") (PRIN1)
)
(DEFUN C:UV()
       (COMMAND "LAYER" "UNLOCK" "V" "") (PRIN1)
)

(defun c:R()
       (princ " = AUTO ")
       (setq ss (ssget))
       (command "change" "p" "" "p" "lA" "R" "C" "BYLAYER" "")
       (prin1)
)
(defun c:H()
       (princ " = AUTO ")
       (setq ss (ssget))
       (command "change" "p" "" "p" "lA" "H" "C" "BYLAYER" "")
       (prin1)
)

(defun c:J()
       (princ " = AUTO ")
       (setq ss (ssget))
       (command "change" "p" "" "p" "lA" "J" "C" "BYLAYER" "")
       (prin1)
)

(defun c:TE()
       (princ " = AUTO ")
       (setq ss (ssget))
       (command "change" "p" "" "p" "lA" "TE" "C" "BYLAYER" "")
       (prin1)
)

(defun c:D()
       (princ " = AUTO ")
       (setq ss (ssget))
       (command "change" "p" "" "p" "lA" "D" "C" "BYLAYER" "")
       (prin1)
)

(defun c:A()
       (princ " = AUTO ")
       (setq ss (ssget))
       (command "change" "p" "" "p" "lA" "A" "C" "BYLAYER" "")
       (prin1)
)

(defun c:V()
       (princ " = AUTO ")
       (setq ss (ssget))
       (command "change" "P" "" "p" "lA" "V" "C" "BYLAYER" "LT" "DASHED" "")
       (prin1)
)
(defun c:P()
       (princ " = AUTO ")
       (setq ss (ssget))
       (command "change" "P" "" "p" "lA" "P" "C" "BYLAYER" "")
       (prin1)
)
(defun c:S()
       (princ " = AUTO ")
       (setq ss (ssget))
       (command "change" "P" "" "p" "lA" "S" "C" "BYLAYER" "")
       (prin1)
)
(defun c:DAS()
       (princ " = AUTO ")
       (setq ss (ssget))
       (command "change" "P" "" "p" "LT" "DASHED" "")
       (prin1)
)
(defun c:HID()
       (princ " = AUTO ")
       (setq ss (ssget))
       (command "change" "P" "" "p" "LT" "HIDDEN" "")
       (prin1)
)
(defun c:CE()
       (princ " = AUTO ")
0       (setq ss (ssget))
       (command "change" "P" "" "p" "LT" "CENTERX2" "")
       (prin1)
)
(defun c:PP()
       (princ " = AUTO ")
       (setq ss (ssget))
       (command "change" "p" "" "p" "C" "BYLAYER" "")
       (prin1)
)

(defun c:HL()
       (princ " = AUTO ")
       (setq ss (ssget))
       (setq SP
       (getint "\>> SCALE PATTEN: "))
       (command "HATCH" "LINE" SP "45" "P" "")
       (prin1)
)

(defun c:HD()
       (princ " = AUTO ")
       (setq ss (ssget))
       (setq SP
       (getint "\>> SCALE PATTEN: "))
       (command "HATCH" "DOTS" SP "" "P" "")
       (prin1)
)          

;;;===== NEW COMMAND =====

(defun initload (name)
    (princ "\n Initializing .....")
    (load name)
)
(DEFUN C:LL1 ()
  (INITLOAD "LL1") (C:LL1))
(DEFUN C:LL2 ()
  (INITLOAD "LL2") (C:LL2))
(DEFUN C:LL3 ()
  (INITLOAD "LL3") (C:LL3))
(DEFUN C:LL4 ()
  (INITLOAD "LL4") (C:LL4))
(DEFUN C:LL5 ()
  (INITLOAD "LL5") (C:LL5))
(DEFUN C:LL6 ()
  (INITLOAD "LL6") (C:LL6))
(DEFUN C:LL7 ()
  (INITLOAD "LL7") (C:LL7))
(DEFUN C:LL8 ()
  (INITLOAD "LL8") (C:LL8))
(DEFUN C:LL9 ()
  (INITLOAD "LL9") (C:LL9))
(DEFUN C:LL10 ()
  (INITLOAD "LL10") (C:LL10))
(DEFUN C:K ()
  (INITLOAD "K") (C:K))
(DEFUN C:X ()
  (INITLOAD "X") (C:X))
(DEFUN C:T3 ()
  (INITLOAD "T3") (C:T3))
(DEFUN C:BB ()
  (INITLOAD "BB") (C:BB))
(DEFUN C:LS ()
  (INITLOAD "LS") (C:LS))
(DEFUN C:LC ()
  (INITLOAD "LC") (C:LC))
(DEFUN C:LF ()
  (INITLOAD "LF") (C:LF))
(DEFUN C:LFF ()
  (INITLOAD "LFF") (C:LFF))
(DEFUN C:LO ()
  (INITLOAD "LO") (C:LO))
(DEFUN C:B ()
  (INITLOAD "B") (C:B))
(DEFUN C:TC ()
  (INITLOAD "TC") (C:TC))
(DEFUN C:CT ()
  (INITLOAD "CT") (C:CT))
(DEFUN C:TST ()
  (INITLOAD "TST") (C:TST))
(DEFUN C:DL ()
  (INITLOAD "DL") (C:DL))
(DEFUN C:SS ()
  (INITLOAD "SS") (C:SS))
(defun c:ddptype ()
  (initload "ddptype") (c:ddptype))
(DEFUN C:CUST ()
  (INITLOAD "CUST") (C:CUST))
(LOAD "ERR")
(LOAD "ee")
(LOAD "TT")
(LOAD "COIL")
(LOAD "COIL2")
(LOAD "LM")
(load "fl240")
(LOAD "EFL240")
(LOAD "PO1")
(LOAD "MO")
(defun EXPD (/ en k e ll)
  (while (/= en "OK")
         (setq k 0)
         (repeat (sslength ss)
                 (setq e (entget (ssname ss k)))
                 (setq ll (cdr (assoc 0 e)))
                 (if (or (and (= ll "INSERT")
                              (= (cdr (assoc 41 e))
                                 (cdr (assoc 42 e))
                              )
                         )
                         (= ll "POLYLINE")
                     )
                     (command "explode" (ssname ss k))
                     (setq en "OK")
                 )
                 (setq k (1+ k))
         )
         (setq ss (ssget "C" p1 p2))
  )
)

; AutoMASTER R12 code
(autoload "ampref"  '("ampref"))
(autoload "amsetup" '("amsetup"))
(autoload "amabout" '("amabout"))
(autoload "amshow"  '("amshow"))
(princ)

(DEFUN S::STARTUP()
(SETVAR "CMDECHO" 0)
(COMMAND "PURGE" "A" "Y")
)