I want to draw multiple boxes using the Drawboxes()function and the pickrandom()function.
When i run the code, it gives me an error saying ”for single box use Drawbox()”
But when i try to run it again after two consecutive times it displays the output which 5 random boxes.
I have attached the copy of the code.
Is my syntax wrong?? If yes what is the correct one?
Yes, you need to add Drawbox() because then it will work if you don’t add it than you will just keep getting it wrong so try Drawbox().
Hope I helped!!
But with Drawbox() i can draw only one box of random color.
I want to draw multiple boxes in a single command using Drawboxes().
Well try with one Drawbox() and see what happeneds
In your screenshot, is that all of the code or is there more underneath?
Sorry forgot to add screenshots in last post
Ok. So i tried it with drawbox() as suggested.
Please have a look at the screenshots. I have labelled them as code-1,2 and 3.
i use drawbox() in this code and the output is one box. If i want another box i have to add one more drawbox(). If i want to draw multiple boxes i have to add multiple drawbox()
I use the drawboxes() function here to draw multiple boxes. But it gives me an error.
I just run the code from Code-2 multiple times and it gives me the output as shown in the screenshot…is my desired output.
My question is why does it show error first…and when i run the same code again and again it shows desired output?
Thats the full code nothing underneath. I have posted the screenshots again.
I think the drawboxes() usually runs with letters to tell it what color to do:
I think that would do a red box, a green box, a red box, and another green box.
This link will give you the list of colors & their abbreviations in grasshopper:List of Colors for Coding in Grasshopper
yes… i too think that the drawbox() and drawboxes() use different formats as argument and thus the error in Code-2.
But what about the output in Code-3, it gives the desired outcome… without any error.
That is kind of weird code-2 and code-3 are the same so it shouldn’t say error on code-2, did you recheck the codes? Maybe you did something wrong, recheck code-2 then look at code-3 and see if you did something wrong.
Hope that helps!! (* ^ ω ^)
Actually, If you want it to pickRandom different colors, you need to use several drawbox(pickRandom(color)):
I did check. I know both codes are same, but they give different outputs. May be a bug with GH interpreter.
Thank you for the support the though.
Yes, that seems to be the only way.
Also i just realized that functions like pickrandom() and Drawbox() are actually created by GH to help us learn the concepts easily. So there might be a bug.
Anyways thank you for the support.
I went to the code playground-glossary-drawboxes().It said:
Draws a square for each letter provided. Each letter corresponds to a color. For instance, 'b' is for 'blue' and 'o' is for 'orange'. A space moves the boxes onto a new line.