Grasshopper

algorithmic modeling for Rhino

Hi,

Is it possible to know how to create component with Plus and minus buttons as scripting components?

I want to add the same type objects, and output them one by one depending of quantity of them.

Thanks

Views: 1086

Replies to This Discussion

Your component must then implement the IGH_VariableParameterComponent interface. Hopefully the 6 or so methods/properties required are reasonably self-explanatory.

Thanks, I have it working. When I want to declare item list tree as input, what has to be changed and is it within this method?

IGH_Param IGH_VariableParameterComponent.CreateParameter(GH_ParameterSide side, int index)
{
Param_Plane param = new Param_Plane();
param.Name = GH_ComponentParamServer.InventUniqueNickname("PPPPPPPPPPPPPPPPPPPPPPPPPPPPP", Params.Input);
param.NickName = param.Name;
param.Description = "Plane" + (Params.Input.Count + 1);

return param;
}

I recommend making CreateParameter as simple as possible. Do all parameter property assignments in the Maintenance function, it gets called a lot more than CreateParameter. I'd suggest only having return new Param_Plane(); in CreateParameter().

Found  param.Access = GH_ParamAccess.list;

What would be the logic for creating multiple outputs that contains one object per output?

For instance I have 1 list of numbers: 0 1 2 3 4, but it can be 0 1 2 or only one number.

In these cases components creates either 5 or 3 or 1 output, each containing one element of the list.

This is not a good idea to do automatically. People spend time and effort hooking up wires to parameters and they'd get cross if you just delete a parameter without asking them. This can easily happen when the user cancels a solution for example.

It's sort of ok to only add parameters and only ask to delete, but I recommend taking the ExplodeTree approach. Add an error/warning to the component if the output layout doesn't match up with the data, and add a menu item which fixes this.

Either way though, you cannot change the parameter layout during solutions. Adding/removing parameters to/from component can be done in either:

  • UI event handler, for example due to a menu-item click or something more advanced.
  • By handling the GH_Document.SolutionStart event.

Thank you a lot I did it just as explode tree component:)

Would it be possible to get more information about Custom GH_Param scripting? :)

I posted message and .cs files in latest thread:

http://www.grasshopper3d.com/forum/topics/c-component-custom-class-...

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service