Rectangle from line, modification

Hello,

I am trying to write a script but my skills are not good enough. I can only do simple marcros.
Could you guys help me with this please.


As you can see above I am trying to make script working like this:
-when I click on already made line , script will make rectangle modified as on picture.

  • same would go for curve or spineline
  • script would take lenght from line and made same lenght rectangle, width would always be 80mm
    -then it will add 5mm to top and bottom
    -and 10mm for the sides

Thanks and best regards
@Czort

forum-fatten.gh (8.8 KB)

if you dont mind using grasshopper, this is fairly easy. feed your lines/curves into the Crv component

Hi @Will_Wang,

I dont have grasshopper, tho it looks easy to make in it.
First line is ok, but second one (curve) - I want to have rectangle, not curved box.

Thanks for help but I would like this as script for Rhino.

How do you want to define the rectangle relative to the curve? Are you looking for an axis-aligned box, some sort of expansion of a minimum XY bounding box, or some other type of alignment?

–Mitch

@Helvetosaur

Rectangle could have start point at 0,0,0 even(something like _squish). Main dimension would be line lenght. I dont know C or any othe programing language to do it. I dodnt know even how to start it.
Command that reads the line lenght would be helpful.

Thank you for contact and sorry for delayed answer

-Czort

Ah, so you’re not looking for something that actually encloses the line, just a rectangle 90mm high based on the curve’s length + 20mm, is that it? That’s fairly simple to do.

–Mitch

@Helvetosaur

Yes. :slight_smile: Its excactly what Iam looking for.

Main problem for me is, that i dont know how to take line lenght and put it as a value for later use.

-Czort

You can try the following on for size…

Instead of hard-coding your offset values, I set up user choices with them as defaults, you can change them if you like. Any changes will stick between uses in the same session. It will create rectangles for as many curves as you like at one time, and stack them vertically along the Y axis with a user set space between them. The rectangles and the corresponding original curves are marked and grouped with text dots so you know which ones correspond.

CreateCurveLengthRectangles.py (1.7 KB)

–Mitch

Hello @Helvetosaur,
I had problem at first but I got it :slight_smile:
Thanks so much It works perfect !
Big cheer to you !
-Czort

You should run in python editor, Tools > pythonscript > run

May be i missed something, but i think the script not working as expected, rectangle created is not aligned with Bases curves.

Ok , seems to work as expected for Czort.

Yes, that’s what he asked for…

–Mitch

1 Like

Yes, @Helvetosaur is right, but there is one small problem:
_space between rectangles does not work (changing values does not affect rectangle)

Rest of code works perfectly

-Czort

Spacing only changes the spacing of the layout between successive rectangles (if you input more than one curve), does not affect the rectangles themselves. Seems to work here.

The “Length margin” is how much to add to overall length of the curve to get the length
The Height is the total height of each rectangle - it’s not an additional factor

Were you expecting it to do something different? The script can be adjusted…

–Mitch

Oh i see. Could we change “space between rectangles” for “height margin”?
Script would work like this:

  • I click on curve (curve lenght 500)
  • lenght margin <20> enter (curve lenght 520)
  • rectangle height <90> enter (rectangle 520x90)
  • height margin <20> enter (rectangle 520x100 - succesive rectangle)
    You can skip space between rectangles please.

Thanks again for helping me.

If your rectangle height is 90, and the height margin is 20, wouldn’t the final rectangle be 110 not 100?

Yes, sorry.

OK, try this one:

CreateCurveLengthRectangles2.py (1.7 KB)

–Mitch

It works great. Thank you Mitch.
This will speed up my work :slight_smile:
Best regards
-Czort