Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Find Intersection point automatically

51 REPLIES 51
SOLVED
Reply
Message 1 of 52
alixbita
7058 Views, 51 Replies

Find Intersection point automatically

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. 

51 REPLIES 51
Message 2 of 52
Patchy
in reply to: alixbita

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

Then use Dataextraction.

 

How many lines do you have? ☺

Message 3 of 52
alixbita
in reply to: Patchy

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

Message 4 of 52
Patchy
in reply to: alixbita

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

Please upload 2007 version ☺

Message 5 of 52
pendean
in reply to: alixbita

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
alixbita
in reply to: Patchy

Here it is sir.

Message 7 of 52
alixbita
in reply to: pendean

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. 

Message 8 of 52
Patchy
in reply to: alixbita

You want the coordinates or dimensions?

 

Message 9 of 52
alixbita
in reply to: Patchy

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.  

Message 10 of 52
alixbita
in reply to: Patchy

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

Message 11 of 52
hak_vz
in reply to: alixbita

(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
alixbita
in reply to: hak_vz

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 

Message 13 of 52
Patchy
in reply to: alixbita

Maybe like this.

Message 14 of 52
alixbita
in reply to: Patchy

WOW! How you do it? 😄

Message 15 of 52
Patchy
in reply to: alixbita

Most of the autolisp I used were from here:

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

Message 16 of 52
alixbita
in reply to: Patchy

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

Message 17 of 52
hak_vz
in reply to: alixbita

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
in reply to: hak_vz

@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
alixbita
in reply to: hak_vz

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

Message 20 of 52
alixbita
in reply to: hak_vz

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?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost