Author Topic: Draw a polyline with a certain offset  (Read 5142 times)

0 Members and 1 Guest are viewing this topic.

Coder

  • Swamp Rat
  • Posts: 827
Draw a polyline with a certain offset
« on: August 24, 2019, 03:50:50 PM »
Hello everyone.

I am trying to draw the Green polyline by picking points on the closed white polyline with a certain offset 0.05 but I stuck when I reached number 6 up to 9 and I don't know how to keep track inside the polyline all the time.

The shape of the white polyline might be varies without arcs all the time.

Thank you in advance.
« Last Edit: August 24, 2019, 03:55:52 PM by Coder »

Coder

  • Swamp Rat
  • Posts: 827
Re: Draw a polyline with a certain offset
« Reply #1 on: August 25, 2019, 10:25:20 AM »
I forgot to tell is that the numbers ( 1 to 9 ) represent the position where the user will specify a point.

For me this is a challenge but is it as well to you?

Thank you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Draw a polyline with a certain offset
« Reply #2 on: August 25, 2019, 10:33:27 AM »
Some helpful code here:  https://www.theswamp.org/index.php?topic=43902.0
But the offset in a different direction within one pick session would require input from the user to change the offset direction.
attached is a Very Old (2003) routine I still use for typical offsets.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Coder

  • Swamp Rat
  • Posts: 827
Re: Draw a polyline with a certain offset
« Reply #3 on: August 25, 2019, 10:47:45 AM »
Thank you CAB.

As you can see that I am looking for special offset and not normal offset.

Any ideas on how to change direction of the offset when required ?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Draw a polyline with a certain offset
« Reply #4 on: August 25, 2019, 12:27:40 PM »
Lee Mac has a routine that puts text on a polyline and his routine caught key presses to modify the location of the text.
I think that technique could also be used here to swap the direction of the offset.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Coder

  • Swamp Rat
  • Posts: 827
Re: Draw a polyline with a certain offset
« Reply #5 on: August 25, 2019, 12:52:56 PM »
Lee Mac has a routine that puts text on a polyline and his routine caught key presses to modify the location of the text.
I think that technique could also be used here to swap the direction of the offset.

Thank you CAB.

I hope Lee would offer his opinion regarding this issue as well as the other experts in this great website.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Draw a polyline with a certain offset
« Reply #6 on: August 25, 2019, 01:00:17 PM »
Here is Lee's routine for labels:  http://www.lee-mac.com/label.html
Study how he handles user input.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Draw a polyline with a certain offset
« Reply #7 on: August 25, 2019, 01:08:59 PM »
Here is another approach, get point or keyword where the key input could change the side to offset.
This also is old code that could be modified to get the user input.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Coder

  • Swamp Rat
  • Posts: 827
Re: Draw a polyline with a certain offset
« Reply #8 on: August 25, 2019, 02:22:11 PM »
The user input is not that difficult but the rerouting is the cumbersome to me.

BIGAL

  • Swamp Rat
  • Posts: 1398
  • 40 + years of using Autocad
Re: Draw a polyline with a certain offset
« Reply #9 on: August 25, 2019, 08:50:25 PM »
Maybe when you do pt4 -> pt5 then like CAB getpoint/string,  "Extend" is selected so pt6 is extension to new pline and offset side is reversed. Same with last point if end is not square a trim/extend is required.
A man who never made a mistake never made anything

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Draw a polyline with a certain offset
« Reply #10 on: August 26, 2019, 03:32:22 AM »
You can create both offsets and then check which of the two has all its points inside the bounding polyline.

Coder

  • Swamp Rat
  • Posts: 827
Re: Draw a polyline with a certain offset
« Reply #11 on: August 26, 2019, 04:52:04 AM »
You can create both offsets and then check which of the two has all its points inside the bounding polyline.

Thank you for your kind reply.

That's a very good idea but I am struggling with the coordinate point between 5 and 6 , please see the image below.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Draw a polyline with a certain offset
« Reply #12 on: August 26, 2019, 05:56:34 AM »
Basically the user has to pick point 6. With tracking this should not be a problem.
If you want to grab the point programmatically (allow the user to click near point 6) then the inters function is your friend:
  • Identify the segment nearest the selected point.
  • Use the inters function to find intersections with other segments that are on that segment.
  • Find the intersection nearest the user point.

Coder

  • Swamp Rat
  • Posts: 827
Re: Draw a polyline with a certain offset
« Reply #13 on: August 26, 2019, 06:42:29 AM »
Thank you.

Sometimes I pick coordinate ( number 5 ) and sometimes ignore it to number 6.

Just for clarification, the green polyline represents the offset and the target polyline.

Is it possible not to ask the user to specify a point for changing direction and get the intersected point for later offset target polyline?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Draw a polyline with a certain offset
« Reply #14 on: August 26, 2019, 08:21:04 AM »
Yes, the routine must detect that 6 is not on a adjoining segment.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.