Grasshopper

algorithmic modeling for Rhino

Hi there,

 

I'm trying to create a custom parameter. I've created a Data class which inherits from 'Grasshopper.Kernel.Types.IGH_Goo'.  I'm not sure how to correctly implement the ScripVariable interface member:

 

'does not implement interface member 'Grasshopper.Kernel.Types.IGH_Goo.ScriptVariable()'.

 

I've tried this:

 

public Grasshopper.Kernel.Types.IGH_Goo ScriptVariable()
{
      object O = this.m_MeshTopology;
      return O;
}

 

Could anyone help me with this? Thanks!

Views: 1601

Replies to This Discussion

This works:

 

public object ScriptVariable()
{
      throw new NotImplementedException();
}

 

Now the only thing left is a warning in the Param class (GH_Param<Data_MeshTopology>) stating:

 

'Grasshopper.Kernel.GH_Param<Reinforcement_Toolbox.Data_MeshTopology>.GH_Param(Grasshopper.Kernel.IGH_InstanceDescription, bool)' is obsolete: 'This constructor is Obsolete and will be removed in future versions of Grasshopper.'

 

Should I be worried about this / is there another, better way of implementing a custom parameter?

Hi Joost,

 

may I ask why you chose to implement IGH_Goo from scratch instead of deriving from GH_Goo<T>?

 

The ScriptVariable() method is used when the data is plugged into a VB/C# script component. You may not want to give scripters access to your original data as that might give them too much power. Basically I always return a copy of the actual data wrapped in my IGH_Goo class. So GH_Brep returns a const instance of the Rhino.Geometry.Brep, GH_Integer returns a copy of the System.Int32 value and so on.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Hi David,

 

Thanks for your reply. I was actually working my way through some older code of mine, which involved creating / passing custom parameters. This seemed to work fine for me, but youre question got me wondering whether there are better ways of implementation.

 

I've attached the param, data and component code. If you could give me some advice, that would be great!

Attachments:

Since I don't have access to the RTMeshTopology class I cannot compile this code, but I made some changes. Most notably, the data class now derives from GH_Goo<T> instead of implementing IGH_Goo from scratch.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Attachments:

Thanks for helping me out! This looks much better.

 

Joost

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service