algorithmic modeling for Rhino
Hello,
I've only recently learned to use Grasshopper, and I've already had to use it for a few school projects. My current project is fairly confusing and complex. Essentially, my goal is to create a height field through Grasshopper over a bitmap of a satellite image of the LA River that I've placed in Rhino. The heights are determined by an Image Sample (based on the light and darkness of the color) that I created in Photoshop and is also placed over the bitmap. I think I have this part down. However, I've tried to create conditional statements in order to give myself the ability to modify heights within the height field based on proximity to such things as highways, the LA River, schools, and parks (by representing them as lines and/or clouds of points and using Curve CP or Point CP). I'm having trouble with the lists, though. For instance, if you look at my code, you can see that the part I'm currently trying to get working involves taking the distance from the center point of the mapped grid to the curves representing the LA River. If it is greater than 5, the numerical value for height generated by the Image Sampler is left alone. If it is less than 5, the height is multiplied by 0. I then need to recombine these 2 lists of numbers that were generated back in the same order from which they were originally derived, so that when the heights are then mapped, the 0 heights appear over and around the curves representing the River. To do this, I feel I either need to be able to generate the lists of true/false statements and keep the null sets, or I need a way to regenerate their order in the original listing based off of the Image Sampler. I've spent the better part of 2 days on this and can't figure it out.
I apologize for my wall of text and possibly difficult/inefficient code. As I mentioned, I'm new at this. Any help would be greatly appreciated.
Tags:
It's better to post the actual GH file rather than a picture of it. Nobody wants to spend the time to recreate it off of a picture if the file is available.
I'm aware of that, but unfortunately, the file somehow ended up being 9MB. Do you have another suggestion?
That's a huge grasshopper file. I guess copying off of a jpeg is the way to go on this one. If sherif's suggestion below doesn't help then maybe use dropbox (dropbox.com) to share the file.
Hope this helps.
Also on your own script you can just use the same values you are inputting for "dispatch pattern" to the weave's "pattern" input -you might then need to switch the weave's 0 and 1 inputs to work correctly with the true and false values.
Thanks for your replies. I'll be able to check out the script you sent in a couple of hours. I assume I just double click on the weave component to change the settings for the inputs?
It worked! Sort of. You solved the problem I was having of getting the correct order of the lists of calculations and applying them to the correct boxes. However, I've hit 2 new snags. The first should be easy. Why is it that when I set multiple curves to a curve component and then use Curve CP to determine the distances of a pointfield to those curves does it only consider the first curve selected? Do I have to do separate coding for every curve, or is there a way to make Curve CP choose the closest point on the closest curve?
Secondly, is my code is hugely inefficient. The code itself is 9.6MB, which I get the impression is unnaturally large. When I tried to plug in the final calculations into the height of the Surface Box component, it maxed out my computer's memory and crashed Rhino. I have a fairly powerful gaming laptop that's only 1 year old. That really shouldn't happen. Is there a way to make my code more efficient or reduce the memory it would require? For instance, should I try to model everything in grasshopper instead of connecting it to curves, points, and modules modeled in Rhino? I really don't know.
New code is attached. Thanks again for the help.
Edit: I know the new screenshot has null calculations because I didn't open the Rhino file it was linked to. I was just trying not to cause another crash.
You need to graft the curves list.
You have to uncheck the "save in file" option found in the image sampler settings this will decrease the size of your file.
As for GH crashing i guess you might just missed a wrong/misplaced flatten or graft some where, that would mess up with data matching down the road.
Fixed it. Thanks so much for your help. You really did a lot and I can't thank you enough. The unchecking the saved file really brought the file size down, and the cause of the crashing was that I'd accidentally left one of the List inputs for a Dispatch command attached to the Image Sampler. The grafting and flattening solved the listing issue, although I still couldn't figure out the issue with Curve CP and multiple curves. Regardless, I had few enough curves just to copy the code for each one, so though it's ugly and inefficient, it now does exactly what I want it to. I'm attaching the files, in case you want to see what I was up to. Use the original Rhino file I linked in my first post, as the current one is 55MB with the GH code Baked in.
Thanks again!
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by