Code Red => AutoLISP (Vanilla / Visual) => Topic started by: mihaibantas on April 19, 2018, 03:17:03 AM
Title: Help - Lisp drawing polyline by degree between two parallel
Post by: mihaibantas on April 19, 2018, 03:17:03 AM
Hello everyone, I am new to the lisp world and this forum. I have huge request if someone can help me with a code. I want to join two parallel polylines/lines by a polyline/line drawn automatically to a certain degree.
I've attached a dwg / jpg file for example.
Thanks in advance for your time...have a good day
Title: Re: Help - Lisp drawing polyline by degree between two parallel
Post by: Dlanor on April 19, 2018, 07:43:13 AM
Quick mashup. Minimal checking. If required you can change the angle of the lines, but these must be in degrees or decimal degrees.
There is also scope to add the new lines to the red polyline.
Title: Re: Help - Lisp drawing polyline by degree between two parallel
Post by: mihaibantas on April 19, 2018, 07:59:47 AM
Hello Dlanor First of all I want to thank you for your help ... the code works perfectly
It seems like I'm facing another problem .... Can I adjust the code to make the same line type just as the green line is above the red ??? I attached the example in the picture ... Thank you in advance for your time.
Title: Re: Help - Lisp drawing polyline by degree between two parallel
Post by: Dlanor on April 19, 2018, 08:36:54 AM
Yes, you can adjust the hard coded angles in the main defun (defun c:test). The first setq function contains two variables l_ang (left angle) and r_ang (right angle). They have comments
;<<===== alongside them
The angles are in degrees. If you require the same slope angle (34 degrees) change l_ang to 146 and r_ang to 34 for red below green
I'll attempt to alter my routine to account for red below green, but i can't do anything before this evening.
Title: Re: Help - Lisp drawing polyline by degree between two parallel
Post by: mihaibantas on April 19, 2018, 08:54:48 AM
Hello Dlanor....I made the changes in the code ... and they were successful :smitten: .... but I happen to have both situations in same drawing. What do you suggest me to do ....... to use two different codes with the respective modified variables
Command TEST ======> l_ang to 146 and r_ang to 34 Command TEST1 ======> l_ang to 214 and r_ang to 326.
However wait and modified version of you ... maybe you version much better solution than mine...Thanks again for the interest shown to my problem
Title: Re: Help - Lisp drawing polyline by degree between two parallel
Post by: Dlanor on April 19, 2018, 12:28:39 PM
Edited as attached file superceded
Title: Re: Help - Lisp drawing polyline by degree between two parallel
Post by: Dlanor on April 19, 2018, 03:00:06 PM
Improved Lisp. Type "test" on commandline to run
While loop: Repeats until null selection made for either polyline or enter pressed at same prompt.
Lisp now handles either end of design polyline being on the ground line or intersection point being outside extents of ground line
Test drawing included to test cases.
Title: Re: Help - Lisp drawing polyline by degree between two parallel
Post by: mihaibantas on April 20, 2018, 03:16:33 AM
Thanks again for the last code ... it covers all my related problems :smitten: :smitten: :smitten: I wish you a good day
Title: Re: Help - Lisp drawing polyline by degree between two parallel
Post by: Dlanor on April 20, 2018, 05:08:47 AM
Thanks again for the last code ... it covers all my related problems
Not a problem, i'm glad it helps
Title: Re: Help - Lisp drawing polyline by degree between two parallel
Post by: BIGAL on April 21, 2018, 05:04:58 AM
If these are road cross sections why are you not producing the batter slope any way ???
To make the code much simpler pick pline left side compare start and end pts swap if required, Pick connecting pline, the line angle is not an angle rather a slope 1:ratio so draw a ray line and look for intersect pt if not reverse angle this is cut v's fill. You know which is left and right so there is only 2 solutions per end to try. Even old lisp (inters p1 p2 p3 p4) if true then it intersects at the new point, false reverse angle.