Jump to content

intersection point


salman

Recommended Posts

this question is more related to maths rather than autocad. Any how I am not able to find a solution so I am sending this post. any help will be deeply appreciated.

 

we have two non parallel lines intersecting each other. Now we offset first line by x distance and the second one by y distance and their point of intersection changes. I want to know how can we find the coordinates of their new point of intersection.

 

Thanks.

Link to comment
Share on other sites

here's a quicky... returns a list of the intersection point(s)

(defun c:test ()
(vl-load-com)
(setq obj1 (vlax-ename->vla-object (car (entsel "\nPick first object: ")))
     obj2 (vlax-ename->vla-object (car (entsel "\nPick object to intersect: ")))
     )
(setq var (vla-intersectwith obj1 obj2 acExtendBoth)
     sa (vlax-variant-value var)
     ip (vlax-safearray->list sa)
     )
)

Link to comment
Share on other sites

Or in plain AutoLisp, even if the lines no longer intersect:

 

[b][color=BLACK]([/color][/b]defun c:lint [b][color=FUCHSIA]([/color][/b]/ s1 s2 l1 l2[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]or [b][color=MAROON]([/color][/b]not s1[b][color=MAROON])[/color][/b]
            [b][color=MAROON]([/color][/b]> [b][color=GREEN]([/color][/b]sslength s1[b][color=GREEN])[/color][/b] 1[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"\nSelect 1st Line:   "[/color][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]setq s1 [b][color=MAROON]([/color][/b]ssget '[b][color=GREEN]([/color][/b][b][color=BLUE]([/color][/b]0 . [color=#2f4f4f]"LINE"[/color][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]or [b][color=MAROON]([/color][/b]not s2[b][color=MAROON])[/color][/b]
            [b][color=MAROON]([/color][/b]> [b][color=GREEN]([/color][/b]sslength s2[b][color=GREEN])[/color][/b] 1[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"\nSelect 2nd Line:   "[/color][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]setq s2 [b][color=MAROON]([/color][/b]ssget '[b][color=GREEN]([/color][/b][b][color=BLUE]([/color][/b]0 . [color=#2f4f4f]"LINE"[/color][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]setq l1 [b][color=NAVY]([/color][/b]ssname s1 0[b][color=NAVY])[/color][/b]
       l2 [b][color=NAVY]([/color][/b]ssname s2 0[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]inters [b][color=NAVY]([/color][/b]cdr [b][color=MAROON]([/color][/b]assoc 10 [b][color=GREEN]([/color][/b]entget l1[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
         [b][color=NAVY]([/color][/b]cdr [b][color=MAROON]([/color][/b]assoc 11 [b][color=GREEN]([/color][/b]entget l1[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
         [b][color=NAVY]([/color][/b]cdr [b][color=MAROON]([/color][/b]assoc 10 [b][color=GREEN]([/color][/b]entget l2[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
         [b][color=NAVY]([/color][/b]cdr [b][color=MAROON]([/color][/b]assoc 11 [b][color=GREEN]([/color][/b]entget l2[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] nil[b][color=FUCHSIA])[/color][/b]
 [b][color=BLACK])[/color][/b]

Hopefully the lines are 2D and in the same plane. -David

Link to comment
Share on other sites

I must have been bored...

(defun c:test ()
 (vl-load-com)
 (setq oldsnap(getvar "osmode")
   oldecho (getvar "cmdecho"))
 (setvar "osmode" 0)
 (setvar "cmdecho" 0)

 (setq ent1 (entsel "\nSelect first object to offset: ")
   od1 (getdist "\nSpecify offset distance: ")
   pt1 (getpoint "\nSpecify point on side to offset: "))
 (vl-cmdf "offset" od1 ent1 pt1 "")
 (setq obj1 (vlax-ename->vla-object (entlast)))
 

 (setq ent2 (entsel "\nSelect second object to offset: ")
   od2 (getdist "\nSpecify offset distance: ")
   pt2 (getpoint "\nSpecify point on side to offset: "))
 (vl-cmdf "offset" od2 ent2 pt2 "")
 (setq obj2 (vlax-ename->vla-object (entlast)))
 
   
(setq var (vla-intersectwith obj1 obj2 acExtendBoth)
     sa (vlax-variant-value var)
     ip (vlax-safearray->list sa)
     )
 (print (strcat "The intersection point is " (rtos (car ip) 2 2)","(rtos (cadr ip)2 2)","(rtos (caddr ip)2 2)))
 (entdel (entlast))
 (entdel (entlast))
 (setvar "osmode" oldsnap)
 (setvar "cmdecho" oldecho)
 (princ)
)

Link to comment
Share on other sites

You can use the quick calculator to find-out intersection points.

From the AutoCAD help file:

ill(p1,p2,p3,p4)

Determines the intersection point between two lines (p1,p2) and (p3,p4). All points are considered three-dimensional.

Link to comment
Share on other sites

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...