Grasshopper

algorithmic modeling for Rhino

Massing Models: Creating rectangles that are locked by a specified area but length and width can adjust on the fly

I'm a newbie too grasshopper and am currently  an architecture student.  

I've been trying to figure this out for hours and have searched the forum and the internet. 

What I want to do is create a script that will allow me to specify the area of a rectangle but be able to adjust the sides by pulling or pushing it in where the rectangle would adapt on the other side while the opposite sides get smaller or larger to keep the total square foot the same.  

For example.  Say my classroom size has to be 400 square feet.  I would like to have two sliders for the x and the y that start at the square root of that being 20 x 20, but if I started to pull the slider up on one of the axis, it would adjust the other automatically so that now a 40' foot long length on one side would adjust the other side to 10' keeping the square footage locked.

I don't have a start yet I've been trying to learn this program as fast as possible.  I don't expect anyone to do it for me but a point in the right direct would be awesome..

Thanks! 

John 

Views: 3320

Replies to This Discussion

Hi John,

this is not possible in regular Grasshopper. You can set it up so that you can change the width of a rectangle while keeping the same area, or the height, but Grasshopper is not an iterative solver where you can change some of the properties some of the time and expect other ones to follow suit.

You may be able to achieve this with the Kangaroo plugin, but I'm afraid that's well beyond my skill level.

--

David Rutten

david@mcneel.com

If it's just a rectangle and you are changing the height or width, I don't think you need Kangaroo, but you can't automatically change slider values on the fly unless you use scripting. I guess the best way would be to use events, but this also seems to work.

that's pretty slick!

That's pretty slicker.

Reattached the file with some changes but probably works exactly the same as before.

If I try this again I'll see if I can use the onvaluechange event.

Attachments:

Thank you Vicente!  This is exactly what I needed and will help me throughout the rest of school and beyond.  So if I'm to understand this from a learning aspect.  You created a script in C# that divides the total square footage (z) by whatever either the x or y are set to telling it to adjust the value so that x*y always equals z.  

My question to you now is did you use an outside program to create the script or did you do this all in grasshopper and if you could explain how you did it in a little more detail so that I can learn from what you just did.  

Again thank you so much I won't forget it 

I did it all in Grasshopper. You can create scripts using the C# or VB.NET scripting components. They are located under Math -> Script. You can also download a plugin to be able to script in Python.

The scripting component does the following:

It reads the value of whatever slider you are changing at the time, divides the area by the slider value and sets the value of the other slider (the one you are not changing) to the result of the division.

If you change the target area it sets both sliders to the square root of the area.

A warning, the script uses the nickname of the sliders, called "width" and "height", to find which sliders it should change. If you have other sliders with the same name, it's possible it will select the wrong slider.

To avoid this problem maybe it should try to figure out which object contains the output parameter connected to the input parameter of the scripting component or something along those lines.

Been looking ofr this too..

Genius!!

Thanks

Thanks a lot  Vicente Soler

Hello there, these is possible without a script, heres an example

Attachments:

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service