Need help with the offset curve with a fixed distance

Hi all,

It may be simple to you but I need help on GH scripting for the offset curve.

As can be seen in this image, there are two blue curves 7.7m apart, and I’m attempting to discover a ‘X’ distance where each line’s start/end points are shifted by the same ‘X’ distance, resulting in these two curves with a specified offset distance between them. And I want to predefine the offset distance in the script so that just the ‘X’ distance varies. The image depicts the ideal circumstance, and I attempted to write a simple script. I could define the X and make the offset distance variable, but I couldn’t manage to do in reverse.
It may not be much use, but I’d like to attach a brief script I made for your reference…
Please help me find a solution to this problem. Thank you!

Offset with fixed distance.gh (13.8 KB)

Something like this?

2 Likes

This is actually quite easy.
The trick is to set two planes that have the x axis coincident to the diagonal line, and the y axis in the world z direction.
Then you draw two sufficiently long parallel lines to define the left and right border.
You can then calculate the intersection of the right border with the rightmost diagonal plane, same for the left border and left-most diagonal plane. That should result in two points.
Take the right point and and move it some distance -d in the world y direction (downwards), and take the left point and move it distance d (upwards).
(Here I’m using d as the equivalent to your sketch x. )
Draw the corresponding lines.
Use a little bit of trigonometry to project the line onto its respective plane.
Connect the endpoints of the line and the projected line.

something.gh (13.5 KB)
this is how to get the x coordinate variable

this was done with some goals

  1. to be able to set the offset between the diagonal lines (as well as the angle)
  2. to be able to se the distance between the left and right borders
  3. to be able to set the “X” dimension

what it cannot do

  1. doesn’t satisfy the constraint of the horizontal lines being about 2350mm
  2. doesn’t check if the combination of set constrains above produce triangles that have a corner outside the left/right borders
  3. doesn’t satisfy the height of the rectangle (not necessarily 7700mm)

note: i used meters instead of mm (so 1.1 and 2.9 instead of 1100 and 2900)

but it should get you started.

That’s a complicated approach and I don’t see the original lines anywhere in your definition…

1 Like

How?

What is ideal?

The bounding rectangle? Is it supposed to remain 2900 x 7700?

Or the ‘fixed’ offset?

If yes, why were you making the offset vary?

Or the length of the triangle base segments (2350)?

If yes, then why not ensure top and bottom segments of the bounding rectangle measure 2350?

So the offset does vary (to affect the X distance)? Wasn’t it supposed to be fixed? Topic title reads “offset curve with a fixed distance” :thinking:

Weren’t you supposed to ‘discover’ this ‘X’ rather than define it?

I think, as you stated, this is ‘simple’ but the explanation is less simple than it should?

Sorry for the questionnaire - I want to help but I am dumb :slight_smile: - I like what @martinsiegrist did though.

*(edit) therefore here’s my ‘inadequate’ version where the bounding rectangle is made first, the 2350 lines are determined (and kept at 2350) second, and ‘X’ is both determined and discovered third :rofl: - hence the offset is fake, neither set nor fixed lol - maybe the only thing discovered - since I thought I understood but I didn’t, I took the liberty to do it this way.
Offset with fixed distance.gh (14.8 KB)

1 Like

Welcome to geometric relationships and constraints.
From OP’s description I interpreted that he wants to make x variable. From that I took a guess about which constraints he wants satisfied.

Thank you! @martinsiegrist

This is exactly the solution I was trying to figure out!

1 Like