algorithmic modeling for Rhino
Hi
has anyone managed to use thir own custom class as an output parameter to a GH component?
I cant seem to do it and GH hangs after the pManage.Regsiter.Param method is called. Im running
0.6.0059.
Some psuedo code to get the ball rolling;
Namespace MyLibrary
Class MyClass
Inherits Grasshopper.Kernel.Types.GH_Goo
End Class
End Namespace
Now in the RegisterOutputParams sub.......................
Protected Overrides Sub RegisterOutputParams(ByVal pManager As GH_OutputParamManager)
Dim ghMyClassParameter As Grasshopper.Kernel.GH_Param(Of MyLibrary.MyClass)
pManager.RegisterParam(ghMyClassParameter, "MyClasses", "MC_P", "MyClass Output Parameters")
End Sub
It fails after execution of the regsiterparam method, i note that ghMyClassParameter has a value of null and have unsuccessfully tried casting from a new instance, say:
Dim myClass As New MyLibrary.MyClass
myClass.CastTo(ghMyClassParameter)
I still get a null instance for ghMyClassParameter
Cheers
Tags:
David et al.,
Just following up on this now. Quick question: I've made a data type, and now I'm trying to make a parameter for it. After deriving from GH_Param(Of MyType), what is the constructor supposed to look like?
Public Class MyParam
Inherits GH_Param(Of MyType)
' Constructor
Public Sub New()
MyBase.New(argument???)
End Sub
....
End Class
(The SDK shows an example deriving from GH_PersistentParam, but my type is not serializable.)
Thanks,
Jon
The constructor for a class that derives from GH_Param(Of T) needs to call the base class constructor with a GH_InstanceDescription. Like so:
Public Sub New()
MyBase.New(New GH_InstanceDescription("MyType", "MT", "A parameter for MyType", "Params", "Primitive")
End Sub
Basically it defines what your parameter is called when you create a standalone version of it and where on the tabs it appears.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
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
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by