home *** CD-ROM | disk | FTP | other *** search
/ Share Gallery 1 / share_gal_1.zip / share_gal_1 / GR / GR505.ZIP / LSP.EXE / EXTLINE.LSP < prev    next >
Text File  |  1988-05-23  |  3KB  |  69 lines

  1. ; EXTENDLINE will extend a selected line so that it is perpendicular to a 
  2. ; selected point.
  3.  
  4. ;    a     -starting point of selected line
  5. ;    b     -ending point of selected line
  6. ;    c     -point to which line is to be extended perp. to
  7. ;    d     -point on a line thru pt. c that is perp to line AB
  8. ;    e     -entity group for the selected line
  9. ;    f     -point of intersection btw'n lines AB & CD
  10. ;    np    -endpt. of line AB closest to c
  11. ;    fp    -endpt. of line AB furthest from c
  12. ;   deltax -delta x between a & b
  13. ;   deltay -delta y between a & b
  14.  
  15. (defun C:EL ()
  16.   (setq e (entget (car (entsel "\nPick the line to extend : "))))
  17.   (setq c (getpoint "\nPick the point to extend to : "))
  18.   (if (or (null e) (null c)) (prompt "   Somethings wrong. Try again.")
  19.      (progn
  20.      (setq a (cdr (assoc 10 e))
  21.            b (cdr (assoc 11 e)))            ; name the endpoints
  22.      (if (> (distance a c)(distance b c))
  23.         (setq np b fp a agroup 11)          ; then
  24.         (setq np a fp b agroup 10)          ; else
  25.      )
  26.      (setq deltax (- (car np)(car fp))
  27.            deltay (- (cadr np)(cadr fp)))
  28.      (setq d (list (- (car c) deltay)(+ (cadr c) deltax)))
  29.      (setq f (cons agroup (inters a b c d nil)))
  30.      (setq e (subst f (assoc agroup e) e))
  31.      (entmod e)
  32.      ))
  33.   (princ)
  34. )
  35.  
  36. ; EXTENDLINE will extend a selected line a user supplied distance.
  37. ; Variables:
  38. ;    a     -starting point of selected line
  39. ;    b     -ending point of selected line
  40. ;    c     -how far the line is to be extended
  41. ;    e     -entity group for the selected line
  42. ;    f     -point @ distance c from np
  43. ;    np    -endpt. of line AB closest to c
  44. ;    fp    -endpt. of line AB furthest from c
  45. ;    g     -point @ which line was picked
  46. ;    h     -angle of line AB from fp to np
  47.  
  48. (defun C:ELD ()
  49.   (setq e (entsel "\nPick the line to extend : "))
  50.   (setq g (cadr e))
  51.   (setq e (car e))
  52.   (setq e (entget e))
  53.   (setq c (getdist "\nHow far? : "))
  54.   (if (or (null e) (null c)) (prompt "   Somethings wrong. Try again.")
  55.      (progn
  56.      (setq a (cdr (assoc 10 e))
  57.            b (cdr (assoc 11 e)))            ; name the endpoints
  58.      (if (> (distance a g)(distance b g))
  59.         (setq np b fp a agroup 11)          ; then
  60.         (setq np a fp b agroup 10)          ; else
  61.      )
  62.      (setq h (angle fp np))                 ; Get the angle of the line.
  63.      (setq f (cons agroup (polar np h c)))  ; 
  64.      (setq e (subst f (assoc agroup e) e))
  65.      (entmod e)
  66.      ))
  67.   (princ)
  68. )
  69.