Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LISP for drawing a secant segment to a polyline

7 REPLIES 7
Reply
Message 1 of 8
1_0_1
1923 Views, 7 Replies

LISP for drawing a secant segment to a polyline

Hi everyone, I'm trying to draw a secant segment (n length, don't matter if this line intersect two or more times) to a polyline but at the same time this segment must be tangent to another polyline that is parallel to the first polyline.

Like showed in the image.

Capture_3.jpg

The main interest is that the function can find the points where this happen (if happen), and it draw a line secant and tangent at the same time to a polyline and its parallel, respectively.

Is possible?

Thanks in advance.

7 REPLIES 7
Message 2 of 8
Kent1Cooper
in reply to: 1_0_1

Some clarification about what's input and what's output [not that I can picture a way to do it yet, but I wanted to be sure of the parameters]:

 

I assume the Polylines are there already.  Is the n length to be specified by the User each time, with the issue being to find whether [and if so, where] there are any places where a Line of that specified length, with both its ends lying on Polyline 1, is tangent to Polyline 2?  Off-hand, I suspect it wouldn't be achievable by calculation, but could be, within some defined tolerance, in a "brute-force" approach that tries it out repeatedly and under some conditions where it finds itself close, narrows down the exact location of the Line.

 

[I can't imagine that the secant points are what the User would specify, because then either it works or it doesn't -- there's nothing to find.]

Kent Cooper, AIA
Message 3 of 8
1_0_1
in reply to: Kent1Cooper


@Kent1Cooper wrote:
I assume the Polylines are there already.  Is the n length to be specified by the User each time, with the issue being to find whether [and if so, where] there are any places where a Line of that specified length, with both its ends lying on Polyline 1, is tangent to Polyline 2?

Yes, it's exactly like this.

Actually, I do it by "brute force" and by "hand" with the considerations that you imagine.

Maybe explain the "method" that I use to do it can help you to find a solution by "brute force" but in automatic way.

1.- Initially I have  the two polylines (always parallels between them)

 

2.- Then i make a circle (in any place) with radio n (length of the line).

3.- Next step, I convert this circle to a BLOCK, any name will work.

4.- I use the command MEASURE and select the first polyline (where lying the ends of the line), with option B (BLOCK) and type the name of the block given in the previous step, AutoCAD will ask Align block to object?, type Y (YES), and again AutoCAD will ask Specific lenght of the segment? here I put the "TOLERANCE" that you mention and depends of the separation of the polylines.

5. In this moment the drawing looks of this way

 

Clip_11.jpg


6. Here comes the bother part, I must locate first the zone where probably occurs the tangent point, then by try and error I draw lines that connect the intersection of one circle with the first polyline (top polyline in the image) and the center of the same circle. (select only CENTER and INTERSECCTION like object snap modes really help).

 

Clip_13.jpg

 

Clip_14.jpg

7.- After of many errors I found ( approximately) that I look for:

 

Clip_15.jpg

Maybe you are intrigated about why am i doing this. The answer is simple, the bottom polyline (second one) is the road longitudinal contour, the above polyline (first one) is the visibility line of the conductor (the height depends of the kind of vehicle) and finally the line that I looking for is the overtaking sight distance.

In a road with tens or hundreds of kilometers it's exhausting do this by hand.

Message 4 of 8
Kent1Cooper
in reply to: 1_0_1

I thought the general concept rang a bell, and I found it -- take a look at ViewBlockDist.lsp attached to Message 8 on this thread.  It's not exactly what you're looking for, but I think a variant of it could be made to do that

Kent Cooper, AIA
Message 5 of 8
1_0_1
in reply to: Kent1Cooper


@Kent1Cooper wrote:

take a look at ViewBlockDist.lsp attached to Message 8 on this thread.


I tested and it's correct, it does the job

 

Clip_16.jpg

 

Faster and with more precisión that I could do it by hand.

 

Clip_17.jpg

 

I undestand that the script do an scanning from left to right. On this context, Can you add to the LISP an option to delete all lines (or not draw) except the last line before the tangency point and first line after the same point? of course only if a tangency point can be approach.

 

Example, green line in the image it's for me the last line before the tangency point (to right of this point the script will break because the original restrictions are broken) and magent line is first line after the same point (where fulfills the conditions again).

 

Clip_18.jpg

 

Kent1Cooper, thanks for your help.

 

Message 6 of 8
Kent1Cooper
in reply to: 1_0_1


@1_0_1 wrote:
....

I tested and it's correct, it does the job

....

I undestand that the script do an scanning from left to right. On this context, Can you add to the LISP an option to delete all lines (or not draw) except the last line before the tangency point and first line after the same point? of course only if a tangency point can be approach.

....


I'm glad it does what you're after, even though your original didn't work from a center-line [or maybe your original "first Polyline" is meant as a center-line].  If you oreally need it from side to side, rather than center to two sides, that would be one of the things I meant by the word "variant" in my previous message.

 

[By the way:

1.  It's not a "script" -- that word has a specific meaning in AutoCAD, different from what this is.

2.  It doesn't always work from left to right, but goes along the drawn direction of the center-line Polyline, whatever that is.]

 

That could certainly be done, but in the meantime, try using VBD's "Treatment" option and choosing "Mark" instead of "Delete."  That will at least make it easier to see where the transitions are between those that "work" and those that don't.  [It Marks the ones that hit the edges by making them Yellow and of Hidden2 linetype, but you can change those in the code.]

 

I have a feeling the way to do what you're looking for will involve running it with the Mark option, and somehow stepping through and checking whether pairs of adjacent Lines are both either Marked or not, or are one of each -- I'll have to think about exactly how to do that.

Kent Cooper, AIA
Message 7 of 8
1_0_1
in reply to: Kent1Cooper


@Kent1Cooper wrote:
I'm glad it does what you're after, even though your original didn't work from a center-line [or maybe your original "first Polyline" is meant as a center-line].  If you oreally need it from side to side, rather than center to two sides, that would be one of the things I meant by the word "variant" in my previous message.

The request of antonijo and mine are two sides of the same coin. The polylines of antonijo are on the horizontal plane (he's is looking for the lateral visibility of road) and mine are on the vertical plane (i'm looking for the vertical visibilty of road), the LISP works because the concept is the same, but technically on the vertical plane there isn't two sides or an axis like antonijo's example.

Message 8 of 8
Kent1Cooper
in reply to: 1_0_1


1_0_1 wrote:

The request of antonijo and mine are two sides of the same coin. The polylines of antonijo are on the horizontal plane (he's is looking for the lateral visibility of road) and mine are on the vertical plane (i'm looking for the vertical visibilty of road), ... the concept is the same, but technically on the vertical plane there isn't two sides or an axis like antonijo's example.


That makes sense.  In that case, you can pick the eye-level Polyline when it asks for the center-line, and the road-level Polyline for the limit/boundary -- it doesn't need both sides, but will accept a boundary on just one side.  [You could change the wording of the prompts if you like.]

Kent Cooper, AIA

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

Post to forums  

Autodesk Design & Make Report

”Boost