Hi all,
I’ve run into a bit of trouble in Rhino v7 (see below) when trying to identify Trimmed Surfaces from the GeometryBase type in a compiled component. I am aware that trimmed surfaces are actually Breps and “Trimmed Surface” is GH-specific, but it seems that compiled components fail to recognize them as such in the first place. Once the compiled component sees them as Surface type, they are automatically cast as the underlying untrimmed surface.
Here’s a comparison between a compiled and a scripted component that spit out the object type from a GeometryBase input (code inside the components is listed below):
The scripted component identifies everything as a Brep no matter what, while the compiled component identifies surfaces as Surface even if they are trimmed, unless they pass through a Brep type component.
Scripted component code:
private void RunScript(GeometryBase G, ref object T)
{
if (G == null) return;
T = G.ObjectType;
}
Compiled component code (relevant parts):
public class TestBrepType : GH_Component
{
public TestBrepType()
: base("TestBrepType", "Nickname", "Description", "test", "test")
{
}
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddGeometryParameter("Geometry", "G", "Geometry", GH_ParamAccess.item);
}
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddTextParameter("Type", "T", "The recognized geometry type", GH_ParamAccess.item);
}
protected override void SolveInstance(IGH_DataAccess DA)
{
GeometryBase obj = null;
if (!DA.GetData(0, ref obj)) return;
DA.SetData(0, obj.ObjectType);
}
}
The question is: how can I recognize a trimmed surface as a Brep type from GeometryBase type in Rhino v7?
EDIT: this whole situation happens in v7, in Rhino v8 things look like this (which is fine for what I need to do):

