Jump to content

Recommended Posts

Posted

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.

Posted

Try this:

 

;; 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:

 

(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))

Posted

Another, for a Selection Set:

 

(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:

 

(defun c:test (/ ss x)
 (vl-load-com)

 (if (setq ss (ssget))
   (foreach x (Get_Inters ss)
     (command "_.point" "_non" x)))

 (princ))

Posted

Hi Dear Lee Mac.

I should test your post in my routine. I'll tell the result after that.

thanks for ur helping.

  • 2 years later...
Posted

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.

Posted

Investigate the ExtendOption parameter of the IntersectWith method:

 

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.

 

Posted

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

Posted

Thank you.:)

I got the solution.:thumbsup:

What references you suggest for studing about all options of all method?

Posted

Ok. Thanx a lot.:)

I will try it before any request.;)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...