Hello,
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.
Solved! Go to Solution.
Solved by hak_vz. Go to Solution.
Solved by Patchy. Go to Solution.
Solved by hak_vz. Go to Solution.
Solved by Patchy. Go to Solution.
Solved by Patchy. Go to Solution.
Solved by hak_vz. Go to Solution.
Solved by Patchy. Go to Solution.
Thank you for your reply. I have almost 100 intersection points. I have to find out every intersection points locations.
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.
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.
(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
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
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
@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