algorithmic modeling for Rhino
Dear GHA developers. As you may have noticed the preferred gui for variable parameters has changed in 0.8.0060. The old gui is still available, but has been marked Obsolete and will soon no longer be visible in Visual Studio autocomplete.
If you have a GH_Component class that implements IGH_VarParamComponent and you wish to switch over to the new gui, please do the following:
Methods to implement for IGH_VariableParameterComponent:
I'll try and write a topic for this in the SDK documentation as soon as possible but until then, feel free to ask any questions about this here.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Tags:
Hi David,
thanks for the great improvement. I have two small questions:
- Is it possible to access the current parameter list from for example inside a CanRemoveParameter()? (To enforce a certain amount of parameters for example?)
- What kind of values can GH_ParameterSide side have? (How to determine which side we're on?)
Thanks a bunch!
Yes, all code running inside a GH_Component derived class has access to the current parameters. You can use the Params property to examine and change the input and output parameters of a component. For example, let's say the user is allowed to remove any input parameter, but only while we have at least 3 inputs left. I.e., we do not allow the component to have less than two inputs. In that case the implementation of CanRemoveParameter would look as follows:
The GH_ParameterSide enumeration only has Input and Output.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Ok, great! Thanks a bunch.
Would it be easy to force a component to expire after a label has been changed? Calling this.expireSolution(true); from the VariableParameterMaintanance method does not seem to do the trick.
The Params object has 3 events which you can register that will inform you when parameters change:
ParameterNickNameChanged(ByVal sender As Object, ByVal e As GH_ParamServerEventArgs)
ParameterSourcesChanged(ByVal sender As Object, ByVal e As GH_ParamServerEventArgs)
ParameterChanged(ByVal sender As Object, ByVal e As GH_ParamServerEventArgs)
The first two are only used for specific events (nicknames and sources respectively), the third one is always raised (even when one of the specific ones is raised first).
You can register handlers for these events in the component constructor if you want.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
A quick bug report:
Params.ParameterNickNameChanged does not fire unless I hit return after renaming the parameter. If I simply click on the canvas and allow the pop-up to loose focus, the parameter nickname is changed, but the Params.ParameterNickNameChanged event does not fire. I can send over sample code if you'd like.
Apologies if this is not the proper venue for bug reports.
-Kyle
Got it. Thanks.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hi David.
Could you please share a bit of code demonstrating how to register handlers to this events in a component constructor??
I am trying to trigger some behavior when the nickname of a component changes, then I wrote this behavior on the VariableParameterMaintenance() method, but apparently it is not running when the Nickname is changed.
Thanks
Manuel
Hey David - would it be possible to provide some examples of complete component classes that effectively implement this behavior? I am struggling to properly implement it in my own code. I'm especially interested in the behavior of the Sort component, among others, which automatically adds corresponding output parameters when new input parameters are included.
I copied the variable parameter logic of the Sort component into a separate text file (attached). Let me know if you need more.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thanks a bunch!! I will study this in detail.
After finished a standard component, I'm trying to make a simple Variable Component in C#, and can't figure out what to return in method:
CreateParameter().
In your code (VB) you return a new Param_GenericObject() but I can't find where the IGH_Params are in C# (neither in the sdk documentation).
I can't also find Param_Integer(), like you said in OP.
I know I'm missing something but I don't know what.
I think I managed to figure that out, and the component runs, but when I press '+' in Grasshopper nothing happens.
I'm attaching the code of the component. When I found a solution I'll post the corrected one in order to keep it as a simple c# example of this kind of components.
Hope someone can help :)
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
© 2024 Created by Scott Davidson. Powered by