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

Intersect Between Two Lines Using Start and End Values of the Two Lines

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
kpennell
2258 Views, 9 Replies

Intersect Between Two Lines Using Start and End Values of the Two Lines

With all of you fine teachers, I have the know-how to get the start and end values of a line.

 

Do you think there is a way to get a point returned that represents the true intersection of the two lines, without having to involke a user defined "getpoint" function using "intersect" osnap?

 

If so, where would one start?

 

I'm thinking geometry.

 

Thanks

KP

9 REPLIES 9
Message 2 of 10
hmsilva
in reply to: kpennell

one way

 

(if (and (setq a (vlax-ename->vla-object (car (entsel "\nSelect the first line: "))))
	 (setq b (vlax-ename->vla-object (car (entsel "\nSelect the second line: "))))
	 );; and
  (setq c (vlax-invoke a 'IntersectWith b acExtendNone))

HTH

Henrique

EESignature

Message 3 of 10
dgorsman
in reply to: hmsilva

There is also an (inters ...) function in LISP, which effectively does the math for you.  You don't even need objects/entities to start with, just the points.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 4 of 10
Lee_Mac
in reply to: dgorsman


@dgorsman wrote:

There is also an (inters ...) function in LISP, which effectively does the math for you.  You don't even need objects/entities to start with, just the points.


1+ Smiley Happy

 

inters is definitely the way to go when determining the intersection between two lines given their endpoints - here is the function documentation for your reference.

Message 5 of 10
kpennell
in reply to: kpennell

Me thinks this will work

 

Thanks,

KP

Message 6 of 10
pbejse
in reply to: kpennell


@kpennell wrote:

Me thinks this will work

 

Thanks,

KP


Be mindful of none zero Z-value KP

 

Message 7 of 10
kpennell
in reply to: kpennell

So this is the code that works so far for what i need,

 

It would be nice if I could include this bit of code in the dimlinear command somehow.  I tried but I don't get the ghost lines.

 

    (command "line" pause pause "")
    (setq LineEnt (entlast))
    (setq edata (entget (entlast)))
    (setq p1 (cdr (assoc 10 edata)))
    (setq p1 (trans p1 0 1))
    (setq p2 (cdr (assoc 11 edata)))
    (setq p2 (trans p2 0 1))
    (setq p3 (getpoint))
    (setq p4 (getpoint))

    (setq point (inters (list (car p1)(cadr p1)) (list (car p2)(cadr p2)) (list (car p3)(cadr p3)) (list (car p4)(cadr p4))))

    (command "erase" LineEnt "")
    (command "circle" point (* (* SF 2) UnitScale))

 

Perhaps, when the user is promted to pick the second point in the dimlinear command, have an option (iniget 128? perhaps) to hit the letter "I" for intersection.  I'll be working on this today.

 

The scenario constantly arises where I need the point projected to a sloped surface.  My team has to draft in geometry and trim about lines to get the point they need to relay to the reader.

 

See attached screenshot for example.

 

KP

Message 8 of 10
Kent1Cooper
in reply to: kpennell


@kpennell wrote:

.... 

See attached screenshot for example.


If you're doing this to determine the location of the Circle or of a definition point for a Dimension, your illustration looks like something you could do using Apparent-Intersection [APP] object snap, without any routine.  Or am I misinterpreting what you're doing?  If so, what in the illustration is the Line that is drawn [if it's still there], and where are the various point variables?

Kent Cooper, AIA
Message 9 of 10
kpennell
in reply to: kpennell

My lisp is drawing the circle at the point I want the user to be able to snap to, to later use for dimensioning.  The line you're seeing is actually an edge of a 3D solid, so the APP intersention does not work for edges of 3D solids.

 

So I was thinking something along the lines of the following:

 

    (setq p1 (getpoint))

    (initget 128)
    (setq rslt (getpoint "\nPick second point or \"I\" for intersection: "))

        (cond
        ((or (= rslt "i")(= rslt "I"))(DL-Inter)(command "DIMLINEAR" p1 point))
        ((= (length rslt) 3)(setq p2 rslt)(command "DIMLINEAR" p1 p2))
        (T(Alert "Invalid selection")(command "undo" "Back")(exit))
        )

 

One problem I do have here though, is usually there a ghost line after the user picks the first point.  My code does not allow that to happen.

Message 10 of 10
Kent1Cooper
in reply to: kpennell


@kpennell wrote:

.... 

    (setq p1 (getpoint))

    (initget 128)
    (setq rslt (getpoint "\nPick second point or \"I\" for intersection: "))
.... 

One problem I do have here though, is usually there a ghost line after the user picks the first point.  My code does not allow that to happen.


For that last part, supply p1 as the rubber-banding base point [the 'pt' argument in the AutoLISP Reference entry about (getpoint)]:

....

      (setq rslt (getpoint p1 "\nPick second point or \"I\" for intersection: "))

....

Kent Cooper, AIA

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

Post to forums  

”Boost