GH - Inport type GeometryBase crashes in runtime

rhino5

#1

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.

// Rolf


#2

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.

// Rolf


(David Rutten) #3

Point3d is a struct and thus cannot inherit from GeometryBase.

If you’re just pumping data from left to right I recommend using IGH_Goo. If it has to be geometric data, then you can switch to IGH_GeometricGoo.


#4

So, what type of “Add???Parameter” should be used? I tried with AddGenericParameter but 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. :frowning:

Edit: It works fine with AddGenericParameter and ‘IGH_Goo’ after some debugging.

// Rolf


(David Rutten) #5

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.


#6

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:

// Rolf


Wish - GH Component Inport option "OneOf"