Results 1 to 8 of 8

Thread: Determining if two areas are overlapping

  1. #1
    Member
    Join Date
    2008-10
    Posts
    7
    Login to Give a bone
    0

    Default Determining if two areas are overlapping

    Does anyone know how to (using AutoLisp or Visual Lisp) determine if two areas are overlapping? The areas will be defined by polylines which could make up any shape. I need to figure out how to check if they are overlapping even the slightest bit, I've been racking my brain on how to start this but I'm drawing a blank. I would greatly appreciate any ideas on how to determine this, no one needs to write the code for me, just throw me some ideas/psuedo-code to get me rolling. I've been looking in the help files for any commands that might be useful but haven't found any. I'm not sure how I can compare the vertices of the areas to determine if they overlap, I thought of maybe converting them to solids and somehow using Interference Checking or the Intersect command (the polylines would all be drawn at zero elevation or flattened). I haven't gotten any code put together for that even yet so any ideas on how to do this in a very simple manner would be greatly appreciated.

    I attached a simple drawing showing two areas overlapping.


    Thanks!
    Attached Images Attached Images

  2. #2
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Determining if two areas are overlapping

    The method ' IntersectWith ' will let you know if two objects intersect with each other.

  3. #3
    Member
    Join Date
    2008-10
    Posts
    7
    Login to Give a bone
    0

    Default Re: Determining if two areas are overlapping

    Isn't that VBA? I haven't done alot of VBA, would like to get this done with LISP.



    Quote Originally Posted by T.Willey View Post
    The method ' IntersectWith ' will let you know if two objects intersect with each other.

  4. #4
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Determining if two areas are overlapping

    You can use it with lisp. It is ActiveX. Just load the arx file that will allow you to; ' (vl-load-com) '. This will return T if they intersect, and nil if not, to the command line.

    Code:
    (defun c:IntersectTest (/ Sel Ent Obj1 Obj2)
        
        (vl-load-com) ; only needs to be called once per session, but doesn't matter if called more times.
        (and
            (setq Sel (entsel))
            (setq Obj1 (vlax-ename->vla-object (car Sel)))
            (setq Sel (entsel))
            (setq Obj2 (vlax-ename->vla-object (car Sel)))
            (vlax-invoke Obj1 'IntersectWith Obj2 acExtendNone)
        )
    )

  5. #5
    Member
    Join Date
    2008-10
    Posts
    7
    Login to Give a bone
    0

    Default Re: Determining if two areas are overlapping

    I see... Thank you, I wasn't sure how to call VBA from LISP. That would be very helpful!

    Thanks.




    Quote Originally Posted by T.Willey View Post
    You can use it with lisp. It is ActiveX. Just load the arx file that will allow you to; ' (vl-load-com) '. This will return T if they intersect, and nil if not, to the command line.

    Code:
    (defun c:IntersectTest (/ Sel Ent Obj1 Obj2)
        
        (vl-load-com) ; only needs to be called once per session, but doesn't matter if called more times.
        (and
            (setq Sel (entsel))
            (setq Obj1 (vlax-ename->vla-object (car Sel)))
            (setq Sel (entsel))
            (setq Obj2 (vlax-ename->vla-object (car Sel)))
            (vlax-invoke Obj1 'IntersectWith Obj2 acExtendNone)
        )
    )

  6. #6
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Determining if two areas are overlapping

    It can be very powerful, but also sometimes it will take longer. Only with experience and testing will one know for sure, but it is a good tool to have in your tool bag.

    You're welcome.

  7. #7
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Determining if two areas are overlapping

    Quote Originally Posted by bdwidhalm View Post
    I see... Thank you, I wasn't sure how to call VBA from LISP. That would be very helpful!

    Thanks.
    It's not actually VBA you're calling. It's named ActiveX ... which is an Extension Library which can be called from any (well ... most) programming languages. VBA is simply the norm in most applications.

    The Visual Lisp extensions allowed this to be called in Lisp. And yes, some things are much easier to do with these methods, while some things are possible only through these methods, and yet other things are only possible through normal AutoLISP. So it depends on the situation, but generally it's easier quicker & more efficient to use the vlax / vla methods.

    Also a shorthand way of executing the Method is to replace the line:
    Code:
    (vlax-invoke Obj1 'IntersectWith Obj2 acExtendNone)
    with
    Code:
    (vla-IntersectWith Obj1 Obj2 acExtendNone)

  8. #8
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Determining if two areas are overlapping

    Quote Originally Posted by irneb View Post
    Also a shorthand way of executing the Method is to replace the line:
    Code:
    (vlax-invoke Obj1 'IntersectWith Obj2 acExtendNone)
    with
    Code:
    (vla-IntersectWith Obj1 Obj2 acExtendNone)
    True, but if you used to working in lisp, one will give you a list of points, and the other will be a variant. I like working with lists instead of variants, so that is why I posted it the way I did.

Similar Threads

  1. 2013: Overlapping cut areas in materials
    By WScottAllenPE in forum AutoCAD Civil 3D - Sections
    Replies: 1
    Last Post: 2013-05-02, 01:19 PM
  2. Determining Version
    By mikeosborne in forum VBA/COM Interop
    Replies: 1
    Last Post: 2009-06-01, 06:10 PM
  3. Overlapping Areas? Different Area Plans still subtract.
    By 3dway in forum Revit Architecture - General
    Replies: 4
    Last Post: 2008-11-20, 02:49 AM
  4. Determining if a sheet set is linked to a drawing
    By Mike.Perry in forum AutoCAD Tips & Tricks
    Replies: 0
    Last Post: 2006-06-08, 07:22 PM
  5. Areas - Removing Columns from Floor Areas
    By ddavison.33993 in forum Revit Architecture - General
    Replies: 3
    Last Post: 2006-02-18, 02:39 PM

Posting Permissions

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