Intersection of CAD entities with lines defined by points

Intersection of CAD entities with lines defined by points

pavel_hosek
Participant Participant
1,590 Views
13 Replies
Message 1 of 14

Intersection of CAD entities with lines defined by points

pavel_hosek
Participant
Participant

Hi,

 

I'm looking for a way to find intersections of a given entity with a line that's not a CAD entity, but of which I know the coordinates of endpoints (for example an existing polyline and a fictional line with coordinates ((0 0 0)(1 1 0)). Is there any easy way, without the need to create and erase the line as an object?

 

I've been usingthis command: 

(vlax-invoke OBJ1 'intersectwith OBJ2 acextendnone)

but both OBJ1 and OBJ2 need to be CAD entities...

 

Thanks for help!

 

Pavel

0 Likes
Accepted solutions (1)
1,591 Views
13 Replies
Replies (13)
Message 2 of 14

Kent1Cooper
Consultant
Consultant

If the drawn object is a LINE, you can use (inters) with its endpoints and the known locations.  If it's a POLYLINE with only line segments, presumably you can have a routine step through it, using (inters) with each successive pair of adjacent vertices and the known locations, to see whether any of them intersect.  But if arc segments may be involved, that won't do.  Is that worth pursuing?  What other kind(s) of object(s) might you want to do it with?

Kent Cooper, AIA
0 Likes
Message 3 of 14

devitg
Advisor
Advisor

@pavel_hosek For better understanding, and maybe get further help, please upload such sample.dwg

0 Likes
Message 4 of 14

pavel_hosek
Participant
Participant

Thanks for your replies. For now, I've got a working script using analytical geometry combined with (inters), and it kind of works for lines, arcs, circles. I could adjust it to add polylines as well. But, given the fact that there already is a working command (as in my first post) for finding intersections between two entities, I would prefer to use that one, instead of writing script for every possible combination of elements (rectangles, rays, etc.). Also, my script for finding intersections would probably not be as efficient.

 

The goal is to have a function that draws a section of a plan between two points, in which every entity that intersects with the defined section is drawn at the correct position. Jpeg attached - the plan and the resulting section.

 

Thanks! 

0 Likes
Message 5 of 14

-didier-
Advisor
Advisor

Bonjour @pavel_hosek 

 

of course it is possible
but drawing the intersection line is faster than anything else.
in the program, you can draw the line, look for intersections, and erase the line.
the user won't see this line because it is so fast.

 

amicalement

Éternel débutant.. my site for learning : Programmer dans AutoCAD

DA

EESignature

0 Likes
Message 6 of 14

devitg
Advisor
Advisor

@pavel_hosek  please , the dwg , not a jpg . and also the lsp you have . 

 

0 Likes
Message 7 of 14

john.uhden
Mentor
Mentor
Accepted solution

I take it that you don't want to have to create or even see the line that would connect 2 points.

I suggest you temporarily entmakex an invisible line and vla-intersect it with whatever other object you want, then vla-delete the temporary line.  It's easy...

Say you have 2 points, p1 and p2)

(setq e (entmakex (list '(0 . "line")(cons 10 p1)(cons 11 p2)(cons 60 1))))

(setq obj1 (vlax-ename->vla-object e))

Now you do the rest.

John F. Uhden

Message 8 of 14

-didier-
Advisor
Advisor

Bonjour @john.uhden 

 

That is exactly was I was thinking it will save a lot of analytical equations

 

Amicalement

Éternel débutant.. my site for learning : Programmer dans AutoCAD

DA

EESignature

0 Likes
Message 9 of 14

pavel_hosek
Participant
Participant

Thanks John, this might be exactly what I was looking for!

0 Likes
Message 10 of 14

john.uhden
Mentor
Mentor

Good.  If it works for you, give me an "attaboy."

John F. Uhden

Message 11 of 14

vladimirvay
Participant
Participant

Hi John.
We are using LT 2020, no LISP command available. It's taking too much time to mark intersections, extending arcs and lines, adding circles, trimming, removing circles. AutoDesk made so many improvements and additions (I started with 10!) but omitted fixing some annoying work arounds like marking an intersection... and more.

0 Likes
Message 12 of 14

pendean
Community Legend
Community Legend

@vladimirvay wrote:

...We are using LT 2020, no LISP command available....


LISP was added starting in LT2024: if this is a dire business need it's cheaper than subscribing to full AutoCAD today.

0 Likes
Message 13 of 14

Sea-Haven
Mentor
Mentor

Maybe look at an alternative to LT that has full LISP built in like Bricscad. It purchase cost is very reasonable and can be perpetual.

0 Likes
Message 14 of 14

john.uhden
Mentor
Mentor

@vladimirvay ,

Without AutoLisp I can not help you out.

You may be best off by taking @Sea-Haven 's advice.

John F. Uhden

0 Likes