[Tool] Offset line by a given distance  SOLVED

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

Mathew
User
Posts: 593
Joined: Thu Jun 19, 2014 7:30 pm

[Tool] Offset line by a given distance  SOLVED

Post by Mathew »

This tool offsets a line, polyline, or polygon by a given distance. It can duplicate the offsets, and has a way to try to capture sections that fold on themselves.

The tool was originally written in response to a forum post by @BearBear. I've since found that it is very useful beyond just offsetting a polyline or polygon. I use it to copy a non-orthogonal line parallel to itself a specific distance, for example. I've since added a few more options, including units and scale.

Installation
Extract the zip file and save into %APPDATA%\Tracker Software\PDFXEditor\3.0\Javascripts
offsetLine v1.0.zip
It will add a button to the add-ons toolbar as well as to the home ribbon:
image.png
Multi-language
The tool can be translated. I've attached the template translation file below and the tool at viewtopic.php?p=186101#p186101 will help editing the file to add translations.
translationData.offsetLine.json.zip

Usage
Select the linework you want to offset, then the tool. It will open a dialog:
image(1).png
Offset distance
  • The distance can be positive or negative to put the line inside or outside the shape. It depends on the direction the shape was drawn. Select the units on the dropdown: mm, pt (points) or in (inches)
Repeat Count
  • The number of offset repeats desired. If offsetting inside a shape, these may start to fold on themselves.
Scale
  • This is the number to divide the distance entered above by to get paper units. ie 100 would mean 10mm on the paper equals 1m. For US customary units, this number is 12 / inch scale similar to used commonly for Dimscale in AutoCAD:
    1/4" = 1'-0" is 48
    1" = 1'-0" is 12
    1 1/2" = 1'-0" is 8
    etc.
Separate Loops
  • When an offset distance exceeds the available space inside a shape, the polygon will start to fold on itself. This option detects where a line overlaps itself and splits that loop off as a separate item. There were a number of approaches discussed in the forum thread, but this one seems to work best for me. For example, if I offset the following shape, the result overlaps:
    image(2).png
    The tool splits the interior shape at the overlap point so that I can delete the part that doesn't make sense:
    image(3).png
Delete Loops
  • The tool will try to guess which is the correct shape to keep. For polygons it will select the one with the largest area. This may not be correct, so you can turn this option off, then manually select and delete the separate pieces that don't make sense.
tl;dr
I tried quite a few iterations on how to handle offsets when shrinking a shape. Proximity to the line was difficult to handle, because the original line may cross itself intentionally. I settled on the split at self-crossing approach because it was easiest to implement and seems to handle most cases fine.

The results can get really weird when offsetting a curved shape made up of polylines, even for relatively simple shapes. This is related to the way I'm offsetting the line: I split the angle between the two adjacent lines, and offset the point along that angle.
image(4).png
The tool handles the little anomalies at the corners fine because their area is so small.

This method will not guess correctly which loop to keep if the correct loop has a smaller area, so in those cases it's better to leave "Delete loops" unchecked, and manually delete:
image(5).png
You do not have the required permissions to view the files attached to this post.
Last edited by Mathew on Mon Mar 24, 2025 10:32 pm, edited 1 time in total.
User avatar
⚜ Kenny Lemens, P.E. ᵂᴵ
User
Posts: 42
Joined: Thu Jan 23, 2025 4:09 pm

Re: [Tool] Offset line by a given distance

Post by ⚜ Kenny Lemens, P.E. ᵂᴵ »

Greetings;

Thank you for this script! I was planning to create this feature sometime in the future, but it looks like you saved me the hassle; much appreciated.

May this be of Good Help;
⚜ Kenny Lemens, P.E. ᵂᴵ
User Plugins: https://is.gd/A9HMPG || PDF-XChange Icons: https://is.gd/Z4GeG8
[Migration] Revu Bluebeam 17 to PDF-XChange Editor: https://is.gd/8Xs1OF
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19902
Joined: Mon Jan 12, 2009 8:07 am

[Tool] Offset line by a given distance

Post by Stefan - PDF-XChange »

:)
Reflection
User
Posts: 1
Joined: Mon Jun 30, 2025 3:36 am

Re: [Tool] Offset line by a given distance

Post by Reflection »

I just made an account to say thanks for this fantastic tool which enabled me to effectively show developable areas based on zone setbacks for a whole subdivision in about thirty minutes. This would otherwise have been a daunting task:
image.png
Suggestions to make this even more useful for my niche use case if anyone has the skills and time:
1. Allow specification of segments to be offset by a different amount (i.e segment 1: 5m, all other segments: 3m).
2. A similar tool to allow for creating parallel line segments as you click in a Polyline.
You do not have the required permissions to view the files attached to this post.
User avatar
Dimitar - PDF-XChange
Site Admin
Posts: 2239
Joined: Mon Jan 15, 2018 9:01 am

Re: [Tool] Offset line by a given distance

Post by Dimitar - PDF-XChange »

Hello Reflection,

Thank you for your suggestion.

Let's hope that Mathew, can think of a way to do this :-)

Regards.