Hi all,
I’m fairly new to grasshopper component development. I am trying to set arbitrary geometric or non-geometric objects as “debug outputs” of my components. This is to be used only through the development of the component.
What I have at the moment is a Generic parameter registered as below:
pManager.AddGenericParameter("Debug", "D", "Debug results.", GH_ParamAccess.list);
and a public property like this:
public object DebugOutputs { get; set; }
So for example I set the property to something arbitrarily like this:
// unionBlocks is a List<PolylineCurve>
DebugOutputs = unionBlocks;
which I pass to output of the component like this:
DA.SetData(1, solution.DebugOutputs);
On the grasshopper canvas then I have a separate C# component that casts the object to different things and outputs the results based on the object type. Something like this:
private void RunScript(object x, object y, ref object a)
{
if(x is IList){
var type = x.GetType();
if (type.GetGenericArguments()[0] == typeof(PolylineCurve))
{
var list = x as List<PolylineCurve>;
a = new DataTree<PolylineCurve>(list);
}
// so on and so forth
}
else
{
// get the type and cast it
}
}
Before I go ahead and complete the code, I was wondering if there’s any better way for this already using vanilla grasshopper? I’ve looked at the GH_GeometricGoo class but that seems not quite the solution as the debug outputs can arbitrarily change (eg: polylines, points, meshes etc)
Thanks.
Hoss