Grasshopper

algorithmic modeling for Rhino

Hi David,
I have done my GH_Goo T class, but I have problem to load it like tree access.
You said:
"2) Create a new class that either implements IGH_Param or which inherits from GH_Param(Of T), where T is the class you created under (1). Be sure to fill out all required fields."

Can you explain how to fill all  required fields, please? (how to make constructors)

It is correct to register data like this:

GH_VTKparam myParam = new GH_VTKparam();
pManager.RegisterParam(myParam, "x", "x", "xxx", GH_ParamAccess.tree);

Thanks!

Views: 636

Replies to This Discussion

Hi Lukáš,

that appears to be the correct syntax. You fill out all required fields or Visual Studio won't even let you compile the project. So clearly you've done that.

I'll need to see much more code than this though, you can mail it to me or post it online if you don't mind other people seeing it.

--
David Rutten
david@mcneel.com
Seattle, WA
I think I have solved it.
Here's my class that implements GH_Param
(GH_VTKparam my class which I have created using an example from the documenation)

And I register my param in RegisterOutput(Input)Params method like this:

GH_VTKparam vtkParam = new GH_VTKparam(new GH_InstanceDescription());
pManager.RegisterParam(vtkParam,"x","x","x");

it works, It is Ok , haven't I forgotten about something important? ? Is there anything what is useless ?
Thanks!
ps: VS works without constructors but Grasshopper throw the error
Attachments:
Try adding a constructor with no arguments, like so:

public GH_VTKparam() : base(new Grasshopper.Kernel.GH_InstanceDescription("VTK Data", "VTK", "A collection of VTK values", "VTK", "Params")) { }


--
David Rutten
david@mcneel.com
Seattle, WA
Good idea. The registration is much easier in input/output methods.
Thanks!
Lukas
If your parameter is exposed in the toolbars, it needs to know what to call itself when you create a new floating instance of it. So the blank constructor is used when the parameter is not part of some bigger assembly.

--
David Rutten
david@mcneel.com
Seattle, WA
My GH_Param class:


class GH_ParamPointData : GH_Param < GH_PointData >
{
public GH_ParamPointData() : base(new Grasshopper.Kernel.GH_InstanceDescription("PointData", "PD", "A collection of VTK point data values", "VTK", "Data"))
{
}

//constructor 1 overload
public GH_ParamPointData(GH_InstanceDescription nTag):base(nTag)
{
}

//constructor 2 overload
public GH_ParamPointData(GH_InstanceDescription nTag, GH_ParamAccess access): base(nTag, access)
{
}

//component guid
public override Guid ComponentGuid
{
get { return new Guid("{08ad9ebb-f5c2-4f74-93c6-34d87512bc2c}"); }
}

public override string TypeName
{
get
{
return "PointData";
}
}

//component icon (optional)
protected override Bitmap Internal_Icon_24x24
{
get { return VTK.Properties.Resources.point_24x24; }

}
}


method to register my param:


pManager.RegisterParam(new GH_ParamPointData(), "PD", "PD", "A collection of VTK point data values", GH_ParamAccess.tree);


Attachments:
That all looks correct to me, there are no more problems now right?

--
David Rutten
david@mcneel.com
Seattle, WA

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service