C# Group output

I’m trying to bake a GH Group within a C# script. I understand the Group is ungrouped when it enters the C# component but I don’t understand how to regroup it again so that it bakes as a Group from the script ( just like right-mouse click on the Group component in GH and selecting Bake). I’ve read a couple of past discussions, but they fell short. I’m interested in developing & understanding the process and prefer not to rely on a plug-in.

ThanksGroup.gh (9.0 KB)

Hi Billd
Try this code.

if (bake)
  var geos = geo as List<object>;
  if (geos == null || geos.Count == 0)return;
  var ghGoos = geos.Select(o => GH_Convert.ToGeometricGoo(o)).Where(o => o != null);
  var grp = new GH_GeometryGroup();
  var doc = Rhino.RhinoDoc.ActiveDoc;
  Guid g = Guid.Empty;
  grp.BakeGeometry(doc, null, ref g);

2020-11-18-Group.gh (17.0 KB)