Find Intersection point automatically

Find Intersection point automatically

Anonymous
Not applicable
13,603 Views
51 Replies
Message 1 of 52

Find Intersection point automatically

Anonymous
Not applicable

Hello, 

 

alixbita_0-1602164802096.png

I have a lot of line which have to cut a single line. I need to know all intersection point location. How can I find it easily? Can I do it with a single command? 

 

Thanks in advance. 

13,604 Views
51 Replies
Replies (51)
Message 2 of 52

Patchy
Mentor
Mentor
Accepted solution

https://www.cadstudio.cz/en/download.asp?file=IntLines

Then use Dataextraction.

 

How many lines do you have? ☺

Message 3 of 52

Anonymous
Not applicable

Thank you for your reply. I have almost 100 intersection points. I have to find out every intersection points locations.

0 Likes
Message 4 of 52

Patchy
Mentor
Mentor

Upload the example, let's see if it can be done ☺

Please upload 2007 version ☺

Message 5 of 52

pendean
Community Legend
Community Legend
How do you think these 100 points should be presented to you? explain your expectations or wishes in more detail, if needed, fake something visual in your file to show us.
Message 6 of 52

Anonymous
Not applicable

Here it is sir.

0 Likes
Message 7 of 52

Anonymous
Not applicable

Yes, I have uploaded a sample drawing file, Kindly see the drawing. 

I have to find out the location where red line cuts the white line. 

0 Likes
Message 8 of 52

Patchy
Mentor
Mentor

You want the coordinates or dimensions?

 

Message 9 of 52

Anonymous
Not applicable

Sir, the red line midpoint would be (x,y) = (0,0), if I want find out the coordinate. or it would be dimension form the red line mid point.  

0 Likes
Message 10 of 52

Anonymous
Not applicable

actually, I need the distance from the red line mid point to intersection point

0 Likes
Message 11 of 52

hak_vz
Advisor
Advisor
Accepted solution
(defun c:intersections nil(intersections))

(defun intersections ( / e eo ss i getintersections mappend mklist flatten pointlist3d io int all)

(defun getintersections	(obj1 obj2 / var)
     ; from RonJonP
     (setq var (vlax-variant-value (vla-intersectwith obj1 obj2 1)))
     (if (< 0 (vlax-safearray-get-u-bound var 1))
	  (vlax-safearray->list var)
     ) ;_ end of if
) ;_ end of defun
(defun mappend (fn lst) ; Peter Norvig ??
     ; Append the results of calling fn on each element of list.
     ; Like mapcon, but uses append instead of nconc."
     ; One thing to notice is that fn must return a list, otherwise, it will go wrong.
     ; usage: (mappend '(lambda (x) (list x (* x x))) '(1 2 3))
     (apply 'append (mapcar fn lst))
) ;_ end of defun
(defun mklist (x)
     ; If x is a list return it, otherwise return the list of x
     (if (listp x)
	  x
	  (list x)
     ) ;_ end of if
) ;_ end of defun

(defun flatten (expr)
     ; Get rid of imbedded lists (to one level only)."
     (mappend 'mklist expr)
) ;_ end of defun

(defun pointlist3d (lst / ret)
     ; converts one dimensional list (vector) to list of 3d points 
     (while lst
	  (setq	ret (cons (list (car lst) (cadr lst) (caddr lst)) ret)
		lst (cdddr lst)
	  ) ;_ end of setq
     ) ;_ end of while
     (reverse ret)
) ;_ end of defun

(while (not e )(setq e (car (entsel "\nSelect base object > "))))
(setq eo (vlax-ename->vla-object e))
(princ "\nSelect intersection objects >")
(setq ss (ssget) i 0)
(repeat (sslength ss)
	(setq io (vlax-ename->vla-object (ssname ss i)))
	(setq int (pointlist3d(flatten(getintersections eo io))))
	(if (and int)(setq all (cons int all)))
	(setq i (+ i 1))
)
all
)

 

Try this.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 12 of 52

Anonymous
Not applicable

Thanks a lot. But I am sorry sir, I don't know how to input this. I know programming, but don't know about autocad coding. Please help me sir 

0 Likes
Message 13 of 52

Patchy
Mentor
Mentor

Maybe like this.

Message 14 of 52

Anonymous
Not applicable

WOW! How you do it? 😄

0 Likes
Message 15 of 52

Patchy
Mentor
Mentor
Accepted solution

Most of the autolisp I used were from here:

http://www.lee-mac.com/index.html

Message 16 of 52

Anonymous
Not applicable

OK sir. Thank you. But could you please tell me how you do that? How you find out all coordinate points?

0 Likes
Message 17 of 52

hak_vz
Advisor
Advisor

Save this code to a file with extension .lsp  i.e.  intersections.lsp. Load it into AUTOCAD though menus 

tools-> load application -> select wile name

or by using command APPLOAD

 

When loaded type command INTERSTECTIONS  to console and follow what it asks.

For your sample when origin is set to 0,0 you will receive a list:

 

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 18 of 52

hak_vz
Advisor
Advisor

@Patchyhas something that is probably easier for you to use since you don't know how to use lisp code, and you didn't elaborated how you want  your intersection list to be represented.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 19 of 52

Anonymous
Not applicable

Sir, I successfully load the app. After that I cannot do what it wants. It is asking for base objects. 

0 Likes
Message 20 of 52

Anonymous
Not applicable

Yes sir.  @Patchy sir's solution is enough for my work. I need this type of output. I would like to request @Patchy sir, how he do it?

0 Likes