Grasshopper

algorithmic modeling for Rhino

output parameter index[] too high or too low for component

Hi all

     I want to make a component to classify the input geometry,there no output at the beginning(the output will be create after geometry is given).It works well before I use the "SetDataTree()".It says "output parameter index[] too high or too low for component". It weird! is it a bug?

  someone can help me? thanks

(here is my code and screenshot)

Views: 1390

Attachments:

Replies to This Discussion

Hi Tom

  thank your so much for your solution,but I find it still doesn't work (I didn't completely according to your way to do it),do you put your code in the VS to test it?

You are not allowed to change the topology of the network during solutions. That means no deleting objects, no adding/deleting wires, no adding/removing inputs or outputs. You're also not allowed to expire objects during solutions.

Tom's approach is roughly correct, with the exception that he calls CreateOutputs() from within SolveInstance. What you need to do is:

  1. Inside SolveInstance figure out which outputs you need for the current solution.
  2. If you currently have those outputs, assign data to them and you're done.
  3. If you don't, then you must store this information somewhere safe, I recommend a class level variable.
  4. You then schedule a solution with a callback to some private method in your component class and you return without assigning the data (or, alternatively, you can assign whatever outputs you do have).
  5. When the next solution starts, your callback method will be invoked and this is where you read your local data and modify your outputs accordingly. Now, whenever SolveInstance is called your outputs will match your data.

Do note that some components in Grasshopper whose output topology depends on the input data do not take this approach. Have a look at Explode Tree for example. It will modify the outputs only when the user asks for this via the menu.

Hi David
thank you for you answer,but did it as your said,but it still doesn't work ,do I misunderstand your mean?(I post my file)

Attachments:

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service