Get geometry type in RhinoC# like connect them to the grasshopper's Panel

Hi! I have a question when I’m attempting to get the geometry’t type in the C# component in Grasshopper. If I plug geometries to a grasshopper panel, it will show geometries’s type such as “Open Brep”, “Invalid Brep” and “Closed Brep” (the thrid panel in the screenshot). But if I directly use “ToString()” or “GeometryBase.ObjectType”, the panel in grasshopper won’t show the object type as directly put geometries to the panel.

Detailed Geo Type.gh (9.0 KB)

Does anyone know how to access those object detail types in the grasshopper panel in C#? Thank you!

This is coming from Grasshopper itself, there is nothing for this in RhinoCommon. It is based on Brep.IsValid and Brep.IsSolid to tell you it’s valid brep and whether it is closed or open.

1 Like

If you absolutely need to reproduce the Grasshopper ToString behavior, there is a trick to get it using NodeInCode in C# / ghpythonlib.components in Python.

In C#:

var TextJoinComponent = Rhino.NodeInCode.Components.FindComponent("TextJoin");
GeoToString = TextJoinComponent.Delegate.DynamicInvoke(new List<Object>{"", Geo}, "");

In Python:

from ghpythonlib import components as ghc
GeoToString = ghc.TextJoin(["", Geo])

The C# version messes data organization and creates a tree output for some reason, I’m sure there is a way to clean that up.

But I don’t really see why you’d need to do that: if you need to know whether a Brep is open or closed, or if it’s valid, use the RhinoCommon methods that Menno mentionned. If you need your script component to play nicely with a Grasshopper panel, just send the geometry objects to an ouput and plugin a panel to that:

2 Likes

Thank you Menno!

Thank you Pierre! The reason is that I’m trying to use only one component to calculate volume. So I want to filter any invaild brep or open brep/meshes.