# Split Closed Curve to equal dimensions using a macro

I have a Rectangle ® closed curve and I’d like to split the curve into two equal closed rectangles ® using macro commands.
I have a Rectangle measure 24 x 15, I’d like to place another rectangle in the center with a .125 width and split the 24 x 15 R to 2 equal 11.0625 x 15 rectangles. All of this using macros and without hardcoded measurements other than the .125 I’d like to split the curve with.

Any thoughts?

Hello - can you please post a Rhino file containing the input and desired output? It all sounds like a script to me but I am not picturing the thing very clearly.

-Pascal

Begin with:

End Result

Strictly using .125 as the spacing between the two curves and not knowing the other dimensions previously.

to do this without a macro I basically just trimmed the edges of the larger rectangle and trashed the remaining portion of the split rectangle measuring .125 x whatever height (doesn’t matter)

You can do this with CurveBoolean - draw your thin rectangle in the middle past the big rectangle top and bottom, then select the two, call curveBoolean with DeleteInput=All and click inside the two bigger rectangle halves/Enter

Or, draw a line from big rectangle side midpoints, offset that both sides half of your .125" then select all and CurveBoolean as above.

This could probably be scripted, but I think a macro would be too complicated.

1 Like

Hello - assuming your rectangle is always aligned to the world, this ought to do what I think you are asking -

DivideRectangle.py (1.7 KB)
@jeff27t10 - a little friendlier - you can set the gap. But it assumes you are picking a world aligned rectangle, it does not check.

To use the Python script use `RunPythonScript`, or a macro:

`_-RunPythonScript "Full path to py file inside double-quotes"`

-Pascal

1 Like

This worked beautifully within the macro, other challenges will surface but I will attempt to figure it out without badgering the forum. Otherwise, I’ll post another question.

Thank you all