Help! My script doesn't work!
When you start building your own scripts for the first time, you most certainly will run into problems. It can be quite frustrating when you imagined a script that does not give you the expected result. This tutorial will give you some general advice how to solve these problems.
Find the problem
Grasshopper has the nice feature that objects in Grasshopper highlight with different colors in Rhino. Usually, when the preview of an object is on, but a node is not selected, the color is transparent red. If you then select the node, it will turn green.
If highlighted selection is not working, make sure "shaded preview geometry" is turned on.
Solving problems sometimes takes a while. It can be useful to turn off the preview of all nodes and then step-by-step turn on the preview, to see what happens to the object in Rhino.
Furthermore, it can be helpful to check the output of each node by holding your mouse on the output. The panel that occurs, displays information about the type of data that is outputted, the amount of items in the output and the data structure.
By connecting a panel to the output, you can clearly scroll through all the data in a script. Always try to imagine the data you are expecting and compare it to the visible data.
If you are still not certain what causes the problem in your script. Make sure you go through all the inputs and outputs of a node. Hold your mouse on all inputs to see what data they require.
Sometimes, huge amounts of data from an output can be a bit overwhelming. There are two Grasshopper nodes that can help you: List Item and Tree Branch.
Using the List Item node, you can extract a specific item from an output. By changing the index input, you can scroll through all the data.
If the output consists of a data tree, you will also need the Tree Branch component. By simplifying the Tree input with your right mouse button, you can extract a specific branch.
Simplify the model
If you are not able to find the solution for a problem, you can try to input some extreme cases. For example, if a script is based on a collection of points, try to only use one point. On the other hand, if the input is numerical, experiment with very high values, negative values or even multiple values. This can sometimes indicate what causes a problem in your script.
Solve a problem
When you have developed a script that is not giving you the expected results, in most cases you can also use another method. Most results can be achieved in three or even more ways. Scrolling through available nodes in the standard Grasshopper function collection can give you inspiration.
Remember that you can find the location of a function by clicking on Ctrl + alt + LMB on a node.
When your scripts are becoming more advanced, you may notice that most of your problems occur due to incorrect interactions between Data Trees. These problems can be quite complex sometimes and may take a while to solve. If you are stuck, it is recommended to take a look at one of the following tutorials, which give you examples of how you can interact with and manipulate Data Trees.
Ask for help
Usually your fellow Grasshopper users are very helpful on the McNeel Grasshopper Forum. Clearly explain your problem, add your script and show some images. In most cases, people will try to help you within several hours.