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

  1. ;;; -----------------------------------------------------------------------
  2. ;;; CHFACE.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 Jan S. Yoder                                 April 22, 1988
  13. ;;;
  14. ;;; -----------------------------------------------------------------------
  15. ;;; DESCRIPTION
  16. ;;;
  17. ;;;   A routine to change the end point locations of 3dfaces by pointing.
  18. ;;;
  19. ;;;   Undo backs up one face at a time, regardless of the number processed.
  20. ;;;
  21. ;;;   Version 0.3
  22. ;;;
  23. ;;; -----------------------------------------------------------------------  
  24.  
  25. ;;; Internal error handler
  26.  
  27. (defun myerr (s)                      ; If an error (such as CTRL-C) occurs
  28.   ;; while this command is active...
  29.   (if (/= s "Function cancelled") 
  30.     (princ (strcat "\nError: " s))
  31.   ) 
  32.   (redraw ent 1) 
  33.   (command "undo" "e") 
  34.   (setvar "osmode" osm)               ; restore old OSNAP value
  35.   (setvar "blipmode" obm)             ; restore old BLIPMODE value
  36.   (setvar "cmdecho" ocmd)             ; restore old CMDECHO value
  37.   (setq *error* olderr)               ; restore old *error* handler
  38.   (princ)
  39.  
  40. ;;; Move the vertex
  41.  
  42. (defun mvvtx (v opt) 
  43.   (initget 16) 
  44.   (setq npt (getpoint opt "\nNew location: "))
  45.   (if (= (type npt) 'LIST) 
  46.     (progn
  47.       (setq entl (subst (cons v (trans npt 1 0)) (assoc v entl) entl))
  48.       (entmod entl)
  49.     )
  50.   )
  51.  
  52. ;;; Allow selection of 3dfaces to redraw while editing
  53.  
  54. (defun disply (/ ss n1 t1) 
  55.   (cond (ss (princ "\nRedrawing entities...") 
  56.             (repeat (sslength ss) 
  57.               (ssadd (setq t1 (ssname ss (setq n1 (1+ n1)))) faclst)
  58.             ) 
  59.             (princ "done.") 
  60.          T)                           ; return T
  61.   )
  62.  
  63. ;;; Find the vertex by pointing
  64.  
  65. (defun findpt () 
  66.   (foreach n '(10 11 12 13) (if (equal ans (cdr (assoc n entl))) 
  67.                               (setq savn n)
  68.                             )
  69.   ) 
  70.   savn
  71.  
  72. ;;; --------------------------- Main program ---------------------------------;
  73.  
  74. (defun C:CHFACE (/ splfo osm rg ent oflags entvtx1 entvtx2 entvtx3 entvtx4 ans 
  75.                    flags tst test
  76.                 ) 
  77.   (setq olderr *error* 
  78.         *error* myerr)
  79.   (setq ocmd (getvar "cmdecho"))      ; save old CMDECHO value
  80.   (setvar "cmdecho" 0)                ; set CMDECHO off
  81.   (setq osm (getvar "osmode"))        ; save old OSNAP value
  82.   (setq obm (getvar "blipmode"))      ; save old BLIPMODE value
  83.   (setvar "blipmode" 0)               ; set BLIPMODE to off
  84.   (setq cont "Yes")                   ; Get all the faces in the database
  85.   (setq fcs (ssget "x" '((0 . "3DFACE"))))
  86.   (setq test T 
  87.         ent nil 
  88.         xit T)
  89.   (while test 
  90.     (setq ent (car (entsel "\nSelect the entity to change: ")))
  91.     (if (equal ent nil) 
  92.       (princ "\nNo entity selected.  Please try again. ") 
  93.       (progn
  94.         (setq savent ent 
  95.               entl (entget ent))
  96.         (if (equal (cdr (assoc 0 entl)) "3DFACE") 
  97.           (setq test nil)
  98.           (princ "\nEntity selected is not a 3Dface. ")
  99.         )
  100.       )
  101.     )
  102.   ) 
  103.   (setvar "osmode" 1)                 ; set osmode to endpoint
  104.   (while xit 
  105.     (command "undo" "group") 
  106.     (disply) 
  107.     (redraw ent 3) 
  108.     (initget "1 2 3 4 Undo Display") 
  109.     (setq ans (getpoint "\n1/2/3/4/Undo/Display/<Select vertex>: "))
  110.     (cond ((= ans "1") (setq entvtx (trans (cdr (assoc 10 entl)) 0 1))
  111.        (mvvtx 10 entvtx)
  112.       ) 
  113.       ((= ans "2") (setq entvtx (trans (cdr (assoc 11 entl)) 0 1))
  114.        (mvvtx 11 entvtx)
  115.       ) 
  116.       ((= ans "3") (setq entvtx (trans (cdr (assoc 12 entl)) 0 1))
  117.        (mvvtx 12 entvtx)
  118.       ) 
  119.       ((= ans "4") (setq entvtx (trans (cdr (assoc 13 entl)) 0 1))
  120.        (mvvtx 13 entvtx)
  121.       ) 
  122.       ((= ans "Undo") (command "undo" "e") 
  123.        (command "undo" "3") 
  124.        (setq ent savent 
  125.              entl (entget ent))       ; restore saved entity
  126.       ) 
  127.       ((= ans "Display") (initget "All Select") 
  128.        (setq ss (if (eq (setq ans (getkword "\nSelect/<All>: "))
  129.                         "Select"
  130.                     ) 
  131.                   (ssget)
  132.                 ) 
  133.              n1 -1)
  134.        (if (= ans "Select") 
  135.          (disply) 
  136.          (redraw)
  137.        )
  138.       ) 
  139.       ((= (type ans) 'LIST) (setq n (findpt) 
  140.                                   entvtx (trans (cdr (assoc n entl)) 0 1))
  141.        (mvvtx n entvtx)
  142.       ) 
  143.       ((or (= ans "") (= ans nil)) (setq xit nil)
  144.        (redraw ent 1) 
  145.        (command "undo" "e") 
  146.        (setvar "osmode" osm)          ; restore old OSNAP value
  147.        (setvar "blipmode" obm)        ; restore old BLIPMODE value
  148.        (setvar "cmdecho" ocmd)        ; restore old CMDECHO value
  149.        (setq *error* olderr)          ; restore old *error* handler
  150.        (princ)
  151.       )
  152.     )
  153.   )
  154.  
  155. ;;; -----------------------------------------------------------------------
  156.  
  157.