home *** CD-ROM | disk | FTP | other *** search
/ Share Gallery 1 / share_gal_1.zip / share_gal_1 / GR / GR505.ZIP / LSP.EXE / VERTEX.LSP < prev   
Text File  |  1987-07-12  |  3KB  |  105 lines

  1. ; VERTEX.LSP
  2. ; 1/12/87
  3. ; by Tony Tanzillo
  4. ;
  5. ; These are miscellaneous routines that make use
  6. ; of the AutoLISP (inters) function, and can be used
  7. ; in a manner similar to AutoCAD's Object snap mechanism.
  8. ;
  9. ; (vertex)  - Returns the intersection of 2 line entities.
  10. ;             Can be used as an OPTION KEYWORD at any AutoCAD
  11. ;             point prompt. It is a kind of "virtual" intersection
  12. ;             OBJECT SNAP (meaning that the lines do not have to
  13. ;             physically intersect)
  14. ;
  15. ;     Usage:  Assuming you have several non-parallel lines on the
  16. ;             display already, enter the LINE command, and pick
  17. ;             a starting point, draw a few segments, and then at
  18. ;             any "To point: " prompt, enter "(VERTEX) <CR>"
  19. ;             (w/o the quotes) and select 2 lines. The endpoint
  20. ;             of the current line segment you are drawing should
  21. ;             Anchor itself to the vertex (virtual intersection)
  22. ;             of the 2 lines you selected. There are other uses,
  23. ;             which is limited only by ones imagination.
  24. ;
  25. ;  (extend) - This is another OPTION KEYWORD that can be entered
  26. ;             at any point prompt. If used with the line command
  27. ;             It will let you draw a line by "EXENDING IT" to
  28. ;             another line (just like AutoCAD's EXTEND command
  29. ;             would extend an existing line). The line that you
  30. ;             are extending to is treated as though it were of
  31. ;             infinite length, And the resulting line will maintain
  32. ;             the specified angle regardless of length.
  33. ;
  34. ;     Usage - Assuming there are some lines on the display, Enter
  35. ;             the LINE command and specify a starting point, draw
  36. ;             a few segments, and then enter (EXTEND) at any
  37. ;             "To point: " prompt. Next, enter or pick the angle
  38. ;             that the next segment is to be drawn at, and then
  39. ;             select a line that the segment is to be EXTENDED to.
  40. ;             Again, don't assume this function is only useful with
  41. ;             the LINE command which I only site here as an example.
  42. ;             Since this these functions return a point, they can be
  43. ;             used at ANY AutoCAD POINT PROMPT, and thier uses are
  44. ;             limited only by ones imagination.
  45. ;
  46. ;
  47. ;    Tony Tanzillo, A/E Automation Systems 70307,2556
  48.  
  49. (defun pfetch(e p)
  50.   (cond
  51.     ((atom p)
  52.        (cdr
  53.          (assoc p
  54.            (entget (cond ((eq (type e) 'ENAME) e) ((car e))))
  55.          )
  56.        )
  57.     )
  58.     ((mapcar '(lambda(x) (pfetch e x )) p))
  59.   )
  60. )
  61.  
  62.  
  63. (defun orr(l) (eval (cons 'cond (mapcar 'list l))))
  64.  
  65.  
  66. (defun ends(e)
  67.   (list
  68.     (pfetch e 10)
  69.     (pfetch e 11)
  70.   )
  71. )
  72.  
  73. (defun land(l) (if (not (member nil l)) (last l)))
  74.  
  75. (defun vertex( / a)
  76.   (inters
  77.     (car (setq a (ends (entsel "Vertex of line: "))))
  78.     (cadr a)
  79.     (car (setq a (ends (entsel "And line: "))))
  80.     (cadr a) nil))
  81.  
  82. (defun extend( / a b c d e)
  83.   (setq a (getvar "lastpoint"))
  84.   (setq b (getpoint a "Angle: "))
  85.   (setq c (entsel "\nLine to extend to, or ENTER for 2 points: "))
  86.   (setq e
  87.     (if c
  88.       (ends c)
  89.       (progn
  90.         (list
  91.           (setq d (getpoint "\nFrom point: "))
  92.           (getpoint d "To point: ")
  93.         )
  94.       )
  95.     )
  96.   )
  97.   (if (and a b (car e) (cdr e))
  98.     (apply 'inters
  99.       (list a b (car e) (cadr e) nil)
  100.     )
  101.   )
  102. )
  103. )
  104. ;
  105. ;   There may be