Converting GH_Surface (Cylinder) input to Rhino Mesh in C#

Hey! I’m currently writing a c# script to take a Grasshopper Surface Cylinder as the input, and display the image in a windows form. The cylinder gets classified as GH_Surface type, and I need to convert that to a Rhino.Geometry Mesh in order to further manipulate the data to be a windows mesh object. However, currently, only one of the faces of the cylinder is displayed, and the top of it is missing.

The code used to do this conversion is:

Any help is appreciated! Thank you:)

Hi, I think you need to attach the entire code otherwise nobody can help.

But honestly your code looks correct. Also I’m wondering why there assumed to be multiple surfaces. A cylinder may be just a single Nurbs surface even if it is enclosed in a Brep capsule.

Do you want to check the number of items in Mesh array? if it is 1, then the problem is something else.

Hi! Thanks for your reply. You’re right, the cylinder object might just be one surface as it is has an untrimmed surface value.

I just checked and the Mesh array returns size 1. Do you have any idea what the problem might be in this case?


Hi if so, the issue is not your code.

This is just my guess, but from the ancient era, Graphics has been used some tricks to speed up the rendering. One of them is to render only the faces looking toward the screen. This is because if the geometry is a closed sphere or a cylinder, the faces looking backward are hiding behind the faces looking toward the screen, so you don’t need to draw the half. I don’t know if this trick is still alive in 2020 modern Windows GUI framework (WPF?) because it speeds up only 2x and there should be geometries that are not closed solids, which is your case. Your cylinder does not have top and bottom caps made the backward faces visible from the screen which is not a good friend with this ancient trick.
I guess there is an option to show backward faces but clearly this is the GUI framework issue, not Rhino
Maybe this?

Thank you!! This solved my problem:) I wouldn’t have thought to look there myself