Grashopper help- Center rectangle not behaving with properly

I am trying to make rectangle with point taken as center, i have achieved this with some operation like divide the length by 2 and displace in opposite direction, you will find that in below file. I made this as a cluster so i can reuse it by making a toolbar of that cluster but the problem is that it works only with xy plane, i want it to accept any plane, can anyone suggest me how to achieve this.
My node tree-

Problem description-
Machine Part (8.2 KB)

I also tried Deconstruct plane but it only provide vector, i dont have idea to combine vector and value to use in move node.

Hi @Kalpit_3d ,

This is because of the unit vector components you are using.

You should be feeding the plane input alone into the Rectangle From Center component.

The X Y inputs can be handled with an expression on the inputs to get the division and other math operands you may need.

Alternatively you can use the Point Oriented component to move locally within the context of a plane. That will allow you to “move” the plane origin location while still being aligned with the plane itself even if the plane is a random rotation for instance.

So if you Deconstruct the plane and reconstruct the plane, pass the XY values from component to component but in-between O to O inputs you would have a Point Oriented component where you input U(X) V(Y) and W(Z) offset number values.

If you only need to go from point A to B with the move mode, you can use a Vector 2pt component, connect the from plane to A and the to plane to B inputs. Then take the output of that and connect to the move component.

I’ll attach a GH file when I’m at my computer next

actually i am very new to grashopper, i know 3d well but i am learning grashopper from youtube , can you suggest some good resources to learn from. atleast basic functioning of all nodes.

1 Like

Deconstructing files shared on these forums is a good place to learn.

Unlike most CAD operations that are open then closed, GH is more of a “flow” and often problems are solved with algorithmic planning.

And one of the great things in GH is you don’t have to commit geometry to Rhino until you absolutely want to.

You can preview every step of the way and keep the file very lightweight and then bake everything you need at the end, ignoring all other “steps” along the way.

Probably the biggest difference transitioning from 3D CAD to GH is understanding data trees and what that means within GH context in relation to geometrical operations.

This concept makes what would be very long and complicated scripts very simple and computationally efficient once you grasp the concepts of data trees.

This is a good resource for data trees:

Another good resource:

I like to think of data tree branches as buckets.

If one branch has a bunch of sand in it, that doesn’t mean it can touch the sand in another branch/bucket but if you flatten bucket B, then A bucket has access to B buckets sand as well, and if you have both flattened, you just have a pile of sand and its harder to organize now. :joy:

For an overview of native nodes I like this resource:

For actually using all the different nodes, probably YouTube is best or these forums.

Some good YouTube channels:

This series from ComputationalDesignDetroit:

This Series:

You don’t need vectors for this at all. The ‘X’ and ‘Y’ inputs to Rectangle are domains so you can construct the domains using ‘-x/2’ and ‘x/2’, like this:

rectangle_cntr_2023Sep24a (9.4 KB)

The plane components and PRot (Rotate Plane) are there just to show that you can provide any plane to Rectangle and this works.

P.S. Here is the same thing in a cRectangle cluster:


The cluster:

rectangle_cntr_2023Sep24b2 (10.3 KB)

1 Like

Yup that’s I was going to mockup with the Construct Domain components.

Also by feeding only positive values or only negative values into the XY inputs you can make a “left oriented” or “right oriented” rectangle.

The domain in this example would be -16.3 To 16.3 in the X input giving you a rectangle “Width” of 32.6 units.

That’s because if you supply only a number instead of a domain for ‘X’ or ‘Y’, a domain is constructed, such as ‘0 To 16.3’ or ‘0 To -16.3’ - but @Kalpit_3d wants the rectangle centered, so the domain approach I posted is the best way, from '-x/2 To x/2’.

I’m not following this part but believe the issue is clear to both of us, eh.

1 Like

That does what i need, thanks for your time and explanation, i need to learn a lot. i also learn that we can use expression like x/2 instead of using division node.

1 Like

thanks for sharing, i will watch in free time

1 Like