Sort geometry by type (C# in GH)

I am trying to make a simple component in GH that takes in curves and surfaces, but outputs only surfaces.

I get this error message that the objects cannot be converted to surfaces.

“Error (CS1502): Den överlagrade metod som bäst matchar System.Collections.Generic.List<Rhino.Geometry.Surface>.Add(Rhino.Geometry.Surface) har några ogiltiga argument (line 62)
Error (CS1503): Argumentet 1: kan inte konverteras från object till Rhino.Geometry.Surface (line 62)”

It works if I specify the input to be surfaces but then I cannot input both curves and surfaces.

Cast your x[i] to a surface object:

Rhino.Geometry.Surface surf = x[i] as Rhino.Geometry.Surface;

and then test it

if(surf == null){
     //cast failed, it was a curve

Thank you, that worked excellent! :smiley: