Help - Extending a perpendicular line from the end of one line to another

Hello everyone,

I have a set of lines that are parallel to each other with different dimensions. I want the shorter lines to draw a perpendicular to the nearest longer line from their end points and close the curve to form a rectangle. The first picture shows the current situation. The second picture shows what it should be like.

Your help will be much appreciated. Thank you so much :slight_smile:


Lines.gh (9.6 KB)

The example that you uploaded is different from what you show in the screenshots. It features only a single smaller line, not two!

Something like this?


Lines_rev1.gh (12.9 KB)

And check this as well.


Lines_rev2.gh (23.9 KB)

Oh I am sorry, it did not save properly. I attach it here:
Lines.gh (18.3 KB)

Wow, That’s very cool. It is awesome when you want to control the location of boxes using domain. In my case, we have to make a box by extending two perpendicular lines from the both ends of the small lines (and then it touches the longer line and stops to close the curve). I hope I explained it better this time. I am attaching the file here too (in previous file there was only one small line). Thank you so much for your help. :slight_smile:

Lines.gh (18.3 KB)

You can simply do something like this:

Lines-rev.gh (14.7 KB)

This is amazing. Thank you so much. I can use it for my work.

Cheers! :slight_smile:

Hi, I have another small query. I have a square (let’s say 2200 mm length and width each) and I want to extend it in x and z-direction to make it 2300 mm each by adding 50 mm on both sides considering the centroid of the square. I was trying to use Scale NU but it considers the current size of the rectangle as 1 and I am confused with that. Or I just add 1.050 on x and z vectors for it and it will be correct
Could you please help me with it too. Thanks a lot :slight_smile:
Scaling.gh (9.8 KB)

One way to accomplish this is by remapping your sizes, like so:

Screenshot 2022-02-23 at 12.57.09

Scaling-rev.gh (7.0 KB)

That’s a very good approach. Let’s say I do not know if the rectangle or square is 2200 m long. I get this rectangles as an output and I have different sizes of rectangles so I cannot deconstruct the rectangles and use their dimensions. Is there any other way I can add 50 mm to a rectangle without considering its original dimensions? For example by deconstructing the rectangle into individual curves and then extending the curves on both sides by 50 mm and then connecting them again to form the rectangle. Is it possible? I am trying to do it but unable to.
Thank you so much!!

Yes, you can deconstruct the rectangles to get their widths and heights!

Screenshot 2022-02-23 at 15.15.04

deconstruct_rectangle.gh (6.1 KB)

It works however, I have a large number of rectangles and I am not sure if it is time-efficient for that. I could sense that it could be done using List (sort) nodes, I have been struggling to find the combination for it. I have already asked you enough questions and taken enough of your time but it would be a hugeeee favour if you could help me in this last question. I am attaching the purged GH file with internalised data where we have rectangles (windows) and I want to increase these rectangles’ width by 50 mm on both sides and then form a new rectangle. Is this doable? I feel embarrassed too for keeping on asking questions. You can answer if you have some idle time.

Thank you so much again.
Rectangles.gh (23.3 KB)

Here you go!

And props for getting rid of the generic username.

Rectangles-rev.gh (24.7 KB)

1 Like

haha, I saw your post regarding that and I got to know it can be changed. Prior to that, I was thinking I cannot change it which was disappointing. :smiley:
Thank you so much for your time and help :slight_smile:

You’re welcome.

Hello again, the script you developed is correctly working on the XZ plane with 50 mm extension but on the YZ plane, it is not exactly 50 mm, it is 64.33 mm. Could you please look into that? I feel it is due to the Dot product of Z but I am not sure. I am trying alternatives which are only making it worse :frowning:

Sorry to bother you again and again!!

Not really. It’s due to the initial rectangles not being cleanly constructed. Some thus have different plane orientations, which causes the deconstruction to provide y-values that in other planes are x-values and vis versa.

Here’s a fix!

Rectangles-rev-2.gh (29.2 KB)

That is soooo coooooool. It works perfect and it makes sense too.

Thanks again :slight_smile: