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

  1. ;;;   CHBlock.lsp
  2. ;;;   Copyright (C) 1990 by Autodesk, Inc.
  3. ;;;  
  4. ;;;   Permission to use, copy, modify, and distribute this software and its
  5. ;;;   documentation for any purpose and without fee is hereby granted.  
  6. ;;;
  7. ;;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. 
  8. ;;;   ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF 
  9. ;;;   MERCHANTABILITY ARE HEREBY DISCLAIMED.
  10. ;;; 
  11. ;;;   by Jan S. Yoder
  12. ;;;   01 February 1990
  13. ;;;
  14. ;;;--------------------------------------------------------------------------;
  15. ;;; DESCRIPTION
  16. ;;;   Change the X, Y, or Z block scales independently.
  17. ;;;   Also changes to the insertion point and rotation angle are allowed.
  18. ;;;   Either of these operations may be done by dragging an instance of
  19. ;;;   the block on-screen or by specifying real values.
  20. ;;;
  21. ;;;   Multiple entitites may be selected for manipulation;  they will be
  22. ;;;   accessible one at a time in the order of selection.
  23. ;;;
  24. ;;;      BLOCK SCALES:  X - 1.0  Y - 1.0  Z - 1.0
  25. ;;;      Change scale. All/X/Y/Z/<Exit>: 
  26. ;;;--------------------------------------------------------------------------;
  27.  
  28. (defun cs (/ cb_ver temp temp1 ename ent x y z) ; change block scales
  29.  
  30.   (setq cb_ver "1.00")                ; Reset this local if you make a change.
  31.  
  32.   ;;
  33.   ;; Internal error handler defined locally
  34.   ;;
  35.   (defun chb_er (s)                   ; If an error (such as CTRL-C) occurs
  36.                                       ; while this command is active...
  37.     (if (/= s "Function cancelled")
  38.       (if (= s "quit / exit abort")
  39.         (princ)
  40.         (princ (strcat "\nError: " s))
  41.       )
  42.     )
  43.     (command "undo" "end")
  44.     (if chb_oe                        ; If an old error routine exists
  45.       (setq *error* chb_oe)           ; then, reset it 
  46.     )
  47.     (setvar "cmdecho" chb_oc)         ; Reset command echoing on error
  48.     (princ)
  49.   )
  50.   
  51.   (if *error*                         ; Set our new error handler
  52.     (setq chb_oe *error* *error* chb_er) 
  53.     (setq *error* chb_er) 
  54.   )
  55.  
  56.   (setq chb_oc (getvar "cmdecho"))
  57.   (setvar "cmdecho" 0)
  58.   
  59.  
  60.   (princ (strcat "\nChange block,  Version " cb_ver
  61.                   ", (c) 1990 by Autodesk, Inc. "))
  62.   (setq sset (ssget)
  63.         ssl  (if sset (sslength sset) 0)
  64.   )
  65.   (while (and sset (> (setq ssl (1- ssl)) -1))
  66.     (setq ent (entget (setq ename (ssname sset ssl))))
  67.     (if (= (cdr(assoc 0 ent)) "INSERT")
  68.       (setq x   (cdr(assoc 41 ent))
  69.             y   (cdr(assoc 42 ent))
  70.             z   (cdr(assoc 43 ent))
  71.             temp nil
  72.       )
  73.       (setq temp "Exit") ; skip this entity
  74.     )
  75.     (if (null temp)
  76.       (if temp1
  77.         (princ "\nNext object...")
  78.         (progn
  79.           (setq temp1 T)
  80.           (princ "\nFirst object...")
  81.         )
  82.       )
  83.     )  
  84.     (while (and (= (cdr(assoc 0 ent)) "INSERT") (not (= temp "Exit")))
  85.       (command "undo" "group")
  86.       (redraw ename 3)
  87.       
  88.       (princ "\nInsertion point/Rotation/Scale/<Exit>: ")
  89.       (initget "Insertion Rotation Scale Exit")
  90.       (setq temp (getkword))
  91.       (cond
  92.         ((= temp "Insertion")
  93.           (command "move" ename "" (cdr(assoc 10 ent)) pause)
  94.           (setq ent (entget ename))
  95.         )
  96.         ((= temp "Rotation")
  97.           (command "rotate" ename "" (cdr(assoc 10 ent)))
  98.           (princ (strcat
  99.             "\nNew rotation angle <" (angtos (cdr(assoc 50 ent))) ">: "))
  100.           (command pause)
  101.           (setq ent (entget ename))
  102.         )
  103.         ((= temp "Scale")
  104.           (while (/= temp "Exit")
  105.             (princ (strcat "\nBLOCK SCALES: \tX - " (rtos x)
  106.                                            "\tY - " (rtos y)
  107.                                            "\tZ - " (rtos z)))
  108.             (princ "\nChange scale. All/X/Y/Z/<Exit>: ")
  109.             (initget "All X Y Z Exit")
  110.             (setq temp (getkword))
  111.             (cond
  112.               ((= temp "X")
  113.                 (setq x (getdist (strcat "\nNew X scale <" (rtos x) ">: ")))
  114.                 (setq ent (subst (cons 41 x) (assoc 41 ent) ent))
  115.               )
  116.               ((= temp "Y")
  117.                 (setq y (getdist (strcat "\nNew Y scale <" (rtos y) ">: ")))
  118.                 (setq ent (subst (cons 42 y) (assoc 42 ent) ent))
  119.               )
  120.               ((= temp "Z")
  121.                 (setq z (getdist (strcat "\nNew Z scale <" (rtos z) ">: ")))
  122.                 (setq ent (subst (cons 43 z) (assoc 43 ent) ent))
  123.               )
  124.               ((= temp "All")
  125.                 (initget "X Y Z Exit")
  126.                 (setq scale (getdist (strcat 
  127.                   "\nNew global scale X/Y/Z/<" (rtos x) ">: ")))
  128.                 (cond
  129.                   ((= scale "Y") (setq scale y))
  130.                   ((= scale "Z") (setq scale z))
  131.                   ((= (type scale) 'REAL) (princ))
  132.                   (T             (setq scale x))
  133.                 )
  134.                 (setq x scale
  135.                       y scale
  136.                       z scale
  137.                 )
  138.                 (setq ent (subst (cons 41 x) (assoc 41 ent) ent)
  139.                       ent (subst (cons 42 y) (assoc 42 ent) ent)
  140.                       ent (subst (cons 43 z) (assoc 43 ent) ent)
  141.                 )
  142.               )
  143.               (T
  144.                 (setq temp "Exit")
  145.               )
  146.             )
  147.             (entmod ent)
  148.           )
  149.           (setq temp T)
  150.         )
  151.         (T
  152.           (setq temp "Exit")
  153.           (redraw ename 4)
  154.         )
  155.       )
  156.     )
  157.   )
  158.   (command "select" sset "")
  159.   (command "undo" "end")
  160.   (setvar "cmdecho" chb_oc)         ; Reset command echoing on error
  161.   (princ)
  162. )
  163. (defun c:chb  () (cs) ) ; change block scales
  164. (princ "\n\tC:CHBlock loaded.  Start command with CHB.")
  165. (princ)
  166.