+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Mar 2010
    Posts
    112

    Default How it can check if there is an intersection???

    Registered forum members do not see this ad.

    Hi.
    Is there a solution(s) to find out that there is an intersection between a line with a lwpline?????
    I know that it should be checked all entities of lwpline for existance of intersection with a line. but, cause i 'm new in programming, it's difficult for me to get entities of lwpline one after another.
    please guide me how i can check one by one???
    Thank you for pay attention.

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,816

    Default

    Try this:

    Code:
    ;; Finds all Intersections between obj1 & obj2
    ;; Args: obj1,obj2
    ;; VLA-Objects with Intersectwith method available
    ;; Returns: List of Intersections (or nil)
    
    (defun GetIntersections (obj1 obj2 / GroupByNum)
      ;; Lee Mac  ~  16.04.10
      
      (defun GroupByNum (lst num / rtn) (setq rtn nil)
      
        (if lst
          (cons (reverse
                  (repeat num
                    (progn
                      (setq rtn (cons (car lst) rtn)
                            lst (cdr lst))
                      rtn)))
    
                (GroupByNum lst num))))
    
      (GroupByNum (vlax-invoke obj1 'IntersectWith obj2 acExtendNone) 3))

    Test Function:

    Code:
    (defun c:test (/ e1 e2)
      (vl-load-com)
    
      (if (apply (function and)
                 (mapcar
                   (function
                     (lambda (str sym)
                       (set sym (car (entsel str)))))
    
                   '("\nSelect First Object: " "\nSelect Second Object: ") '(e1 e2)))
    
        (print (apply (function GetIntersections)
                      (mapcar (function vlax-ename->vla-object) (list e1 e2)))))
    
      (princ))
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  3. #3
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,816

    Default

    Another, for a Selection Set:

    Code:
    (defun Get_Inters (ss / GroupByNum i j obj1 obj2 iLst)
      ;; Lee Mac  ~  19.01.10
    
      (defun GroupByNum (lst num / rtn) (setq rtn nil)
      
        (if lst
          (cons (reverse
                  (repeat num
                    (progn
                      (setq rtn (cons (car lst) rtn)
                            lst (cdr lst))
                      rtn)))
    
                (GroupByNum lst num))))
    
      (setq i (sslength ss))
    
      (while (not (minusp (setq j (1- i) i (1- i))))
        (setq obj1 (vlax-ename->vla-object (ssname ss i)))
    
        (while (not (minusp (setq j (1- j))))
          (setq obj2 (vlax-ename->vla-object (ssname ss j)))
    
          (setq iLst (append iLst
                       (GroupByNUm
                         (vlax-invoke obj1 'IntersectWith obj2 acExtendNone) 3)))))
    
      iLst)
    Test Function:

    Code:
    (defun c:test (/ ss x)
      (vl-load-com)
    
      (if (setq ss (ssget))
        (foreach x (Get_Inters ss)
          (command "_.point" "_non" x)))
    
      (princ))
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  4. #4
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Mar 2010
    Posts
    112

    Default

    Hi Dear Lee Mac.
    I should test your post in my routine. I'll tell the result after that.
    thanks for ur helping.

  5. #5
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Mar 2010
    Posts
    112

    Default

    Hi.
    I have a problem with this Lisp-command
    (vlax-invoke obj1 'IntersectWith obj2 acExtendNone)
    to finding the intersection point between 2 objects that do not intersect with each other in drawing, but if i strech one to the other one, it can find the point.
    Isn't it possibleto find the point with this command?
    Thanks for helping.

  6. #6
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,816

    Default

    Investigate the ExtendOption parameter of the IntersectWith method:

    Quote Originally Posted by Visual LISP IDE Help Documentation
    IntersectWith Method

    Gets the points where one object intersects another object in the drawing.

    ... ...

    ExtendOption

    AcExtendOption enum; input-only

    This option specifies if none, one or both, of the objects are to be extended in order to attempt an intersection.

    acExtendNone
    Does not extend either object.

    acExtendThisEntity
    Extends the base object.

    acExtendOtherEntity
    Extends the object passed as an argument.

    acExtendBoth
    Extends both objects.
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  7. #7
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,041

    Default

    You should replace acExtendNone with either acExtendBoth, acExtendThisEntity or acExtendOtherEntity.
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  8. #8
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Mar 2010
    Posts
    112

    Default

    Thank you.
    I got the solution.
    What references you suggest for studing about all options of all method?

  9. #9
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,816

    Default

    Quote Originally Posted by kasra View Post
    What references you suggest for studing about all options of all method?
    Visual LISP IDE Help Docs:

    http://lee-mac.com/functioninfo.html
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  10. #10
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Mar 2010
    Posts
    112

    Default

    Registered forum members do not see this ad.

    Ok. Thanx a lot.
    I will try it before any request.

Similar Threads

  1. Intersection points
    By Small Fish in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 23rd Oct 2009, 02:08 am
  2. Line-Arc intersection?
    By George Duls in forum AutoLISP, Visual LISP & DCL
    Replies: 17
    Last Post: 26th Aug 2009, 02:58 pm
  3. intersection point
    By salman in forum AutoCAD General
    Replies: 5
    Last Post: 20th Apr 2009, 11:27 am
  4. Finding the intersection
    By papado170404 in forum AutoCAD 3D Modelling & Rendering
    Replies: 11
    Last Post: 29th Apr 2008, 10:41 pm
  5. Intersection
    By smiles in forum AutoCAD Beginners' Area
    Replies: 8
    Last Post: 4th Sep 2007, 08:26 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts