In my VS component I’m trying to read input as GeometryBase (which works fine in the ScriptComponent version, and I need to handle generic data) but I keep getting runtime errors. The geometry coming in is Point3d when it crashes,
private GeometryBase m_geoa;
private GeometryBase GeoA {
get {
m_geoa = null;
if (!m_DA.GetData(0, ref m_geoa)) // <--- Kaboom!!
throw new System.ArgumentNullException("Invalid in-parameter 'GeoA' (GeoA).");
return m_geoa;
}
}
How should this property be typed? (this is generated by my CodeGen, spitting out zillions of properties…). Need to get the types right.
I should mention that the component is a “custom dispatcher” and all I need to do with the (Geom) Input value is to pass it on to a (GeometryBase) Output, according to some other boolean Inputs.
So, what I need is a type, or conversion between types while passing through, so that more or less any Rhino or Gh object, like Points and other geometry, can simply pass through the component.
So, what type of “Add???Parameter” should be used? I tried with AddGenericParameterbut that doesn’t play well with IGH_Goo. I tried to search in ‘Parameter’ and ‘IGH_Goo’ but that combination didn’t give any answers.
Edit: It works fine with AddGenericParameter and ‘IGH_Goo’ after some debugging.
Yup, generic parameters and IGH_Goo are the most base-level ones you can use. It will work on all data since all data must ultimately implement IGH_Goo.
If your component does some geometric stuff, like transformations or boundingboxes, then you have to step it up to AddGeometryParameter() and IGH_GeometricGoo.
If your code works on two (or more) types that do not inherit neatly from a common base class or interface, you will also have to use IGH_Goo and perform type testing yourself. For example the Addition component works on integers, numbers, boolean, points, vectors, and colours, so it has to take the broad approach of using Param_Generic and doing all the sifting internally.
OneOf -option inports
While at it, it would be nice to have an extra feature on the inports which I call “OneOf”, meaning that all inports which have this option set to true will, when a wire is connected, release any other inport which also has this option set.
Edit: I moved the rest of this post to a separate post: