Lsp Intersection:Line/Pline

Lsp Intersection:Line/Pline

Anonymous
Not applicable
3,128 Views
4 Replies
Message 1 of 5

Lsp Intersection:Line/Pline

Anonymous
Not applicable

Hello,
I need your support,
I created the following program to draw a point at each intersection between tow lines
I want to update it to draw the edit points when I have two polylines or line / polyline

 

****************************************************************

(defun c:IN2L (/ l1 l2 intersection a)
(setq l1 (car (entsel "\npoligne 1"))
        l2 (car (entsel "\npoligne 2"))
)
(setq intersection (inters (list (car (cdr (assoc 10 (entget l1))))
                                            (cadr(cdr (assoc 10 (entget l1)))))
                                      (list (car (cdr (assoc 11 (entget l1))))
                                            (cadr (cdr (assoc 11 (entget l1)))))
                                      (list (car (cdr (assoc 10 (entget l2))))
                                            (cadr(cdr (assoc 10 (entget l2)))))
                                     (list (car (cdr (assoc 11 (entget l2))))
                                           (cadr (cdr (assoc 11 (entget l2)))))
                            nil)
)
(command "point" intersection "")
)

****************************************************************

 

Thank you in advance,

0 Likes
Accepted solutions (1)
3,129 Views
4 Replies
Replies (4)
Message 2 of 5

cig_ad
Enthusiast
Enthusiast

You can try something like this:

 

(vlax-safearray->list (vlax-variant-value (vla-IntersectWith (vlax-ename->vla-object ename1) (vlax-ename->vla-object ename2) acExtendNone)))

 

which will return a single dimension list that you can group as points (remember - there can be multiple intersections).

 

see also: http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-1243A593-5DAE-4DC3-B539-59FDA990E687

0 Likes
Message 3 of 5

ВeekeeCZ
Consultant
Consultant
Accepted solution

Maybe like this,

 

(defun C:In2ob ( / ss ptsa pt)
  (if (and (setq ss (ssget '(( 0 . "LINE,LWPOLYLINE"))))
	   (= 2 (sslength ss))
	   (setq int (vLa-intersectwith (vLax-ename->vLa-Object (ssname ss 0))
		       			(vLax-ename->vLa-Object (ssname ss 1))
		       	            	acextendnone))
	   (setq ptsa (vLax-safearray->List (vLax-variant-vaLue int))))
    (repeat (/ (length ptsa) 3)
      (setq pt (list (car ptsa)
		     (cadr ptsa)
		     (caddr ptsa)))
      (command "_.POINT" pt)
      (setq ptsa (cdddr ptsa))))
  (princ)
)

 

Used part of stevor's code here

0 Likes
Message 4 of 5

Anonymous
Not applicable

Perfect Smiley Happy

That is exactly what I need.

 

Thank you for the support

0 Likes
Message 5 of 5

Anonymous
Not applicable

I have a question more ... I take advantage.Smiley Happy
It is necessary to go through this formula vLa-intersectwith (vLax-ename->vLa-Object (ssname AA 0))
(vLax-ename->vLa-Object (ssname AA 1))acextendnone)

No other shorter and simpler (classic) method?

 

Thank you for your answers

0 Likes