Author Topic: Mark Error circles at Intersections of polylines  (Read 1813 times)

0 Members and 1 Guest are viewing this topic.

chvnprasad

  • Guest
Mark Error circles at Intersections of polylines
« on: April 13, 2012, 02:39:27 PM »
Hi,
I am new to autolisp, I need to find out all poly lines intersections in a drawing files,and place the error circles at these intersection location and zoom that location one by one as per error markers. 

Lee Mac

  • Seagull
  • Posts: 12925
  • London, England
Re: Mark Error circles at Intersections of polylines
« Reply #1 on: April 13, 2012, 07:16:24 PM »
Look into the 'IntersectWith' method.

Here are some example functions to help you toward your goal:

Code - Auto/Visual Lisp: [Select]
  1. ;;----------------=={ Intersections in Set }==----------------;;
  2. ;;                                                            ;;
  3. ;;  Returns a list of all points of intersection between      ;;
  4. ;;  objects in a selection set                                ;;
  5. ;;------------------------------------------------------------;;
  6. ;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
  7. ;;------------------------------------------------------------;;
  8. ;;  Arguments:                                                ;;
  9. ;;  ss - SelectionSet                                         ;;
  10. ;;------------------------------------------------------------;;
  11. ;;  Returns:  List of intersection points, or nil             ;;
  12. ;;------------------------------------------------------------;;
  13.  
  14. (defun LM:IntersectionsInSet ( ss / i1 i2 ls o1 o2 )
  15.     (repeat (setq i1 (sslength ss))
  16.         (setq o1 (vlax-ename->vla-object (ssname ss (setq i1 (1- i1)))))
  17.         (repeat (setq i2 i1)
  18.             (setq o2 (vlax-ename->vla-object (ssname ss (setq i2 (1- i2))))
  19.                   ls (append ls (LM:GroupByNum (vlax-invoke o1 'intersectwith o2 acextendnone) 3))
  20.             )
  21.         )
  22.     )
  23.     ls
  24. )
  25.  
  26. ;;-----------------=={ Group by Number }==--------------------;;
  27. ;;                                                            ;;
  28. ;;  Groups a list into a list of lists, each of length 'n'    ;;
  29. ;;------------------------------------------------------------;;
  30. ;;  Author: Lee Mac, Copyright © 2010 - www.lee-mac.com       ;;
  31. ;;------------------------------------------------------------;;
  32. ;;  Arguments:                                                ;;
  33. ;;  l - List to process                                       ;;
  34. ;;  n - Number of elements by which to group the list         ;;
  35. ;;------------------------------------------------------------;;
  36. ;;  Returns:  List of lists, each of length 'n'               ;;
  37. ;;------------------------------------------------------------;;
  38.  
  39. (defun LM:GroupByNum ( l n / r)
  40.     (if l
  41.         (cons
  42.             (reverse (repeat n (setq r (cons (car l) r) l (cdr l)) r))
  43.             (LM:GroupByNum l n)
  44.         )
  45.     )
  46. )