home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / games / misc_lsp.zip / P-SURF.LSP < prev    next >
Lisp/Scheme  |  1987-08-26  |  3KB  |  115 lines

  1. ;============================ P-SURF.LSP ================================
  2. ;
  3. ;  Patch surface routine for use with AutoCAD Version 2.6 and later
  4. ;
  5. ;  Written by John Lynch   November, 1986
  6. ;
  7.  
  8. ;---------------------- VECTOR() -----------------------------
  9. ; Function to determine a vector between two points and divided by m.
  10. ;
  11. (defun vector (ep bp m / x1 x2 y1 y2 z1 z2 dx dy dz)
  12. ;
  13. ; bp : The beginnning point of the line.
  14. ; ep : The end point of the line.
  15. ; m  : The number of divisions in the line.
  16. ;
  17.   (setq x1 (car bp)
  18.         y1 (cadr bp)
  19.         z1 (caddr bp)
  20.   )
  21.   (setq x2 (car ep)
  22.         y2 (cadr ep)
  23.         z2 (caddr ep)
  24.   )
  25.   (setq dx (/ (- x2 x1) m)
  26.         dy (/ (- y2 y1) m)
  27.         dz (/ (- z2 z1) m)
  28.   )
  29.   (list dx dy dz)
  30. )
  31.  
  32. ;-----------------------------VECTADD() ------------------------------
  33. ;  Function to add a vector to a point.
  34. ;
  35. (defun vectadd (bp vec / x1 x2 y1 y2 z1 z2 dx dy dz)
  36. ;
  37. ; bp  : Beginning point assumed to be a list of three reals.
  38. ; vec : Vector to add to the point assumed to be the same.
  39. ;
  40.   (setq x1 (car bp)
  41.         y1 (cadr bp)
  42.         z1 (caddr bp)
  43.   )
  44.   (setq x2 (car vec)
  45.         y2 (cadr vec)
  46.         z2 (caddr vec)
  47.   )
  48.   (setq dx (+ x1 x2)
  49.         dy (+ y1 y2)
  50.         dz (+ z1 z2)
  51.   )
  52.   (list dx dy dz)
  53. )
  54.  
  55. ;---------------------------------------------------------------------
  56. ; P-SURF command, main program
  57.  
  58. (defun C:P-SURF ()
  59.   (setq fl (entget (car (entsel "\nPoint to first line: "))))
  60.   (setq sl (entget (car (entsel "\nPoint to second line: "))))
  61.  
  62.   (initget (+ 1 2 4))           ; Disallow null, zero, negative replies
  63.   (setq nrow (getint "\nEnter number of faces ALONG lines: "))
  64.   (initget (+ 1 2 4))
  65.   (setq ncol (getint "\nEnter number of faces BETWEEN lines: "))
  66.   (setvar "cmdecho" 0)
  67.   (setvar "blipmode" 0)
  68.  
  69.   ; Initialize the beginning points and determine the vectors along the lines.
  70.  
  71.   (setq bp1 (cdr (assoc 10 fl))
  72.         ep1 (cdr (assoc 11 fl))
  73.         bp2 (cdr (assoc 10 sl))
  74.         ep2 (cdr (assoc 11 sl))
  75.         vl1 (vector ep1 bp1 nrow)
  76.         vl2 (vector ep2 bp2 nrow)
  77.         vpl1 (vector bp2 bp1 ncol)
  78.   )
  79.  
  80.   (setq m 1)
  81.   (while (<= m nrow)
  82.  
  83.      (setq pl1 (vectadd bp1 vl1)
  84.            pl2 (vectadd bp2 vl2)
  85.            vpl2 (vector pl2 pl1 ncol)
  86.      )
  87.  
  88.      ; ---- Initialize the face points
  89.  
  90.      (setq lpp1 bp1
  91.            lpp2 pl1
  92.            n 1
  93.      )
  94.  
  95.      (while (<= n ncol)
  96.         (setq upp1 (vectadd lpp1 vpl1)
  97.               upp2 (vectadd lpp2 vpl2)
  98.         )
  99.         (command "3dface" lpp1 lpp2 upp2 upp1 "")
  100.         (setq lpp1 upp1
  101.               lpp2 upp2
  102.               n (1+ n)
  103.         )
  104.      )
  105.  
  106.      (setq bp1 pl1
  107.            bp2 pl2
  108.            vpl1 vpl2
  109.            m (1+ m)
  110.      )
  111.   )
  112.   (setvar "cmdecho" 1)
  113.   (setvar "blipmode" 1)
  114. )
  115.