home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p024 / 5.img / R11SUPP.EXE / CL.LSP < prev    next >
Encoding:
Lisp/Scheme  |  1990-07-30  |  4.3 KB  |  132 lines

  1. ;;; --------------------------------------------------------------------------;
  2. ;;; CL.LSP
  3. ;;;   Copyright (C) 1990 by Autodesk, Inc.
  4. ;;;  
  5. ;;;   Permission to use, copy, modify, and distribute this software and its
  6. ;;;   documentation for any purpose and without fee is hereby granted.  
  7. ;;;
  8. ;;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. 
  9. ;;;   ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF 
  10. ;;;   MERCHANTABILITY ARE HEREBY DISCLAIMED.
  11. ;;;
  12. ;;;   By Simon Jones    Autodesk Ltd , London      March 1987
  13. ;;;
  14. ;;; --------------------------------------------------------------------------;
  15. ;;; DESCRIPTION
  16. ;;;
  17. ;;;  This macro constructs a pair of center lines through the
  18. ;;;  center of a circle. The lines are put on a layer "CL".
  19. ;;;
  20. ;;; --------------------------------------------------------------------------;
  21.  
  22. (defun clerr (s) 
  23.   (if (/= s "Function cancelled")     ; If an error (such as CTRL-C) occurs
  24.     (princ (strcat "\nError: " s))    ; while this command is active...
  25.   ) 
  26.   (command "UCS" "P")                 ; Restore previous UCS
  27.   (setvar "BLIPMODE" sblip)           ; Restore saved modes
  28.   (setvar "GRIDMODE" sgrid)
  29.   (setvar "HIGHLIGHT" shl)
  30.   (setvar "UCSFOLLOW" sucsf)
  31.   (command "LAYER" "S" clay "") 
  32.   (command "undo" "e") 
  33.   (setvar "CMDECHO" scmde)
  34.   (setq *error* olderr)               ; Restore old *error* handler
  35.   (princ)                             
  36.  
  37. ;;; --------------------------- Main Program ---------------------------------;
  38.  
  39. (defun C:CL (/ olderr clay sblip scmde sgrid shl sucsf e cen rad d ts xx) 
  40.   (setq olderr *error* 
  41.         *error* clerr)
  42.   (setq scmde (getvar "CMDECHO"))
  43.   (command "undo" "group") 
  44.   (setq clay (getvar "CLAYER"))
  45.   (setq sblip (getvar "BLIPMODE"))
  46.   (setq sgrid (getvar "GRIDMODE"))
  47.   (setq shl (getvar "HIGHLIGHT"))
  48.   (setq sucsf (getvar "UCSFOLLOW"))
  49.   (setvar "CMDECHO" 0)
  50.   (setvar "GRIDMODE" 0)
  51.   (setvar "UCSFOLLOW" 0)
  52.   (setq e nil 
  53.         xx "Yes")
  54.   (setq ts (tblsearch "LAYER" "CL"))
  55.   (if (null ts) 
  56.     (prompt "\nCreating new layer - CL. ") 
  57.     (progn
  58.       (if (= (logand 1 (cdr (assoc 70 ts))) 1) 
  59.         (progn
  60.           (prompt "\nLayer CL is frozen. ") 
  61.           (initget "Yes No") 
  62.           (setq xx (getkword "\nProceed? <N>: "))
  63.           (if (= xx "Yes") 
  64.             (command "LAYER" "T" "CL" "")
  65.           )
  66.         )
  67.       )
  68.     )
  69.   ) 
  70.   (if (= xx "Yes") 
  71.     (progn
  72.       (while (null e) 
  73.         (setq e (entsel "\nSelect arc or circle: "))
  74.         (if e 
  75.           (progn
  76.             (setq e (car e))
  77.             (if (and (/= 
  78.                          (cdr (assoc 0 (entget e))) "ARC") 
  79.                          (/= (cdr (assoc 0 (entget e))) "CIRCLE")
  80.                 ) 
  81.               (progn
  82.                 (prompt "\nEntity is a ") 
  83.                 (princ (cdr (assoc 0 (entget e)))) 
  84.                 (setq e nil)
  85.               )
  86.             )
  87.           )
  88.         )
  89.       ) 
  90.       (command "UCS" "e" e) 
  91.       (setq cen (trans (cdr (assoc 10 (entget e))) e 1))
  92.       (setq rad (cdr (assoc 40 (entget e))))
  93.       (prompt "\nRadius is ") 
  94.       (princ (rtos rad)) 
  95.       (initget 7 "Length") 
  96.       (setq d (getdist "\nLength/<Extension>: "))
  97.       (if (= d "Length") 
  98.         (progn
  99.           (initget 7) 
  100.           (setq d (getdist cen "\nLength: "))
  101.         ) 
  102.         (setq d (+ rad d))
  103.       ) 
  104.       (setvar "BLIPMODE" 0)
  105.       (setvar "HIGHLIGHT" 0)
  106.       (command "LAYER" "M" "CL" "") 
  107.       (command "LINE" (list (car cen) (- (cadr cen) d) (caddr cen)) 
  108.                (list (car cen) (+ (cadr cen) d) (caddr cen)) ""
  109.       ) 
  110.       (command "CHANGE" "l" "" "P" "LT" "CENTER" "") 
  111.       (command "LINE" (list (- (car cen) d) (cadr cen) (caddr cen)) 
  112.                (list (+ (car cen) d) (cadr cen) (caddr cen)) ""
  113.       ) 
  114.       (command "CHANGE" "l" "" "P" "LT" "CENTER" "") 
  115.       (command "LAYER" "S" clay "")
  116.     )
  117.   ) 
  118.   (command "UCS" "P")                 ; Restore previous UCS
  119.   (setvar "BLIPMODE" sblip)           ; Restore saved modes
  120.   (setvar "GRIDMODE" sgrid)
  121.   (setvar "HIGHLIGHT" shl)
  122.   (setvar "UCSFOLLOW" sucsf)
  123.   (command "undo" "e") 
  124.   (setvar "CMDECHO" scmde)
  125.   (setq *error* olderr)               ; Restore old *error* handler
  126.   (princ)
  127.  
  128. ;;; --------------------------------------------------------------------------;
  129.  
  130.