algorithmic modeling for Rhino
Hi all,
I'm trying to write a simple test plug-in.
The plug-in components need to be able to
use objects of a custom class as parameters.
I'm going to derive the component classes from GH_Component
I think I'll have to use
GH_Component.GH_InputParamManager.RegisterParam()
for input and
GH_Component.GH_OutputParamManager.RegisterParam()
for output
Is that right ?
I also think that to use these methods I need to derive
a class from GH_Param
Still right ?
Then I'd like to know which methods/properties need
to be overridden in the derived class.
Any example on this ?
Or some other info ?
... I hope this makes some sense ...
Thanks
Emilio
Tags:
Hi Emilio,
not entirely correct. Or rather, not the best way to approach this.
The first thing you'll need to do is write your own data type and make sure it implements IGH_Goo (or derives from GH_Goo<T>). This is probably the hardest task, but it is explained in some detail in the Grasshopper SDK docs (look for the "Simple Data Types" topics in the Examples section).
Once you have your own data type, you could choose to use the Generic parameter to handle it. This will prevent you from storing persistent instances of your data anywhere. If you want to have a parameter that can specifically handle your data type, you'll need to write that as well. You can derive from GH_Param<T>, where T is your new data type. Or you can derive from GH_PersistentParam<T> if you want the ability to store local instances of your data.
Finally, to use your new parameter in a component you need to construct it yourself and pass it to the pManager.RegisterParam() method in RegisterInputParams() and RegisterOutputParams() calls. It is generally a bad idea to add or remove inputs and outputs from a component at a later stage.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hi David,
I think I'll try to keep that as simple as possible:
IGH_Goo and Generic parameters
( If I have understood your reply correctly ... )
Thanks a lot !
Emilio
OK, implementing IGH_Goo and using Generic parameters
seems to work. :)
But I have another question.
How to set up a component to export a List ?
I have to export a List of NurbsCurve
and I have not been able to figure how to make it work.
Using Register_GenericParam() does not raise errors
in the component but linking the output
to a Crv component raises an error in the Crv, saying it cannot
convert a Goo into a curve
Using Register_CurveParam() raises an error from the component
complainig that a List is not a curve.
What have I to do to export a List ?
Emilio
Hi Emilio,
exporting lists means calling the DA.SetDataList from within your SolveInstance method.
Are you using SetData() or SetDataList()?
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Aaaaaah ... I thought it should have been something obvious ! ;)
... and _obviously_ I was using SetData()
Works fine with SetDataList().
Thanks again David !
Have a nice weekend.
Emilio
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